Architecture of the Compiler Edit
The OpenJFX compiler operates in two passes: the front-end and the back-end. The front-end parses the OpenJFX source code, processes it as an FX AST, and finally generates a standard Java AST. The back-end begins with this Java AST and processes it almost identically to the manner that Java code is processed -- finally generating class files.
Front-End (JavafxCompiler) Edit
- Parsing -- parse the OpenJFX source into an FX AST -- generated using ANTLR (v2.g)
- Module building -- wrap module content in a module class (JavafxModuleBuilder)
- Attribution et. al. -- decorate the FX AST with type and symbols information (JavafxAttr, JavafxEnter, JavafxMemberEnter)
- Type morphing -- convert bound and potentially bound variables to Locations, bound expressions to closures, etc (JavafxTypeMorpher)
- Initialization building -- construct instance and attribute initializers (JavafxInitializationBuilder)
- Convert to Java AST -- by construction, translation, pass-through, and use of partial translation decorated on the FX AST by prior phases, build a Java AST
- Prepare for back-end -- remove any contamination on Java AST: symbols, types, etc (JavafxPrepForBackEnd)
Back-End (JavafxJavaCompiler) Edit
The back-end receives only the Java AST and nametable from the front-end -- as if they had been parsed from Java code. This pass differs from the standard Java compiler passes only by starting after the parse phase and because OpenJFX Block Expression nodes are passed all the way to code generation.
- Attribution et. al. -- decorate the Java AST with type and symbols information (BlockExprAttr, BlockExprEnter, BlockExprMemberEnter)
- Dataflow analysis -- detected errors in variable usage (Flow)
- Desugaring -- prepare for code generation (BlockExprLower, BlockExprTransTypes)
- Code generation (BlockExprGen)
Functionality will be added to the compiler by (1) extending the grammar and FX ASTs while handling these new ASTs in all the front-end phases and/or (2) adding new phases between the "Attribution" and "Convert to Java AST" phases.
Back to OpenJFX Compiler