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/12/01 07:18:00 UTC

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

    [ https://issues.apache.org/jira/browse/GROOVY-9324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16985489#comment-16985489 ] 

Daniel Sun commented on GROOVY-9324:
------------------------------------

{{AstBulder}} is based on \{{AstStringCompiler}} and is written in Groovy too, so we will encounter "egg" and "chicken" issue if we use {{AstBuilder}} in Groovy core code.

> 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
>            Priority: Major
>             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 AST transformations in groovy core 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 {
>           ...
>      }
> """).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)