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:11:00 UTC
[jira] [Closed] (GROOVY-9324) Implement `AstStringCompiler` in Java
[ https://issues.apache.org/jira/browse/GROOVY-9324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun closed GROOVY-9324.
------------------------------
Resolution: Fixed
Fixed by https://github.com/apache/groovy/commit/ae9beecc6f753b7d13cec9747b3956c6ca7a609b
> 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 {{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)