MultiPascal is a Delphi (ObjectPascal) multi-target compiler using the LLVM framework. It is an attempt at a working Delphi7 compiler, in particular one capable of compiling to Flash (ActionScript 3). The original goal was to target the ActionScript Virtual Machine (AVM), in order to port some large Delphi projects such as the TERRA graphical engine and the Minimon 3D game to the web. Other future targets will include x86 and Javascript/asm.js+WebGL (probably using emscripten). Another interestig target would be Haxe.
MultiPascal was started in January 2014 and it's still in its early stages. As of Abril 2014, the Delphi front-end is mostly done, with the C++ back-end supporting most of Delphi features and an initial prototype of the LLVM IR back-end.
Planned stages of the project:
-
a Delphi front-end for LLVM
Initially we thought of using the Dgrok recursive-descent (LL(k)) parser. However, looking at the work required to convert the simple lexical-oriented Parse Tree that Dgrok produces to a robust complete AST, we decided to create our own shift-reduce parser.
So MultiPascal ended up with a complete new shift-reduce (LALR) parser created with the C# ports of the Jay Yacc-based parser generator (CSJay) and the JFlex lexer generator (CSFlex).
Currently MultiPascal is built on top of LLVM 3.2, the same version used in FlaCC/Crossbridge. -
a C++ back-end
-
AS3 (Flash) back-end
We meant to emulate the manual memory management of Delphi through the Flash domain memory component, which was introduced in AS3 to support the FlaCC/Crossbridge C++ compiler. Some documentation on manual memory management in Flash can be found here
-
ABC (AS3 bytecode) back-end, based on the AVM2 target developed in FlaCC/Crossbridge
References:
-
LLVM
LLVM Documentation
LLVM 3.2
LLVM C API
LLVM Programmer's manual
LLVM IR Language reference
LLVM.NET wrapper