use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class ICall method resolve.
@Override
default IValue resolve(MarkerList markers, IContext context) {
final int wildcards = this.wildcardCount();
if (wildcards > 0) {
return this.toLambda(markers, context, wildcards);
}
this.resolveReceiver(markers, context);
this.resolveArguments(markers, context);
// Don't resolve and report an error if the receiver is not resolved
IValue receiver = this.getReceiver();
if (receiver != null && !receiver.isResolved()) {
return this;
}
// Don't resolve and report an error if the arguments are not resolved
if (!this.getArguments().isResolved()) {
return this;
}
return this.resolveCall(markers, context, true);
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class MethodAssignment method writeExpression.
@Override
public void writeExpression(MethodWriter writer, IType type) throws BytecodeException {
if (Types.isVoid(type)) {
super.writeExpression(writer, type);
return;
}
final IValue expression = this.arguments.getFirst();
final Variable receiverVar = new Variable(null, this.receiver.getType(), this.receiver);
final Variable expressionVar = new Variable(null, expression.getType(), expression);
receiverVar.writeInit(writer);
expressionVar.writeInit(writer);
this.method.writeCall(writer, new FieldAccess(receiverVar), new ArgumentList(new FieldAccess(expressionVar)), this.genericData, Types.VOID, this.lineNumber());
expressionVar.writeGet(writer);
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class MethodCall method resolveImplicitCall.
protected IValue resolveImplicitCall(MarkerList markers, IContext context) {
final IValue implicit = context.resolveImplicit(null);
if (implicit == null) {
return null;
}
final IMethod method = ICall.resolveMethod(context, implicit, this.name, this.arguments);
if (method == null) {
return null;
}
this.receiver = implicit;
return this.checkArguments(markers, context, method);
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class AbstractFieldAccess method resolve.
// make sure to consider Optional Chain Awareness when overriding this method
@Override
public IValue resolve(MarkerList markers, IContext context) {
this.resolveReceiver(markers, context);
if (this.field != null) {
// to deal with capture correctly
this.capture(markers, context);
return OptionalChainAware.transform(this);
}
final IValue v = this.resolveAccess(markers, context);
if (v != null) {
// resolveAccess is Optional Chain Aware
return v;
}
// Don't report an error if the receiver is not resolved
if (this.receiver == null || this.receiver.isResolved()) {
this.reportResolve(markers);
}
return OptionalChainAware.transform(this);
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class IDataMember method checkAssign.
default IValue checkAssign(MarkerList markers, IContext context, SourcePosition position, IValue receiver, IValue newValue) {
if (this.hasModifier(Modifiers.FINAL) && !context.isConstructor()) {
markers.add(Markers.semanticError(position, this.getKind().getName() + ".assign.final", this.getName()));
}
final IType type = this.getType();
final ITypeContext typeContext = receiver == null ? ITypeContext.NULL : receiver.getType();
final TypeChecker.MarkerSupplier markerSupplier = (errorPosition, expected, actual) -> {
final String kindName = this.getKind().getName();
final Marker marker = Markers.semanticError(errorPosition, kindName + ".assign.type", this.getName());
marker.addInfo(Markers.getSemantic(kindName + ".type", expected));
marker.addInfo(Markers.getSemantic("value.type", actual));
return marker;
};
return TypeChecker.convertValue(newValue, type, typeContext, markers, context, markerSupplier);
}
Aggregations