You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (Jira)" <ji...@apache.org> on 2019/11/29 19:10:00 UTC

[jira] [Created] (GROOVY-9324) Implement `AstStringCompiler` in Java

Daniel Sun created GROOVY-9324:
----------------------------------

             Summary: Implement `AstStringCompiler` in Java
                 Key: GROOVY-9324
                 URL: https://issues.apache.org/jira/browse/GROOVY-9324
             Project: Groovy
          Issue Type: Improvement
            Reporter: Daniel Sun
            Assignee: Daniel Sun
             Fix For: 3.0.0-rc-2


We can use {{AstStringCompiler}} to construct AST in Java code, it will be especially useful when we want to implement {{ASTTransformation}} and generate complicated bytecode. For example,

{code:java}
AsmClassGenerator acg = controller.getAcg();

// Using text block in Java 13(preview)
new AstStringCompiler().compile("""
     if ('a' == x) {
          ...
     } else {
          ...
     }
""", CompilePhase.CONVERSION, true).get(0).visit(acg);
{code}

So we do not have to contruct AST with util methods of {{GeneralUtils}}  any more.





--
This message was sent by Atlassian Jira
(v8.3.4#803005)