Pas2JS General
Pas2JS is a source-to-source compiler (S2S Compiler).
Convert Pascal source to JavaScript source.
It's a part of FreePascal Compiler.
With Pas2JS compiler, CT can build from Pascal source code, JavaScript applications.
These JavaScript applications are ECMAScript 5 and should run in any browser or in Node.js.
CodeTyphon Studio support Pas2JS to ALL Host OSes,
you can build Pas2JS Web Applications on:
- Windows
- Linux
- MacOS
- FreeBSD
- NetBSD
- OpenBSD
- DragonFly
- OpenIndiana
- Solaris
Supported pascal syntax elements
A significant amount of Object Pascal syntax is supported, including RTTI. A more detailed list can be found in the translation file in the sources.
- Delphi and ObjFPC mode
- Program, Units, namespaces
- unit initialization, but not finalization
- Var, Const, Type
- string (unicodestring), char (widechar), Boolean, Double, Byte, Shortint, Word, Smallint, longword, Longint, nativeint(int53), nativeuint(int52), currency
- resourcestrings
- Pointer (as a reference to a class, array, record, pointer of record, interface, but no pointer arithmetic)
- Record (but no variant records), advanced records
- Functions, Procedures, nested, anonymous functions
- function types, of object, reference to (closures)
- function arguments: default, const, var, out
- If-then-else
- For-do
- Repeat-until
- While-do
- With-do
- try-finally
- try-except
- enums
- sets
- arrays static, dynamic, open, multi dimensionals, array of const
- String like array operations: a:=[1,2,3]+[1,1];
- class type, visibility, virtual, override, abstract, overload, properties, class properties, class var, class const, constructor, destructor, class constructor
- class-of
- nested classes
- interfaces: CORBA, COM, delegations, method resolution, reference counting, TVirtualInterface
- external classes, vars, const
- class helpers, record helpers, type helpers
- Enumeration for..in..do
- Type alias, e.g. type TTranslateString = type string;
- RTTI
- asm block for embedding JavaScript directly
- compiler directives (e.g. $ifdef, $if, $define, $modeswitch, $R+)
- compile time and run time range checking. Overflow checking
- attributes
- $linklib directive to link modules.
- generics
- Resources
Unimplemented pascal features
- Array of interface
- Enums with custom values
- Finalization sections, class destructors
- Futures
- Global properties
- Inline
- Library
- Objects
- Pointer arithmetic
- Record field interface
- Variants