use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class PrefixCall method resolveCall.
@Override
public IValue resolveCall(MarkerList markers, IContext context, boolean report) {
// Normal Method Resolution
final MatchList<IMethod> candidates = this.resolveCandidates(context);
if (candidates.hasCandidate()) {
return this.checkArguments(markers, context, candidates.getBestMember());
}
// Implicit Resolution
final IValue implicitCall = this.resolveImplicitCall(markers, context);
if (implicitCall != null) {
return implicitCall;
}
// No apply Resolution
if (report) {
this.reportResolve(markers, candidates);
return this;
}
return null;
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class SubscriptAccess method toCompoundAssignment.
@Override
public IValue toCompoundAssignment(IValue rhs, SourcePosition position, MarkerList markers, IContext context, SideEffectHelper helper) {
// x[y...] (op)= z
// -> x[y...] = x[y...] (op) z
// note that x and y... are each only evaluated once
final IValue subscriptReceiver = helper.processValue(this.receiver);
final ArgumentList subscriptArguments = helper.processArguments(this.arguments);
this.receiver = subscriptReceiver;
this.arguments = subscriptArguments;
return new SubscriptAssignment(position, subscriptReceiver, subscriptArguments, rhs).resolveCall(markers, context, true);
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class Template method makeMainMethod.
private void makeMainMethod() {
// func main(args: [String]) -> void = new TemplateName().mainImpl(args)
final ParameterList params = this.mainMethod.getParameters();
final CodeParameter argsParam = new CodeParameter(this.mainMethod, null, Name.fromRaw("args"), new ArrayType(Types.STRING));
params.add(argsParam);
final IValue newTemplate = new ConstructorCall(null, this.templateClass.getClassType(), ArgumentList.EMPTY);
this.mainMethod.setValue(new MethodCall(null, newTemplate, Name.fromRaw("mainImpl"), new ArgumentList(new FieldAccess(argsParam))));
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class Template method toString.
@Override
public void toString(@NonNull String indent, @NonNull StringBuilder buffer) {
for (int i = 0; i < this.importCount; i++) {
buffer.append(indent);
appendImport(indent, buffer, this.importDeclarations[i]);
buffer.append('\n');
}
final IValue directives = this.genMethod.getValue();
if (!(directives instanceof StatementList)) {
directives.toString(indent, buffer);
return;
}
final StatementList statements = (StatementList) directives;
for (int i = 0, count = statements.size(); i < count; i++) {
statements.get(i).toString(indent, buffer);
buffer.append('\n');
}
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class ScopeDirective method toString.
@Override
public void toString(@NonNull String indent, @NonNull StringBuilder buffer) {
buffer.append('#');
final IValue value = this.getValue();
if (value != null) {
buffer.append('(');
value.toString(indent, buffer);
buffer.append(')');
if (this.block != null) {
buffer.append(' ');
}
}
if (this.block != null) {
this.block.toString(indent, buffer);
}
}
Aggregations