* * *

Author Topic: Pascal to JavaScript: A Report  (Read 762 times)

Phil

  • Hero Member
  • *****
  • Posts: 2279
Pascal to JavaScript: A Report
« on: July 31, 2017, 01:24:47 am »
I spent some time over the weekend looking into FPC trunk's Pascal-to-JavaScript converter. Here are some notes I worked up about what I discovered:

https://macpgmr.github.io/MacXPlatform/PascalToJavaScript_AReport.html

Some clever and interesting stuff in the converter. Worth poking around in.

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Pascal to JavaScript: A Report
« Reply #1 on: July 31, 2017, 08:50:52 am »
I spent some time over the weekend looking into FPC trunk's Pascal-to-JavaScript converter. Here are some notes I worked up about what I discovered:

https://macpgmr.github.io/MacXPlatform/PascalToJavaScript_AReport.html

Some clever and interesting stuff in the converter. Worth poking around in.

Actually, the mappings are in the test suite for fppas2js and comes up with *way* better code than you found.
(It is also the only test that currently seems to fail, but I found that is because of the assumption for the test is currently wrong: it should map to 'E', not 'G')
Furthermore note that * a lot of work * is currently being done in trunk by several people. Getting better all the time..

Also note the pas2js utility is currently broken and should be considered dead code (disabled in make) . I filed a bug against it.
Quote
Worth poking around in.
Indeed..... especially if you use trunk and see al the updates flying about... Or are interested in source to source compilers or webassembly, asm.js and the likes..

[edit]
at 4.: was it "write once, compile anywhere" or "write once, document mañana"?  ;D It is simply not finished. (or polished, to satisfy my Polish friends) 8-)
at 5.: relevance is in a) type safety b) using current knowledge.
« Last Edit: July 31, 2017, 03:22:47 pm by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Phil

  • Hero Member
  • *****
  • Posts: 2279
Re: Pascal to JavaScript: A Report
« Reply #2 on: July 31, 2017, 08:31:10 pm »
Actually, the mappings are in the test suite for fppas2js and comes up with *way* better code than you found.
(It is also the only test that currently seems to fail, but I found that is because of the assumption for the test is currently wrong: it should map to 'E', not 'G')

Sorry, I don't understand what you're referring to here.

Also note the pas2js utility is currently broken and should be considered dead code (disabled in make) .

Right, I started by rewriting pas2js so it would compile, but never could get it to convert more than very simple things, so I moved on to testpas2js.

at 4.: was it "write once, compile anywhere" or "write once, document mañana"?  ;D It is simply not finished. (or polished, to satisfy my Polish friends) 8-)

Strikes me as very odd that they don't want to tell the world about it.

at 5.: relevance is in a) type safety b) using current knowledge.

Maybe. We'll see if those things matter.

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Pascal to JavaScript: A Report
« Reply #3 on: July 31, 2017, 09:45:19 pm »
Strikes me as very odd that they don't want to tell the world about it.
That's why trunk is trunk: it is not a playground but to mature things.
Quote
at 5.: relevance is in a) type safety b) using current knowledge.
Maybe. We'll see if those things matter.
Of course that matters.... That's frankly a no-brainer...
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus