Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9324

Implement `AstStringCompiler` in Java

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-rc-2
    • None
    • None

    Description

      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,

      AsmClassGenerator acg = controller.getAcg();
      
      // Using text block in Java 13(preview)
      new AstStringCompiler().compile("""
           if ('a' == x) {
                ...
           } else {
                ...
           }
      """).get(0).visit(acg);
      

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

      Attachments

        Activity

          People

            daniel_sun Daniel Sun
            daniel_sun Daniel Sun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: