I can already see what for this tool could be possibly used. For
example, one could write ObjectPascal code in Lazarus and then convert
it to JavaScript when needed. The advantage is that one could then use
Lazarus IDE code refactoring features like code completion, renaming
identifiers, searching for identifier usages. These features could be
especially useful: renaming functions, renaming variables and code
completion. I currently edit my JavaScript sources in notepad. I know
that there are IDEs for JavaScript, however, I currently don't use any.
Using Object Pascal for JavaScript could be particularly suitable if one
develops a web application where server side is implemented in
FreePascal while client side web pages contain JavaScript & interact
with server.
I will try ur tool on my project soon and report then the results; as
soon as I have time.
05.04.2014 13:48, Michael Van Canneyt пишет:
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.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel