Search in sources :

Example 6 with MethodCall

use of dyvilx.tools.compiler.ast.expression.access.MethodCall 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;
}
Also used : Variable(dyvilx.tools.compiler.ast.field.Variable) VariableStatement(dyvilx.tools.compiler.ast.statement.VariableStatement) StatementList(dyvilx.tools.compiler.ast.statement.StatementList) ConstructorCall(dyvilx.tools.compiler.ast.expression.access.ConstructorCall) FieldAccess(dyvilx.tools.compiler.ast.expression.access.FieldAccess) MethodCall(dyvilx.tools.compiler.ast.expression.access.MethodCall)

Aggregations

MethodCall (dyvilx.tools.compiler.ast.expression.access.MethodCall)6 IValue (dyvilx.tools.compiler.ast.expression.IValue)5 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)3 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)3 IType (dyvilx.tools.compiler.ast.type.IType)3 ConstructorCall (dyvilx.tools.compiler.ast.expression.access.ConstructorCall)2 CodeParameter (dyvilx.tools.compiler.ast.parameter.CodeParameter)2 ArrayType (dyvilx.tools.compiler.ast.type.compound.ArrayType)2 SourcePosition (dyvil.source.position.SourcePosition)1 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)1 IClass (dyvilx.tools.compiler.ast.classes.IClass)1 CastOperator (dyvilx.tools.compiler.ast.expression.CastOperator)1 DummyValue (dyvilx.tools.compiler.ast.expression.DummyValue)1 InstanceOfOperator (dyvilx.tools.compiler.ast.expression.InstanceOfOperator)1 ClassAccess (dyvilx.tools.compiler.ast.expression.access.ClassAccess)1 NullValue (dyvilx.tools.compiler.ast.expression.constant.NullValue)1 IVariable (dyvilx.tools.compiler.ast.field.IVariable)1 Variable (dyvilx.tools.compiler.ast.field.Variable)1 CodeMethod (dyvilx.tools.compiler.ast.method.CodeMethod)1 ParameterList (dyvilx.tools.compiler.ast.parameter.ParameterList)1