Git Product home page Git Product logo

pas2js-for-delphi's Introduction

Pas2js Pascal to JavaScript transpiler for Delphi

It's a Pascal to JavaScript transpiler, adapted for Delphi compiler. It can get Delphi / Free Pascal projects and units and convert them to JavaScript. The original Pas2js transpiler for Free Pascal is here.

Trunk revision 41377 of Pas2js was downloaded from SVN on February 19, 2019. Pas2js for Delphi is inherited from this edition of Pas2js for FPC.

Most important changes

In my edition there are no any modifications, except those that are necessary for compiling in Delphi for Windows.

  • Used Unicode UTF-16 instead of UTF-8 (and ANSI) strings in the transpiler code.
  • Used generic collections (TDictionary<string, XXX>) instead of TFPHashObjectList.

Other changes made due to differences in syntax of Free Pascal and Delphi language

  • case statement for a string expression --> if expression = ... then else if expression = ... then ...
  • for item in enumeration do --> for item := Low(TEnumeration) to High(TEnumeration) do ...

Limitation of Pas2js for Delphi

The original Pas2js supports several operation systems and compilation targets. This Pas2js for Delphi

  • has the pas2js.dpr command-line utility for Windows, 32-bit. You can compile it in Delphi IDE.
  • It was tested for the browser and nodejs target platforms, i.e. it can generate JS files to use in HTML pages and NodeJS.
  • Source files not used in Pas2js utility were excluded from Pas2js for Delphi package.

Testing and compatibility

Pas2js for Delphi compiled with Delphi 10.3.1 and tested on demo programs included in the original Pas2js package.

There is no difference in the output JS files, generated by the original Pas2js (compiled in FPC), and this Pas2js for Delphi. Except for one: the floating point representation is a little different. For ex.,

  • original constant in Pascal: hrfactor = 1/(24);
  • same constant in JS compiled by FPC: 0.041666666666666664
  • same constant in JS compiled by Delphi: 0.0416666666666667
  • original: mssecfactor = 1/(24*60*60*1000);
  • JS compiled by FPC: 1.1574074074074074E-8
  • JS compiled by Delphi: 1.15740740740741E-8

Support and updates

I cannot guarantee that Pas2js for Delphi will be updated regularly as Pas2js for FPC. I did it because Delphi is my primary IDE, and since I plan to use Pas2js in my projects, it's more convenient to work in a single IDE.

License

Pas2js has the same license as the original Pas2js for FPC. It is essentially GNU General Public License with one modification.

(C) 2019 Kryvich.

pas2js-for-delphi's People

Contributors

kryuski avatar

Forkers

boscobecker

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.