use of dyvilx.tools.compiler.ast.expression.access.ConstructorCall in project Dyvil by Dyvil.
the class FuncDirective method convertBlock.
protected static StatementList convertBlock(StatementList block) {
final StatementList value = new StatementList();
// new StringWriter()
final ConstructorCall newStringWriter = new ConstructorCall(null, Template.LazyTypes.StringWriter, ArgumentList.EMPTY);
// let writer = new StringWriter()
final Variable writer = new Variable(Name.fromRaw("writer"), Template.LazyTypes.Writer, newStringWriter);
writer.getAttributes().addFlag(Modifiers.FINAL | Modifiers.GENERATED);
// { let writer = new StringWriter; { ... }; writer.toString }
value.add(new VariableStatement(writer));
value.add(block);
value.add(new MethodCall(null, new FieldAccess(writer), Names.toString));
return value;
}
use of dyvilx.tools.compiler.ast.expression.access.ConstructorCall in project Dyvil by Dyvil.
the class EnumConstant method resolve.
@Override
public void resolve(MarkerList markers, IContext context) {
final ArgumentList arguments = new ArgumentList(new StringValue(this.name.unqualified), new IntValue(this.index));
if (this.value != null) {
if (this.value.valueTag() == IValue.TUPLE) {
arguments.addAll(((TupleExpr) this.value).getValues());
} else {
arguments.add(this.value);
}
}
this.value = new ConstructorCall(this.position, this.enclosingClass.getClassType(), arguments);
super.resolve(markers, context);
}
Aggregations