Class JavaTranspiler

java.lang.Object
ortus.boxlang.compiler.javaboxpiler.Transpiler
ortus.boxlang.compiler.javaboxpiler.JavaTranspiler
All Implemented Interfaces:
ITranspiler

public class JavaTranspiler extends Transpiler
BoxLang AST to Java AST transpiler The registry maps a AST node to the corresponding Transformer Java class instance. Each transformer implements the logic to convert the BoxLang AST nodes into Java AST nodes.
  • Constructor Details

    • JavaTranspiler

      public JavaTranspiler()
  • Method Details

    • transform

      public com.github.javaparser.ast.Node transform(BoxNode node, TransformerContext context) throws IllegalStateException
      Utility method to transform a node with a transformation context
      Specified by:
      transform in class Transpiler
      Parameters:
      node - a BoxLang AST Node
      context - transformation context
      Returns:
      Throws:
      IllegalStateException
      See Also:
    • getStatements

      public List<com.github.javaparser.ast.stmt.Statement> getStatements()
    • compileJava

      public String compileJava(com.github.javaparser.ast.CompilationUnit cu, String outputPath, List<String> classPath) throws IllegalStateException
      Write a class bytecode
      Parameters:
      cu - java compilation unit
      outputPath - output directory
      classPath - classpath
      Throws:
      IllegalStateException - in the compilation fails
    • transpile

      public TranspiledCode transpile(BoxNode node) throws BoxRuntimeException
      Transpile a BoxLang AST into a Java Parser AST
      Specified by:
      transpile in interface ITranspiler
      Specified by:
      transpile in class Transpiler
      Returns:
      a Java Parser TranspiledCode representing the equivalent Java code
      Throws:
      IllegalStateException
      BoxRuntimeException
      See Also:
    • getCallables

      public List<com.github.javaparser.ast.CompilationUnit> getCallables()
      Get the list of compilation units that represent the callable functions
      Returns:
      the list of compilation units
    • getUDFcallables

      public Map<Key,com.github.javaparser.ast.CompilationUnit> getUDFcallables()
      Get the list of compilation units that represent the callable functions
      Returns:
      the list of compilation units
    • getUDFDeclarations

      public List<com.github.javaparser.ast.stmt.Statement> getUDFDeclarations()
      Get the list of UDF declarations that will get hoisted to the top
      Returns:
      the UDF declarations
    • getStaticUDFDeclarations

      public List<com.github.javaparser.ast.stmt.Statement> getStaticUDFDeclarations()
      Get the list of static UDF declarations that will get hoisted to the top
      Returns:
      the UDF declarations
    • createAbstractMethod

      public com.github.javaparser.ast.expr.Expression createAbstractMethod(BoxFunctionDeclaration bfd, AbstractTransformer transformer, String sourceObjectName, String sourceObjectType)