use of dyvilx.tools.compiler.ast.parameter.IParameter in project Dyvil by Dyvil.
the class TypeVarType method checkType.
@Override
public void checkType(MarkerList markers, IContext context, int position) {
if ((position & TypePosition.REIFY_FLAG) == 0) {
return;
}
final Reified.Type reifiedKind = this.typeParameter.getReifiedKind();
if (reifiedKind == null) {
return;
}
final IParameter reifyParameter = this.typeParameter.getReifyParameter();
if (reifyParameter == null) {
return;
}
this.reifyVariableAccess = new FieldAccess(reifyParameter).resolve(markers, context);
// ensure proper capture
this.reifyVariableAccess.checkTypes(markers, context);
}
use of dyvilx.tools.compiler.ast.parameter.IParameter in project Dyvil by Dyvil.
the class SimpleMethodVisitor method visitEnd.
@Override
public void visitEnd() {
if (this.intrinsicData != null && !this.unsupportedInline) {
this.method.setIntrinsicData(this.intrinsicData);
}
int localIndex = this.method.hasModifier(Modifiers.STATIC) ? 0 : 1;
final ParameterList parameters = this.method.getExternalParameterList();
for (int i = 0, count = parameters.size(); i < count; i++) {
final IParameter param = parameters.get(i);
param.setLocalIndex(localIndex);
if (param.getName() == null) {
param.setName(this.getName(localIndex));
}
localIndex += param.getLocalSlots();
}
}
use of dyvilx.tools.compiler.ast.parameter.IParameter in project Dyvil by Dyvil.
the class SimpleMethodVisitor method visitParameter.
@Override
public void visitParameter(String name, int modifiers) {
final IParameter parameter = this.method.getExternalParameterList().get(this.parameterIndex);
if (parameter == null) {
return;
}
this.parameterIndex++;
if (name != null && !name.isEmpty()) {
final Name name1 = Name.fromQualified(name);
parameter.setName(name1);
parameter.setLabel(name1);
}
if (modifiers != 0) {
if ((modifiers & Modifiers.ACC_VARARGS) != 0) {
// add the internal bitflag for varargs parameters
modifiers |= Modifiers.VARARGS;
}
parameter.getAttributes().addFlag(modifiers);
}
}
use of dyvilx.tools.compiler.ast.parameter.IParameter in project Dyvil by Dyvil.
the class Field method resolve.
@Override
public void resolve(MarkerList markers, IContext context) {
super.resolve(markers, context);
if (this.value != null) {
final IContext context1 = new CombiningContext(this, context);
this.value = this.value.resolve(markers, context1);
boolean inferType = false;
if (this.type == Types.UNKNOWN) {
inferType = true;
this.type = this.value.getType();
}
final TypeChecker.MarkerSupplier markerSupplier = TypeChecker.markerSupplier("field.type.incompatible", "field.type", "value.type", this.name);
this.value = TypeChecker.convertValue(this.value, this.type, this.type, markers, context1, markerSupplier);
if (inferType) {
this.type = this.value.getType();
if (this.type == Types.UNKNOWN && this.value.isResolved()) {
markers.add(Markers.semantic(this.position, "field.type.infer", this.name.unqualified));
this.type = Types.ANY;
}
}
} else if (this.type == Types.UNKNOWN) {
markers.add(Markers.semantic(this.position, "field.type.infer.novalue", this.name.unqualified));
this.type = Types.ANY;
}
if (this.property == null) {
return;
}
this.property.setType(this.type);
final IMethod getter = this.property.getGetter();
final IMethod setter = this.property.getSetter();
final IValue receiver = this.hasModifier(Modifiers.STATIC) ? null : new ThisExpr(this.enclosingClass.getThisType(), VariableThis.DEFAULT);
if (getter != null) {
getter.setType(this.type);
if (getter.getValue() == null) {
// get: this.FIELD_NAME
getter.setValue(new FieldAccess(getter.getPosition(), receiver, this));
}
}
if (setter != null) {
final IParameter setterParameter = setter.getParameters().get(0);
setterParameter.setType(this.type);
if (setter.getValue() == null) {
final SourcePosition setterPosition = setter.getPosition();
if (this.hasModifier(Modifiers.FINAL)) {
markers.add(Markers.semanticError(setterPosition, "field.property.setter.final", this.name));
// avoid abstract method error
setter.setValue(new VoidValue(setterPosition));
} else {
// set: this.FIELD_NAME = newValue
setter.setValue(new FieldAssignment(setterPosition, receiver, this, new FieldAccess(setterPosition, null, setterParameter)));
}
}
}
this.property.resolve(markers, context);
}
use of dyvilx.tools.compiler.ast.parameter.IParameter in project Dyvil by Dyvil.
the class ICall method toLambda.
default IValue toLambda(MarkerList markers, IContext context, int wildcards) {
SourcePosition position = this.getPosition();
final IParameter[] parameters = new IParameter[wildcards];
for (int i = 0; i < wildcards; i++) {
parameters[i] = new CodeParameter(null, position, Name.fromRaw("wildcard$" + i), Types.UNKNOWN, new AttributeList());
}
int parIndex = 0;
final IValue receiver = this.getReceiver();
if (receiver != null && receiver.isPartialWildcard()) {
this.setReceiver(receiver.withLambdaParameter(parameters[parIndex++]));
}
final ArgumentList arguments = this.getArguments();
for (int i = 0, size = arguments.size(); i < size; i++) {
final IValue argument = arguments.get(i, null);
if (argument.isPartialWildcard()) {
arguments.set(i, null, argument.withLambdaParameter(parameters[parIndex++]));
}
}
final LambdaExpr lambdaExpr = new LambdaExpr(position, parameters, wildcards);
lambdaExpr.setImplicitParameters(true);
lambdaExpr.setValue(this);
return lambdaExpr.resolve(markers, context);
}
Aggregations