[fpc-devel] Pascal to Javascript - Call for Help
Michael Van Canneyt
michael at freepascal.org
Sat Apr 5 11:48:29 CEST 2014
Hello,
After many years of dreaming of an open source version of Morfik Appsbuilder,
(and more recently Smart Mobile Studio), I've finally committed a first version
of the pascal-to-javascript conversion engine.
The unit and the associated unit tests are in
packages/pastojs
and a sample converter program in
utils/pas2js
This is a limited initial commit. It will convert plain pascal to javascript, almost verbatim.
It will not yet convert everything, objects are not yet supported, for instance, neither are
var arguments. Scope is also an issue. In fact, it can convert things that do not need a lot
of context - plain syntactical conversion, if you want.
However the engine is IMHO ready for the more serious work.
At least it shows the ideas underpinning the project.
This is potentially a big project, which I cannot handle alone (FPC is a circle of volunteers,
after all). Therefor I'd like to invite people to have a look at the code, give remarks, submit
patches.
That said:
There will also be an effort to let the Free Pascal compiler itself output Javascript
(using asm.js or plain javascript), to which I will - to the best of my abilities
- also contribute.
Why 2 efforts ? The goals of these efforts are not the same:
- The goal of the compiler is to compile all of pascal.
This will result in unreadable javascript, simulating heap memory etc.
It will be more comparable to assembler than to hand-written javascript.
- The goal of this project is to generate understandable Javascript.
The idea is not to convert all existing code to work in the browser (depends on the code),
but rather to be able to program the browser in Object Pascal.
As a consequence, not all pascal constructs will be supported (pointers,
direct memory access jump to mind).
Another matter is that the treshold for understanding the compiler is rather
high (I myself don't claim to understand the compiler fully).
Whereas I believe that understanding this project should be within reach of everyone
that knows object pascal (I may be wrong in this belief, of course ;) )
Both efforts will use the same backend for writing javascript, so the javascript writer
and the javascript syntax tree have been kept low-key, meaning that they can be compiled to
depend almost exclusively on the system unit (no classes unit, to name but one).
Feel free to discuss here or mail me in private with more questions.
Michael.
More information about the fpc-devel
mailing list