Pas2JS Version Changes

From Free Pascal wiki
Jump to navigationJump to search

Releases

Next Version

  • Fixed precedence multiply and power: 100 * 9 ** 0.5 results in 100 * (9 ** 0.5)
  • Fixed Delphi style multiline string literals containing apostrophs.

3.0.1

27th Feb 2024

Changes:

  • New download server for the precompiled binaries: https://getpas2js.freepascal.org
  • Namespaces (unitnames with dotted prefixes):
    • added compiler option -FN<X>: add <x> to namespaces. Namespaces with trailing - are removed. Delphi calls this flag "unit scope names".
    • The packages were extended to support namespaced version of units, e.g. units in packages/rtl are now in packages/rtl/src and the namespaced versions are in packages/rtl/namespaced
    • This requires updating the -Fu paths in your pas2js.cfg, see pas2js.cfg Example
  • Removed submodule "compiler" and instead support "compiler" as copy, symlink or FPCDIR environment variable. See Fetching pas2js source via git and compile
  • Many external JS classes updated and extended
  • FPC Wasm code can access the DOM and JS APIs through pas2js code: WebAssembly/DOM
  • fixed marking library export function result sub elements as used
  • fixed parsing var section after class var section
  • fixed names of properties MultilineStringsTrimLeft and MultilineStringsEOLStyle
  • fixed multilinestrings:
    • combos like `abc`#10
    • double backticks become, same as double apostrophs become one in string literals
    • apostroph
  • fixed anonymous procedure type
  • fixed anonymous record type
  • fixed searching TJSPromise in global scopes, while context is a dot scope
  • fixed typecast array literal to TJSArray
  • added releasecreator, tool written in fpc to compile the compiler and tools
  • Support for datamodules in resources
  • Tool to import typescript declaration modules as external classes
  • Split Web unit into units usable in service workers and main browser window.
  • Many updates on the widgets, support for bulma-styled widgets
  • JSONRPC client support and tool to generate import based on ExtJS-styled API.
  • Add Debugcapture to send logging to server
  • Add testinsight client.

3.0.1 Incompatibilities

Unitpaths of default packages in pas2js.cfg

  • The default packages source paths have changed namespaced versions were added.
  • Remedy: Update the -Fu paths in your pas2js.cfg, see pas2js.cfg Example

Version 2.2.0

22th Feb 2022

All changes of version 2.2.0

  • moved from svn to gitlab
  • New command line option: -Ja<x>: Append JS file <x> to main JS file. E.g. -Jamap.js. Can be given multiple times. To remove a file name append a minus, e.g. -Jamap.js-.
  • Added RTTI TProcedureFlag pfSafeCall and pfAsync
  • pas2js now creates unique method pointers (@SomeMethod), e.g. the following code will now remove the @OnLoad:
 xhr.addEventListener('load', @OnLoad);
 xhr.removeEventListener('load', @OnLoad);
  • Pascal Library
    • export for global functions and static methods
    • export for global variables
  • {$linklib} directive, see pas2js modules
  • new -T platform module
  • new -T platform electron
  • mark record fields as used when passing record to a jsvalue parameter
  • $mode Delphi support for generic overloads, e.g. TBird, TBird<T>, TBird<S,T>. Can be used from a unit with mode ObjFPC too, although cannot yet be declared there.
  • fixed delay init specializations after loading impl sections
  • fixed specialize try except on, issue 38795
  • fixed float / 0.0 results at compiletime in infinity instead of div by zero, issue 38815
  • fixed low/high(aString)
  • fixed typecast jsvalue to external class instance not object checking by default, only when object checks are enabled. For example TJSString(aJSValue).length.
  • fixed emulate compile time assign integer constant of different type
  • fixed typeinfo Module, Attributes, ResultType and Params now have default value nil, not undefined.
  • fixed cloning multi dim static array on assign
  • fixed stack overflow on deep nested binary expressions
  • fixed releasing com interface fields on destroy
  • fixed class property getter for array property of static method
  • fixed find generic proc overload without params, issue 38796
  • fixed calling constructor of nested external class, issue 38858
  • fixed await() as aclass, issue 39028
  • fixed consistent error message on custom js file not found, issue 38978
  • fixed writing sourceMappingURL only if map file enabled, issue 39210
  • fixed Setlength(unicodestring) issue 39208
  • fixed call type helper on type helper read from pcu

2.2.0 Incompatibilities

pas2js.cfg

  • The binary packages' file pas2js.cfg now enables -Jc (concatenate all js) by default. You can disable this with -Jc-.

Version 2.0.6

15th Apr 2021

  • fixed insert(item,array,pos) when array=nil
  • fixed published field with anonymous array
  • fixed -O- and record const, issue 38683
  • fixed multi add a + ImplicitFuncCall + b
  • (generics) Add comparer version of TDictionary create.
  • (generics) Fix wrong comparison of objects, adjusted patch by Henrique Werlang (Issue 38748)
  • (db) Patch from Henrique Werlang to implement TDatasetField
  • (rtti) Patch from Henrique Werlang to implement getting method parameters info
  • (db) Fix in TDataSet.DefaultBytesToBlobData, index out of range
  • (sysutils) TStringBuilder implementation
  • (arrayutils) Start of array utils
  • (web) Clipboard support (bug ID 0038726)
  • (sysutils) Use TBoolStrs for Boolean.ToString helper
  • (jsondataset) Publish OnRecordResolved, OnLoadFail
  • (db) Implement TBlobField.DisplayValue
  • (classes) Add ExtractStrings
  • (classes) StringStream.ReadString/WritString. Fix TMemoryStream.LoadFromStream.
  • (classes) Correctly handle CR/LF in GetNextLineBreak in TStrings.
  • demos: Fix demo to work again with latest webwidget
  • demos: Fixed demorouter example
  • (packages) new flatpickr lib
  • (sysutils) provide suitable defaults for Long- and ShortTimeFormat
  • (web) Patch from Henrique Werlang to implement TJSCSSStyleDeclaration
  • (web) Patch from Henrique Werlang to implement TJSElement.Remove
  • (classes) correctly stream TStrings based properties
  • (db) Patch from Henrique Werlang to let TDatalink transmit events ony when active
  • (sysutils) Introduce FormatSettings

Version 2.0.4

26th Mar 2021

  • fixed wrong setting rtl.TObjectDestroy
  • fixed no hint when published method hides ancestor method
  • fixed compileserver option --simpleserver= and -d relative path
  • fixed stack overflow on long string concatenations
  • fixed filer restore global shortrefs

Version 2.0.2

9th Mar 2021

  • fixed freeing temporary class interface, if it is nil.
  • removed obsolete TTypeInfoDynArray.DimCount
  • fixed TTypeInfoStaticArray.Dims
  • fixed obj as COMIntfType, when obj is nil': for FPC and Delphi compatibility nil returns nil and does not raise an exception.
  • fixed checking statement after except-on
  • fixed if then asm a;b end
  • fixed ord(integer)
  • fixed Include(SetOfIntegerRange, integer)
  • fixed omitting hint for not used property
  • fixed var a: (b,c);
  • fixed calling Instance.StaticMethod not using Instance
  • fixed fixed creating enum shortrefs for precompiled code for optimization EnumValues

Version 2.0.0

11th Jan 2021

All changes of version 2.0.0

  • fixed TDictionary with procedural type
  • fixed TTypeInfoRecord.RecordType

Version 2.0.0RC8

31th Dec 2020

  • fixed UTF-16 char literal #128..#255
  • fixed using invalid UTF-16 but valid string #$DC00'b'
  • fixed checking class method modifiers match class interface (as in IUnknown)
  • fixed typecast specialized array to specialized type
  • fixed implicit call of specialized method
  • added separate hints 4501 field "x" not used and 4502 field "x" assigned but never used. Delphi/FPC do not have these hints, as they treat records as one memory block and can't omit fields. pas2js can omit fields.
  • The param in await(param) must now be an async function, to avoid accidentally calling the wrong function or not a function at all.
  • Allowing await(T,jsvalue), because jsvalue could be a promise.
  • fixed typecast implicit function call passing to arg, e.g. aFunc(aType(obj.bFunc))
  • fixed delayed init specialized class interface

Version 2.0.0RC7

13th Dec 2020

  • fixed optimization shortrefglobals and enum value
  • fixed filer storing unix line ending and writing precompiled code with platform line ending
  • fixed unit without implementatiom
  • fixed record member type

Version 2.0.0RC6

8th Dec 2020

  • the binary snapshot now use same directories as "make all". E.g. bin\i386-win32 for the Windows 32bit executables.
  • the binary snapshot now contains the makestub utility
  • fixed filer, call type helper of unit, which unit implementation has not been parsed.
  • fixed catching load file exceptions and turn into regular errors
  • fixed generating typeinfo for classes with published members, but not referenced via typeinfo

Version 2.0.0RC5

4th Dec 2020

  • fixed skipping non fully specialized types
  • fixed filer, storing reference to await and debugger
  • fixed filer, specialize signature of implementation of methods
  • fixed filer, skipping generic reference to generic type
  • fixed filer, reading inline specialize expression
  • fixed filer, checking signatures needing indirect units of implementation

Version 2.0.0RC4

30th Nov 2020

  • fixed await on as operator
  • fixed await(ProcArgument)
  • fixed hint Await needs a promise
  • fixed calling async function with result type COM interface
  • fixed checking 'await(T,callasyncfunc) type match
  • fixed async procedure modifier not needed in implementation of a procedure
  • added FormData js keyword
  • fixed shortrefglobals optimization of new/free instance fields
  • fixed crash on parser error in inline specialize expression, issue 38111
  • fixed typeinfo path of inline specialize type
  • fixed -OoShortRefGlobals
  • fixed error when using generic type without parameters
  • fixed shortrefglobals when unit initialization uses unit of otherwise empty implementation section

Version 2.0.0RC3

13th Nov 2020

  • fixed typeinfo unicodestring and widechar
  • fixed passing widechar to var argument char and unicodestring to string and vice versus.
  • rtl: system.pas: removed obsolete UnicodeString=string and WideChar=char type alias. They are normal compiler types.
  • fixed typecast integer to widechar
  • fixed ord(widechar)
  • added overload TryStrToInt64 with int64, TryStrToQWord with QWord, TryStrToUInt64 with UInt64

Version 2.0.0RC2

11th Nov 2020

  • fixed shortrefglobals for minimal class interface, issue 38042
  • fixed disable optimization using fpc syntax e.g. -OoNoShortRefGlobals, issue 3804
  • fixed shortrefglobals for procedure without args, issue 38043
  • -JRnone now skips resource directives

Version 2.0.0RC1

5th Nov 2020

All changes of version 2.0.0

  • the binary snapshots now use same directories as "make all". E.g. bin\i386-win32 for the Windows 32bit executables.
  • Generics
  • Attributes:
    • Incompatibility: $modeswitch ignoreattributes was removed
    • base class System.TCustomAttribute
    • $modeswitch prefixedattributes: enabled by default in $mode Delphi
    • declare in front of any type, type member
    • the Delphi compiler attributes like ref, weak, volatile, etc are not supported.
    • query attributes of a type:
      • use either typinfo function GetRTTIAttributes(typeinfo(SomeType).Attributes):
      • or use RTTI unit r:=TRTTIContext, r.GetType(typeinfo(SomeType)).GetAttributes
  • class constructors:
    • for classes, records, class helpers, record helpers and type helpers.
    • Called in initialization section
    • Optimizer removes attributes if type is not used.
  • VarArg.Free, e.g. procedure DoIt(var Arg: TObject); begin Arg.Free end; setting Arg to nil
  • range checking for type helpers
  • range checking for var/out arguments
  • fixed low/high(nativeint) for 53 significand bits instead of only 52 explicit bits, increasing high to $1fffffffffffff = 9007199254740991
  • float literal: removing unneeded 0 in front of E e.g. 1.20E1 as 1.2E1
  • Overflow checks for integers -Co {$overflowchecks on} {$Q+} for integer operators +, -, *. Checks if result is outside nativeint and raises EIntOverflow.
  • class abstract modifier
  • type helper for classtype, same as FPC
  • type helper for interfacetype, no constructors, same as FPC
  • Dispatch messages:
    • method modifier message integer and message string
    • directive {$DispatchField fieldname} and {$DispatchStrField fieldname}

Insert these directives in front of your dispatch methods to let the compiler check all methods with message modifiers if they pass a record with the right field.

  TMyComponent = class
    {$DispatchField Msg}
    procedure Dispatch(var aMessage); virtual;
    {$DispatchStrField MsgStr}
    procedure DispatchStr(var aMessage); virtual;
  end;
  TMouseDownMsg = record
    Id: integer; // Id instead of Msg, works in FPC, but not in pas2js
    x,y: integer;
  end;
  TMouseUpMsg = record
    MsgStr: string;
    X,Y: integer;
  end;
  TWinControl = class
    procedure MouseDownMsg(var Msg: TMouseDownMsg); message 3; // warning: Dispatch requires record field Msg
    procedure MouseUpMsg(var Msg: TMouseUpMsg); message 'up'; // ok, record with string field name MsgStr
  end;
  • added rtti utility functions GetInterfaceProp, SetInterfaceProp, GetMethodProp, SetMethodProp
  • TStream with TBytes
    • TBytesStream
  • convert ord(const) to a const
  • Resource strings:
    • Resource strings can now be written to file. This is controlled by the -Jr option, see the main wiki page for pas2js.
  • TJSFunction(@obj.methodname) is now converted to classtype.methodname
  • Constructors of external classes are now supported in four ways:
    • constructor New is translated to new ExtClass(params). Note the missing JS path.
    • constructor New; external name 'GlobalFunc' is translated to new GlobalFunc(). Note the missing JS path.
    • constructor SomeName; external name '{}' is translated to {} - a basic, empty JS object
    • Otherwise it is translated to new ExtClass.FuncName(params)
  • You can now specify a type for the procedure modifier varargs: varargs of SomeType . For example
  procedure SumWords(); varargs of Word;
  ...
  SumWords(1,2,3); // this works
  SumWords(1,98765); // this gives a range check error
  • Srcmap for pju files
  • allowing using a unit twice, with different names, e.g. uses ns.unit1, unit1; or uses foo in 'unit1.pas', unit1;
  • option -Sj to allow/disallow typed const to be writable
  • option -im to show available modeswitches
  • option -M<modeswitch> to enable or disable a modeswitch, see option -im
  • typecasting unrelated classes now gives only a warning "Class types are not related" instead of an error, Reason: FPC/Delphi compatibility
  • mode ObjFPC now checks procedural types in procedure arguments by signature, reason: FPC compatibility. Note: FPC does that too in $mode delphi, pas2js only in mode ObjFPC.
  • type helper for bytebool, wordbool, longbool
  • ArrayOfChar:=String and pass string to ArrayOfChar
  • safecall calling convention and rtl catch uncaught exceptions.
  • Async procedure modifier and await functions:
    • function await(AsyncFunctionOfResultT): T; // implicit promise
    • function await(aType; p: TJSPromise): aType; // explicit promise requires the resolved type
    • function await(aType; v: jsvalue): aType; // explicit optional promise requires the resolved type
  • Descending a Pascal class from a JS Function
  • The makestub utility converts a Pascal import unit for importing Pascal classes to a unit that is compilable by Delphi
  • fcl-json JSON interface from FPC.
  • New units for Javascript libraries:
    • libjitsimeet interface to jitsi video conferencing.
    • libopentok interface to opentok video conferencing.
    • libkurento interface to kurento video conferencing.
    • libfullcalendar(4/5) interface to fullcalendar.io JS library
    • libdatatables interface to datatables.net JS library
    • pushjs interface to browser Push Notifications
    • libbootstrap interface to bootstrap classes.
    • gmaps interface to google maps interface.
  • added separate hints 4501 field "x" not used and 4502 field "x" assigned but never used. Delphi/FPC do not have these hints, as they treat records as one memory block and can't omit fields. pas2js can omit fields.
  • Optimizations:
    • -O2  : Level 2 optimizations (Level 1 + not debugger friendly)
    • -OoShortRefGlobals[-]: Insert a JS local var for each module, type and static function. Default enabled in -O2.

2.0.0 Incompatibilities

Signature for event handlers TEventListenerEvent and TJSEvent

The signature for event handlers has been corrected. The class TEventListenerEvent is now an alias for TJSEvent

That means that the 2 event handler types
 TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;
 TJSRawEventHandler = reference to Procedure(Event: TJSEvent);
are now equivalent.

TJSEvent type definition

The TJSEvent type definition has been corrected

The currentTarget and Target properties of TJSEvent are now of type TJSEventTarget, as they are in the official specs:
  property currentTarget : TJSEventTarget Read FCurrentTarget;
  property target : TJSEventTarget Read FTarget;
For convenience, a targetElement and CurrentTargetElement property have been added which are of type TJSElement:
   property currentTargetElement : TJSElement;
   property targetElement : TJSElement;

modeswitch ignoreattributes was removed

The workaround {$modeswitch ignoreattributes} was removed. Attributes are now implemented.

Version 1.4.34

28th Oct 2020

  • fixed passing in mode delphi a proc address to a proc type argument.
  • fixed searching pju file, when uses-in-file missing
  • fixed a div b for negative results
  • fixed aCurrency/bCurrency for negative results

Version 1.4.32

15th Oct 2020

  • fixed crash on class function
  • fixed array shrink using SetLength
  • fixed try except on ExternalClass do ; end;
  • fixed dynamic array function a:=concat(b); // marking b as referenced
  • fixed dynamic array function c:=concat(a,b);
  • fixed $ancestor of all root classes is null instead of undefined
  • fixed rtl.spaceLeft return value

Version 1.4.30

8th July 2020

  • fixed assign record with field of dynamic array
  • fixed SysUtils.AnsiSameText comparing strings with umlauts.

Version 1.4.28

3rd Jul 2020

  • fixed system.inc()
  • fixed namespace search order
    • Reason: Delphi/FPC compatibility.
    • Old behaviour: search default namespace (aka prepend program namespace), prepend command line namespaces, no namespace (i.e. as written in uses section)
    • New behaviour: search no namespace (i.e. as written in uses section), prepend command line namespaces, prepend default namespace (aka program namespace)
    • For example program that uses "classes" and units classes.pas and system.classes.pas are in unit search path.
  • fixed try exit(value) finally read Result end

Version 1.4.26

6th Jun 2020

  • fixed RTTI of record/class field with shared anonymous array, e.g. type t = record a,b:array of byte; end;

Version 1.4.24

11th May 2020

  • fixed assign array

Version 1.4.22

10th May 2020

  • fixed allowing member with same name as an ancestor member in $mode delphi
  • fixed allow static directive repetition in method implementation
  • fixed type helper for NativeInt and NativeUInt
  • fixed type helper Self in nested procedure
  • fixed (i*i).helperfunc
  • fixed SetLength(array,..) using resize instead of clone, when not shared. Assign marks an array with a hidden property $pas2jsrefcnt.

Version 1.4.20

11th April 2020

  • fixed stack overflow on long procedures
  • fixed class helper in with-do

Version 1.4.18

15th Dec 2019

  • access modifier constref: works as const, gives a warning for non records, arrays
  • omit not used resourcestrings
  • fixed sourcemap for Firefox

Version 1.4.16

15th Oct 2019

  • fixed helper for type alias type
  • fixed selecting last declared helper
  • replaced rtl.setArrayLength with faster non recursive version
  • fixed external static class method
  • fixed check for helper class method for external class must be static
  • fixed marking implicit call in property parameter

Version 1.4.14

30th Aug 2019

  • source map: when using -Jmabsolute -Jmsourceroot=file:// prepend the absolute source files with file://. Needed by Firefox.
  • fixed longword bitwise operations not, and, or, xor, shl, shr for numbers > $7fffffff
  • fixed creating relative paths without shared based directory, e.g. in source maps C:\foo\project1.js.map C:\bar\project1.pas

Version 1.4.12

28th Aug 2019

  • fixed get method reference of Self inside anonymous method without self
  • fixed typecast nil to class, interface, dynamic array
  • fixed endless loop on type TArr = array of TArr
  • no warning "function result not set" for fieldless record
  • fixed check for duplicate unit, when names differ
  • fixed ComInterfaceInstance is/as InterfaceType to use QueryInterface
  • fixed passing dynamic array to open array var parameter

Version 1.4.10

10th Jul 2019

  • added separate error message duplicate published method
  • fixed allowing reintroduce published method
  • fixed high(dynarrayvar with expr)
  • fixed class var a:t; b:t;
  • fixed type helper in other unit

Version 1.4.8

24th June 2019

  • fixed var a: somearray = nil
  • fixed fixed assignment inside anonymous proc inside for-loop
  • fixed ArcTan definition (bug ID 35655)
  • setlength(arr) now always clone for FPC/Delphi compatibility. Formerly it merely resized the array.

Version 1.4.6

20th Apr 2019

  • fixed advanced records
  • fixed linux rtl.js

Version 1.4.4

19th Apr 2019

  • fixed duplicate identifier when redefining a procedure.
  • fixed escaping string literals in asm blocks

Version 1.4.2

11th Apr 2019

  • fixed optimization of NewInstance function
  • fixed filer class helper
  • fixed passing TExt.new as parameter
  • fixed writing workingdirectory
  • fixed advanced record constructor
  • handling environment options PAS2JS_OPTS
  • fixed nodejs GetEnvironmentVariable returning empty string for non existing variables

Version 1.4.0

24th Mar 2019

  • fixed supporting older node.js (<7.0.0) using Math.pow instead of newer exponential operator **.

Version 1.4.0RC7

16th Mar 2019

  • fixed accessing Self in anonymous function
  • fixed UntypedArg:=recordvar and RecordType(UntypedArg)
  • an external method of a helper is treated like an external method of the helped type
  • updated examples
  • fixed hint method hides identifier with same signature
  • fixed hint argument not used, with array argument and only writing an element
  • fixed hint argument not used, with array argument passed as argument

Version 1.4.0RC6

8th Mar 2019

  • fixed passing class var to var argument
  • fixed reading precompiled units by default

Version 1.4.0RC5

6th Mar 2019

  • fixed overload var arg and type alias
  • added overload TryStrToFloat with type extended
  • nativeint shr int
  • nativeint shl int
  • no hint when hiding private method
  • fixed passing multiple -vm parameters
  • fixed include file search in module directoy
  • allow typecast external class to unrelated external class in $mode delphi, e.g. TJSEventTarget(aJSWindow). Normally you need TJSEventTarget(TJSObject(aJSWindow)).

Version 1.4.0RC4

3rd Mar 2019

  • fixed {$warn identifier error}
  • fixed and/or/xor with nativeint
  • warn on nativeint shl/shr int using only 32bit
  • fixed type helper call as arg
  • fixed (f*f).helpercall
  • fixed info message macro name set to "value"
  • make all now creates a default bin/targetcpu-targetos/pas2js.cfg, so that pas2js.exe works out-of-the box.

Version 1.4.0RC3

27th Feb 2019

  • renamed $modeswitch multiplescopehelpers to multihelpers, same as FPC
  • fixed TAliasOfEnumType.EnumValue
  • fixed emitting hints for not used units
  • fixed SetBufListSize

Version 1.4.0RC2

18th Feb 2019

  • fixed typecast jsvalue(anobject/interface), not doing getObject,
  • fixed obj.Free set to nil if already nil
  • added unit websvg.pas providing API to SVG elements
  • fixed getdelimitedtext, quoting was wrong
  • fixed array-of-const references in precompiled units
  • Added some missing routines in strutils (containstext, containsstr)

Version 1.4.0RC1

16th Feb 2019

  • Highlights:
    • class helpers
    • record helpers
    • type helpers
    • advanced records
    • array of const
    • added locate to JSONdataset, as well as lookup and support for lookup fields.
    • Added Indexes (sorting) to JSONDataset.
  • Incompatibilities:
    • pas2js now searches units first in the folder of the current module as Delphi does.
    • JSArguments declaration was changed from an array of jsvalue to TJSFunctionArguments.


All changes of version 1.4.0

  • Pas2js supports class helpers, record helpers and type helpers since 1.3. The extend is only virtual, the helped type is kept untouched.
    • A class helper can "extend" Pascal classes and external JS classes.
    • A record helper can "extend" a record type. In $mode delphi a record helper can extend other types as well, see type helper
    • A type helper can extend all base types like integer, string, char, boolean, double, currency, and some user types like enumeration, set, range and array types. It cannot extend interfaces or helpers.
    • Type helpers are available by default in $mode delphi and disabled in $mode objfpc. You can enable them with {$modeswitch typehelpers}.
    • By default only one helper is active per type, same as in FPC/Delphi. If there are multiple helpers for the same type, the last helper in scope wins. A class with ancestors can have one active helper per ancestor type, so multiple helpers can be active, same as FPC/Delphi. Using {$modeswitch multihelpers} you can activate all helpers within scope.
    • Nested helpers (e.g. TDemo.TSub.THelper) are elevated. Visibility is ignored. Same as FPC/Delphi.
    • Helpers cannot be forward defined (e.g. no THelper = helper;).
    • Helpers must not have fields.
    • Class Var, Const, Type
    • Visibility : strict private .. published
    • Function, procedure: In class and record helpers Self is the class/record instance. For other types Self is a reference to the passed value.
    • Class function, class procedure: Helpers for Pascal classes/records can add static and non static class functions. Helpers for external classes and other types can only add static class functions.
    • Constructor. Not for external classes. Works similar to construcors, i.e. THelpedClass.Create creates a new instance, while AnObj.Create calls the constructor function as normal method. Note that Delphi does not allow calling helper construcors as normal method.
    • no destructor
    • Property : getters/setters can refer to members of the helper, its ancestors and the helped class/record.
    • Class property : getter can be static or non static. Delphi/FPC only allows static.
    • Ancestors : Helpers can have an ancestor helper, but they do not have a shared root class, especially not TObject.
    • no virtual, abstract, override. Delphi allows them, but 10.3 crashes when calling.
    • inherited inside a method of a class/record calls helper of ancestor.
    • inherited inside a helper depends on the $mode:
      • $mode objfpc : inherited; and inherited Name(args); work the same and searches first in HelperForType, then in ancestor(s).
      • $mode delphi: inherited; : skip ancestors and HelperForType, searches first in helper(s) of ancestor of HelperForType.
      • $mode delphi: inherited name(args); : same as $mode objfpc first searches in HelperForType, then Ancestor(s)
      • In any case if inherited; has no ancestor to call, it is silently ignored, while inherited Name; gives an error.
    • RTTI: typeinfo(somehelper) returns a pointer to TTypeInfoHelper with Kind tkHelper.
    • There are some special cases when using a type helper function/procedure on a value:
      • function result : using a temporary variable
      • const, const argument : When helper function tries to assign a value, pas2js raises a EPropReadOnly exception. FPC/Delphi use a temporary variable allowing the write.
      • property : uses only the getter, ignoring the setter. This breaks OOP, as it allows to change fields without calling the setter. This is FPC/Delphi compatible.
      • with value do ; : uses a temporary variable. Delphi/FPC do not support it.
  • built-in function concat (string1,string2,...)
  • local types (declared inside functions) are now created in the global scope
  • added locate to JSONdataset, as well as lookup and support for lookup fields.
  • Added Indexes (sorting) to JSONDataset.
  • Added unit fpexprpars.pas, an expression parser unit (needed for dataset filtering...)
  • omit unnecessary brackets on associative operations (a||b)||(c||d), (a&&b)&&(c&&d), (a|b)|c, (a&b)&c, (a^b)^c, (a+b)+c, (a-b)-c, (a*b)*c
  • records are now created as Object, instead of JS function
    • records now have hidden (not enumerable) functions $new, $assign, $clone, $eq
    • passing records to var argument now passes the record directly instead of creating a temporary setter
    • Assigning a record, e.g. aRecord:=value, now copies the values, while keeping the JS object. This makes pointer of record Delphi/FPC compatible.
  • Advanced records: enabled in $mode delphi, disabled im $mode objfpc, enable with {$modeswitch AdvancedRecords}
    • visibility private, strict private, public, default is public
    • methods, class methods (must be static like in FPC/Delphi), constructors
    • class vars
    • const
    • property, class property, array property, default array property
    • nested types
    • RTTI
  • Records can now have external fields with '[2]', '["a b"]'
  • In $mode objfpc forward class-of and pointer declarations can now refer to types even if there are other const/var/resourcestring sections in between. Same a FPC. For example:
type 
  TClassOfBird = class of TBird;
const k = 1;
type 
  TBird = class end;
  • lo(), hi() in $mode delphi returning the lo/hi byte, in $mode objfpc returning the lo/hi byte|word|longword.
  • char range with non ascii literals: 'Б'..'Я'
  • typecast char to word and other integers
  • added option -Jmabsolute to store absolute filenames in sourcemaps
  • JSArguments declaration was changed from an array of jsvalue to TJSFunctionArguments.
  • fixed expr[][] with default properties
  • fixed assigning class vars
  • pas2js now searches units first in the folder of the current module as Delphi does.
  • fixed case-of with non ascii literals
  • implemented ProcVar:=StaticClassMethod
  • implemented ProcVar:=ClassMethod inside static class method
  • class property getter/setter can now be static or non static.
  • array of const:
    • Works the same: vtInteger, vtBoolean, vtPointer, vtObject, vtClass, vtWideChar, vtInterface, vtUnicodeString
    • longword is converted to vtNativeInt instead of mangling to vtInteger
    • vtExtended is double, Delphi/FPC: PExtended
    • vtCurrency is currency, Delphi/FPC: PCurrency
    • Not supported: vtChar, vtString, vtPChar, vtPWideChar, vtAnsiString, vtVariant, vtWideString, vtInt64, vtQWord
    • only in pas2js: vtNativeInt, vtJSValue
  • fixed o.ProcVar() when ProcVar is typeless property
  • fixed const evaluation float - currency
  • fixed reading #$00xx as widechar, bug 34923
  • fixed relative paths in srcmap in Windows
  • nicer error message on invalid set element type

Version 1.2.0

Version 1.2.0RC1

type
  TRefProc = reference to procedure;
  TProc = procedure;
procedure DoIt(arg: TRefProc);
var 
  ref: TRefProc;
  proc: TProc;
begin
  ref:=procedure begin end; // assign to "reference of procedure" type
  ref:=procedure  // note the omitted semicolon
    var i: integer; // var, types, const, local procedures
    begin
    end; 
  DoIt(procedure begin end); // pass as argument
  refproc:=procedure assembler asm // embed JavaScript
      console.log("foo");
    end; 
  // Note that typecasting to non "reference to" does not make a difference 
  // because in JS all functions are closures:
  proc:=TProc(procedure begin end);   
end;
  • added variable rtl.version, which corresponds to the compiler version Major*10000+Minor*100+Release
  • added option -JoCheckVersion:
    • -JoCheckVersion- : do not add rtl version check, default.
    • -JoCheckVersion=main : insert rtl.checkVersion() into main.
    • -JoCheckVersion=system : insert rtl.checkVersion() into system unit.
    • -JoCheckVersion=unit : insert rtl.checkVersion() into every unit.
  • moved classtopas function to a class2pas unit, improved the interface so it uses a stringlist. Adapted the demo.
  • Fix System.Int() so it also works on IE (where Math.trunc is missing).
  • allow typecasting string(apointer) and pointer(astring)
  • asm-block now skips Pascal comments //... and Pascal string literals with single quotes. It no longer stops at end in such comments and string literals.
  • Fix FormatFloat() rounding logic (actually FloatToDecimal)
  • Fix stringofchar for count<=0
  • Fix quotestring and add quotedstr
  • implemented special includes like {$i %date%}:
    • %date%: current date as string literal, '[yyyy/mm/dd]'
    • %time%: current time as string literal, 'hh:mm:ss' Note that the inclusion of %date% and %time% will not cause the compiler to recompile the unit every time it is used: the date and time will be the date and time when the unit was last compiled.
    • %line%: current source line number as string literal, e.g. '123'
    • %linenum%: current source line number as integer, e.g. 123
    • %currentroutine%: name of current routine as string literal
    • %pas2jstarget%, %pas2jstargetos%, %fpctarget%, %fpctargetos%: target os as string literal, e.g. 'Browser'
    • %pas2jstargetcpu%, %fpctargetcpu%: target cpu as string literal, e.g. 'ECMAScript5'
    • %pas2jsversion%, %fpcversion%: compiler version as string literal, e.g. '1.0.2'
    • If param is none of the above it will use the environment variable. Keep in mind that depending on the platform the name may be case sensitive. If there is no such variable an empty string is inserted.
  • implemented pred(char), succ(char)
  • allow typecasting TypedPointer(UntypedPointer)
  • allow assign UntypedPointer:=TypedPointer
  • skip double quotes in asm-blocks, e.g. s = "end"+"'";
  • added {$modeswitch OmitRTTI}: treat class section 'published' as 'public' and typeinfo() does not work on symbols declared with this switch. This allows to easily disable generating RTTI and allows the optimizer to omit unused published properties.
  • added option -Jpcmd<command>: Run postprocessor. For each generated js execute command passing the js as stdin and read the new js from stdout. This option can be added multiple times to call several postprocessors in succession. Quote the <command> to add options for the postprocessor. For an example see minifier.
  • Added built-in procedure Debugger;, which is converted to the JavaScript statement debugger;. If a debugger is running it will break on this line just like a break point.
  • Changed operator precedence level of is to same as and, or, xor. Same as fpc/delphi.
  • fixed assert to raise on false, bug 34643
  • built-in procedure val(const string; out enum; out int)
  • added option -JoRTL-<x>=<y> to change the name of a autogenerated identifier. See the list of available identifiers with -iJ.

Version 1.0.4

  • 14th Nov 2018
  • SVN release tag is https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_4
  • fixed calling destructor after exception in constructor
  • fixed initializing static array of record
  • fixed parsing if expr then raise else
  • fixed local record and enum types
  • fixed for e in set do
  • fixed for-in of shared sets
  • fixed inc(classvar)
  • fixed assigning class var of descendant classes
  • fixed error position on include file not found
  • fixed loading include file from cache
  • fixed range check of o.aString[index] and o.aArray[index]
  • fixed Result:=inherited;
  • fixed escaping invalid UTF-16 in string literals
  • fixed not generating octal literals in ECMAScript5, it bites strict mode
  • fixed IsNaN on ECMAScript6
  • fixed error on method in record
  • fixed name clash published property and external
  • fixed str(aCurrency)
  • catch ECompilerTerminate while parsing params
  • sLineBreak and LineEnding are now var under platform NodeJS

Version 1.0.3

function GetItems(const i: integer): byte;
property Items[i: integer]: byte read GetItems;
  • fixed high(intvar)
  • fixed WPO when using record constants
  • fixed include(FuncResultSet,enum)
  • fixed if then <empty> else <something>;
  • fixed p^.x:=
  • fixed acurrency:=aninteger to become acurrency:=aninteger*10000
  • fixed integer(acurrency) to become Math.floor(acurrency/10000)
  • fixed calling $final, clearing references on destroy
  • fixed not calling BeforeDestruction on exception in constructor
  • fixed $class be a property of the class, not the object
  • fixed local var modifier absolute in method
  • fixed using external const in const expression, e.g. const tau = 2*pi;
  • fixed selecting procedure overload, preferring lossy int over int to float
  • fixed calling Free inside method
  • fixed System.Int() so it also works on IE (where Math.trunc is missing).
  • fixed FormatFloat() rounding logic (actually FloatToDecimal)
  • fixed stringofchar for count<=0
  • fixed quotestring and add quotedstr

Version 1.0.2

Version 1.0.1

Version 1.0.0

Version 1.0.0rc1

  • 24 Jul 2018
  • fixed TObject.Create()
  • -vd shows stacktraces

Version 0.9.32

  • 17 Jul 2018
  • fixed memory leaks and double frees

Version 0.9.31

  • 10 Jul 2018
  • fixed aIntSet:=[0]
  • fixed crash on List.Items.Dummy
  • fixed some mem leaks
  • fixed -MDelphi + $mode objfpc + overloads withouts overload keyword
  • TGUIDString is now type string
  • RTL: added websockets

Version 0.9.30

  • 4 Jul 2018
  • fixed calling COM interface _Release function for expressions.
  • fixed catching exception in pju variant of pas2js
  • split reserved words into two categories: the compiler now checks global JS identifiers like "Date" only for identifiers without path. That means a local variable Date will be renamed, a property Date will not, keeping the RTTI name of properties. Identifiers like apply are still renamed.
  • fixed property RTTI for alias type in other unit
  • fixed default value of integer variables, using 0 even if it is outside range. Reason: Delphi/FPC compatibility.

Version 0.9.29

  • 29 Jun 2018
  • fixed pcu reading alias type
  • fixed analyzer: element needing typeinfo marks indirect elements as used normally
  • hint for text after final "end.", disable with $warn GARBAGE off
  • $warn BOUNDS_ERROR off: disable range check warnings at compile time
  • $warn MESSAGE_DIRECTIVE off: disable $message notes

Version 0.9.28

  • 27 Jun 2018
  • fixed static array of char = stringlit+stringlit
  • fixed libpas2js disk full error
  • $warn directive: {$warn identifier on|off|default|error}, identifier can be a message number as shown with -vq or one of the following. Note, that some hints like "Parameter %s not used" are currently using the enable state at the end of the module, not the state at the hint source position.
    • CONSTRUCTING_ABSTRACT: Constructing an instance of a class with abstract methods.
    • IMPLICIT_VARIANTS: Implicit use of the variants unit.
    • NO_RETVAL: Function result is not set
    • SYMBOL_DEPRECATED: Deprecated symbol
    • SYMBOL_EXPERIMENTAL: Experimental symbol
    • SYMBOL_LIBRARY
    • SYMBOL_PLATFORM: Platform-dependent symbol
    • SYMBOL_UNIMPLEMENTED: Unimplemented symbol
    • HIDDEN_VIRTUAL: method hides virtual method of ancestor

Version 0.9.27

  • 26 Jun 2018
  • mode delphi: fixed passing static array to open array
  • allow assigning aTypeInfo:=pointer, needed by units with and without using unit typinfo

Version 0.9.26

  • 25 Jun 2018
  • typecast function address to JS function, e.g. TJSFunction(@IntToStr)
  • typecast function reference to JS function, e.g. TJSFunction(OnClick)
  • typecast method address to JS function, e.g. TJSFunction(@List.Sort). Note that a method address creates a function wrapper to bind the Self argument.
  • changed some types to type alias: TDateTime, TDate, TTime, Single, Real, Comp, UnicodeString, WideString. This only effects typinfo and some compiler error messages. Reason: Delphi/FPC compatibility.
  • In mode delphi dynamic array initializations must now use square brackets instead of round brackets. For example var a: array of integer = [1,2];. Reason: Delphi compatibility.
  • Assignation using constant array. For instance Arr:=[1,2,3], where Arr is a dynamic array.
  • + operator for arrays: This concatenation operator is available using the new modeswitch arrayoperators, which is enabled by default in mode delphi.
  • unit webgl updated
  • unit webaudio added
  • unit webbluetooth added
  • db unit: ftDataset field type added (not supported)
  • JSONDataset unit: TField.OldValue now works for TJSONDataset
  • webidl2pas tool added. A command line tool to create Pascal units from idl specs.
  • allow external record fields.
  • hint 5024 'Parameter "%s" not used' was split into two:
    • 4501 for virtual/override methods
    • 5024 for others

Version 0.9.25

  • 7 Jun 2018
  • TComponent now supports IInterface
  • -o is now always relative to working directory, even if -FU or -FE is given. Reason: FPC compatibility
  • fixed typeinfo(typeintegerrange)
  • fixed using interface ancestor methods
  • fixed 'make' building with fpc 3.0.4

Version 0.9.24

  • 2 Jun 2018
  • fixed precompiled js formatting to same options as compiled js
  • fixed unit analyzer private method used by protected property
  • fixed class-of RTTI
  • fixed precompiled resolve pending scopes before pending units

Version 0.9.23

  • 28 May 2018
  • added webgl demos from Ryan Joseph
  • for value in jsarray do - where jsarray is any external class with a matching length and default property. This enumerates similar to other arrays the values, not the index.
  • allow typecast array to TJSObject
  • allow typecast TJSObject to array
  • Unicode character constants outside of BMP, e.g. #$10437
  • allow {$H+}, error on {$H-}
  • added intrinsic procedure WriteStr(out s: string; params...), which works similar to str(param,s), except it can take any amount of parameters, which are concatenated.
  • added option -Sm to enable macro replacements

Version 0.9.22

  • 17 May 2018
  • Fixed $00ff00

Version 0.9.21

  • 16 May 2018
  • added option -FE: set the main output path, used for the main .js file, if there is no -o option or the -o option has no folder.
  • fixed WPO typeinfo of inherited property
  • for easier FPC integration the following message IDs were changed:
    • nVirtualMethodXHasLowerVisibility = 3250; // was 3050
    • nConstructingClassXWithAbstractMethodY = 4046; // was 3080
    • nNoMatchingImplForIntfMethodXFound = 5042; // was 3088
    • nSymbolXIsDeprecated = 5043; // was 3062
    • nSymbolXBelongsToALibrary = 5065; // was 3061
    • nSymbolXIsDeprecatedY = 5066; // 3063
    • nSymbolXIsNotPortable = 5076; // was 3058
    • nSymbolXIsNotImplemented = 5078; // was 3060
    • nSymbolXIsExperimental = 5079; // was 3059

Version 0.9.20

  • 11 May 2018
  • fixed passing typecasted alias type to var parameter
  • forbid typecast rectordtype to other recordtype
  • remove leading zeroes in number literals
  • added namespace option -FN<x>, marked -NS as obsolete. Reason: fpc compatibility.
  • added option -vz : write messages to stderr, -o. still uses stdout.
  • added option -ic : Write list of supported JS processors usable by -P<x>
  • added option -io : Write list of supported optimizations usable by -Oo<x>
  • added option -it : Write list of supported targets usable by -T<x>
  • added option -SIcom, -SIcorba interface style
  • added option -vv : Write pas2jsdebug.log with lots of debugging info
  • fixed option -va including option -vt
  • fixed combination of -Jc -o.
  • option -vt now writes used unit scopes
  • external class fields with brackets. e.g. X: nativeint external name '[0]'
  • autogenerated interface GUIDs now consider the unitname

Version 0.9.19

  • 2 May 2018
  • type alias type, e.g. type TCaption = type string;
  • record const, e.g. const p: TPoint = (x:1; y:2);
  • {$WriteableConst on|off}: treat typed constants as readonly, e.g. const i:byte=3;... i:=4; creates a compile time error.
  • forbid assignment of for-loop variable
  • nested classes
  • property specifier nodefault
  • default(type) returning the initial value of the type, e.g. default(recordtype).
  • external typed const: e.g. const NaN: Double; external name 'NaN';
  • case string of support for ranges
  • fixed typecast shortint(integer)

Version 0.9.18

  • 26 Apr 2018
  • Fixed rcArrR in rtl.js

Version 0.9.17

  • 25 Apr 2018
  • Fix recno calculation for TJSONDataset
  • Fix initializing next buffers in TDataset.
  • Implemented Currency as double, values are multiplied by 10000 and truncated, so a 2.7 is stored as 27000.
  • Implemented pointer of record. It's simply a reference.
    • p:=@r translates to p=r
    • p^.x becomes p.x
    • intrinsics new(PointerOfRecord), dispose(PointerOfRecord). dispose(p) sets p to null if possible.
  • enumerator for jsvalue: e.g. var v: jsvalue; key: string; for key in jsvalue do translates to for (key in jsvalue){}
  • enumerator for external class: e.g. var o: TJSObject; key: string; for key in o do translates to for (key in o){}
  • range checking $R+
    • compile time: warnings become errors
    • run time: int:=, int+=, enum:=, enum+=, intrange:=, intrange+=, enumrange:=, enumrange+=, char:=, charrange:=
    • run time: parameters: int, enum, intrange, enumrange, char, charrange
    • run time: array[index], string[index]
  • type cast integer to integer, e.g. byte(aLongInt)
    • with range checking enabled: error if outside range
    • without range checking: emulates the FPC/Delphi behaviour: e.g. byte(value) translates to value & 0xff, shortint(value) translates to value & 0xff <<24 >>24.
  • case-of statement: error on duplicate values
  • fixed error on int:=double

Version 0.9.16

  • 21 Apr 2018
  • mode delphi: allow "ObjVar is IntfType" and "ObjVar as IntfType" with unrelated types.
  • TVirtualInterface - create an implementation at runtime. rtl unit rtti.pas
  • typecast a class type to JS Object, e.g. TJSObject(TObject)
  • typecast an interface type to JS Object, e.g. TJSObject(IUnknown)
  • typecast a record type to JS Object, e.g. TJSObject(TPoint)
  • not jsvalue is converted to !jsvalue
  • "=" operator for records with static array fields
  • changed TGuid to record
  • TGUID record
    • GuidVar:='{guid}', StringVar:=GuidVar, GuidVar:=IntfTypeOrVar, GuidVar=IntfTypeOrVar, GuidVar=string
    • pass IntfTypeOrVar to GuidVar parameter
  • added new type TGuidString to system unit
    • GuidString:=IntfTypeOrVar, GuidString=IntfTypeOrVar
    • pass IntfTypeOrVar to GuidString parameter
  • added option -JoUseStrict, to enable or disable adding "use strict"

Version 0.9.15

  • 8 Apr 2018
  • fixed crash when ancestor implements more interfaces than current class.

Version 0.9.14

  • 8 Apr 2018
  • fixed duplicates in rtl/strutils.pas
  • fixed reference counts on reading element lists
  • implemented using function result variable in for-loop. e.g. for Result:=..., for Result in ...
  • fixed for string in arrayofstring do
  • fixed $scopedenums with anonymous enumtype. e.g. type TSet = set of (A,B);
  • implemented class interfaces:
    • methods, properties, default property
    • {$interfaces com|corba|default}
      • COM is default, default ancestor is IUnknown (mode delphi: IInterface), managed type, i.e. automatically reference counted via _AddRef, _Release, the checks for support call QueryInterface
      • CORBA: lightweight, no automatic reference counting, no default ancestor, fast support checks.
    • inheriting
    • GUIDs are simple string literals, TGUID = string.
    • An interface without a GUID gets one autogenerated from its name and method names.
    • a class implementing an interface must not be external
    • a ClassType "supports" an interface, if it itself or one of its ancestors implements the interface. It does not automatically support an ancestor of the interface.
    • method resolution, procedure IUnknown._AddRef = IncRef;
    • delegation: property Name: interface|class read Field|Getter implements AnInterface;
    • is-operator:
      • IntfVar is IntfType - types must be releated
      • IntfVar is ClassType - types can be unrelated, class must not be external
      • ObjVar is IntfType - can be unrelated
    • as-operator
      • IntfVar as IntfType - types must be releated
      • IntfVar as ClassType - types can be unrelated, nil returns nil, invalid raises EInvalidCast
      • ObjVar as IntfType - mode delphi: types must be related, objfpc: can be unrelated, nil if not found, COM: uses _AddRef
    • typecast:
      • IntfType(IntfVar) - must be related
      • ClassType(IntfVar) - can be unrelated, nil if invalid
      • IntfType(ObjVar) - mode delphi: must be related, objfpc: can be unrelated, nil if not found, COM: if ObjVar has delegate uses _AddRef
      • TJSObject(intfvar)
    • Assign operator:
      • IntfVar:=nil
      • IntfVar:=IntfVar2 - IntfVar2 must be same type or a descendant
      • IntfVar:=ObjVar - nil if unsupported
      • jsvalue:=IntfVar
    • Assigned(IntfVar)
    • RTTI
    • $modeswitch ignoreinterfaces was removed
    • Not supported: array of interface, interface as record member

Version 0.9.13

  • 21 Mar 2018
  • fixed keeping methods AfterConstruction, BeforeDestruction
  • fixed modeswitch ignoreinterfaces

Version 0.9.12

  • 19 Mar 2018
  • fixed parsing procedure p(var a; b: t)
  • fixed checking duplicate implementation of unit interface procedure

Version 0.9.11

  • 16 Mar 2018
  • fixed loading files encoded in non UTF-8, e.g. UTF-8 with BOM. This was a regression.

Version 0.9.10

  • 13 Mar 2018
  • fixed renaming overloads of unit interface at end of interface, not at end of module. Needed for unit cycles.

Version 0.9.9

  • 13 Mar 2018
  • Fixed libpas2js to use WorkingDir parameter instead of GetCurrentDir
  • Fixed static array clone function.

Version 0.9.8

  • 9 Mar 2018
  • fixed optimizer keep overrides

Version 0.9.7

  • 7 Mar 2018
  • fixed pass local variable v as argument to a var parameter.

Version 0.9.6

  • 6 Mar 2018
  • static arrays are now cloned on assignment or when passed as argument to a function (no const, var, out)
  • Fixed array[enum..enum] of
  • pas2jslib: fixed checks of directoryexists to use cache
  • uses with in-filename: In $mode delphi the in-filenames are only allowed in the program and the unitname must fit the filename, e.g. uses unit1 in 'sub/Unit1.pas'. In $mode objfpc units can use in-filenames too and alias are allowed, e.g. uses foo in 'bar.pas'.

Version 0.9.5

  • 12 Feb 2018
  • Error on duplicate forward class
  • Error on method class in other unit
  • Fixed index property override

Version 0.9.4

  • 8 Feb 2018
  • Removed debug writeln, fixing Disk Full errors in libpas2js.
  • Nicer error messages on illegal qualifier.

Version 0.9.3

  • 4 Feb 2018
  • Fixed number literals outside int64.
  • Shorten float numbers, e.g. 1.00000E+001 to 10
  • unexpected exception now sets ExitCode to 1

Version 0.9.2

  • 4 Feb 2018
  • Fixed -constant, when constant is a negative number

Version 0.9.1

  • 3 Feb 2018
  • Fixed class const evaluating expression.

Version 0.9.0

  • 31 Jan 2018
  • Fixed srcmap header. It must be )]}' to work in Firefox. Added option -JmXSSIHeader to exclude or include the XSSI protection header.
  • Ignore procedure modifier "inline"
  • Char(int)
  • search units and include files case insensitive by default. Enable FPC like search with parameter -JoSearchLikeFPC.
  • Const in external classes:
    • const c: type = value, const c = value are translated to the value.
    • const c: type, class const c: type are treated like readonly variables.

Version 0.8.45

  • 23 Jan 2018
  • is-operator: jsvalue is class-type, jsvalue is class-of-type
  • assertions: -Sa, $C+|-, $Assertions on|off, Assert(boolean), Assert(boolean,string)
  • object checks: -CR, $ObjectChecks on|off, check method calls, check object type casts
  • some bugfixes for alias types
  • multi dimensional static array const, e.g. array[1..2,3..4] of byte = ((5,6),(7,8))
  • fixed overloads when skipping class interface
  • fixed s[i]:= when s is a var parameter

Version 0.8.44

  • 15 Jan 2018
  • State of directives $Hints|Notes|Warnings on|off at end of procedure is used for analyzer hints, e.g. "local variable x not used".
  • Fixed re-reading directories after Reset.

Version 0.8.43

  • 4 Jan 2018
  • Fixed -Fi include path
  • Read directories instead of checking every single file. Added hooks for ReadDir to libpas2js.

Version 0.8.42

  • 25 Dec 2017
  • var absolute modifier for local variables
  • $scopedenums
  • $hint, $note, $warn, $error, $fatal, $message text
  • $message hint|note|warn|error|fatal text
  • $hints, $notes, $warnings on|off

Version 0.8.41

  • 25 Dec 2017
  • Enumerators:
    • ordinal types: char, boolean, byte, ..., longword, enums, sets, static array, custom range
    • const set
    • variables: set, string, array
    • class GetEnumerator
    • It does not support operator enumerator, IEnumerator, member modifier enumerator.

Version 0.8.40

  • File read callback for pas2jslib

Version 0.8.39

  • 14 Dec 2017
  • fixed circular unit dependencies

Version 0.8.38

  • 12 Dec 2017
  • support for * and ? in search paths
  • fixed converting a typecast to an alias proc type
  • fixed inherited-identifier-as-expr
  • emit warning method-hides-method-in-base-type only for virtual methods
  • reduced function hides identifier from level hint to info
  • fixed unit contnrs to always use mode objfpc.

Version 0.8.37

  • 5 Dec 2017
  • Bugfixed a combination of overload/override

Version 0.8.36

  • 5 Dec 2017
  • fixed missing brackets in binary expression and left side has a call (a-f(b)) / (c-d)

Version 0.8.35

  • 20 Nov 2017
  • fixed a bug in the overload code

Version 0.8.34

  • 19 Nov 2017
  • fixed skipping attributes behind procedure declarations.
  • Procedures/methods now properly hides procs with same name.
  • In mode delphi overloads now always require the 'overload' modifier.
  • In mode objfpc the modifier is required when using different scopes.
  • hints for hiding identifiers of other units.
  • implemented system.built-in-identifier.

Version 0.8.33

  • 14 Nov 2017
  • srcmaps with included sources now ignores untranslatable local paths and simply uses the full local path.
  • custom enum ranges, e.g. TBlobType = ftBlob..ftBla
  • custom integer ranges, e.g. TSome = 1..5
  • custom char ranges
  • set of custom enum/integer/char ranges
  • the conversion of the for-to-do loop has changed. If the loop is never executed, the loop variable is not touched. And the start expression is now executed before the end expression.

Version 0.8.32

  • 8 Nov 2017
  • some bug fixes for warnings

Version 0.8.31

  • 29 Oct 2017
  • bugfix for implicit function calls of parameters of some built in functions.

Version 0.8.30

  • 19 Oct 2017
  • nicer "can't find unit" position
  • fixed a crash parsing uses clause

Version 0.8.29

  • 16 Oct 2017
  • bugfixes
  • it now supports directive $M alias $TypeInfo

Version 0.8.28

  • fixed passing static array

Version 0.8.27

  • 4 Oct 2017
  • implemented resourcestrings
  • implemented logical xor
  • fixed class-of-typealias
  • fixed property index modifier expression

Version 0.8.26

  • 3 Oct 2017
  • fixed RTTI for static arrays
  • implemented property modifier index
  • implemented FuncName:=

Version 0.8.25

  • 1 Oct 2017
  • bugfixes
  • a new modeswitch ignoreattributes to ignore attributes.

Version 0.8.24

  • 28 Sep 2017
  • implemented multi dimensional SetLength
  • fixed keeping old values when using SetLength
  • fixed method override of override

Version 0.8.23

  • 27 Sep 2017
  • property default value for sets
  • custom integer ranges, like TValueRelationship
  • typecast enums to integer type (same as ord function)
  • new modeswitch ignoreinterfaces to parse class interfaces, but neither resolve nor convert them. Using them will cause an error.

Version 0.8.22

  • 24 Sep 2017
  • fixed loading dotted units
  • implemented property stored and default modifiers

Version 0.8.21

  • 21 Sep 2017
  • fixed aString[index]:=
  • fixed analyzer to mark default values of arguments
  • many improvements for sourcemaps making step-over/into nicer in Chrome.
  • new tool fpc/packages/fcl-js/examples/srcmapdump to dump the produced sourcemap.
  • unicodestring and widechar are now declared by the compiler instead of system.pas

Version 0.8.20

  • 14 Sep 2017
  • Static array const are now implemented. For example:
  • array['a'..'d'] of integer = (1,2,3,4);
  • array[1..3] of char = 'pas';

Version 0.8.19

  • 12 Sep 2017
  • several bug fixes
  • started static arrays:
    • array[2..6] of char
    • array['a'..'z'] of char
    • array[boolean] of longint
    • array[byte] of string
    • array[enum] of longint
    • array[char] of boolean // Note that char is widechar!
    • low(), high()

Version 0.8.18

  • 6 Sep 2017
  • Anonymous arrays in record members are now supported:
  TFloatRec = Record
     ...
     Digits: Array Of Char;
  End;

Version 0.8.17

  • 3 Sep 2017
  • checks for semicolons between statements
  • fixed proc type of procedure in Delphi mode
  • implemented @@ operator for proc types in Delphi mode.
  • compile time evaluation, range and overflow checking for boolean, base integer types, enums, sets, custom integer ranges, char, widechar, string, single and double.

Version 0.8.16

  • 28 Jul 2017
  • bugfix release.

Version 0.8.15

  • 8 Jul 2017
  • compiler can now generate source maps when passing option -Jm

Version 0.8.14

  • 17 May 2017
  • now supports TObject.Free.

In Delphi/FPC obj.Free works even if obj is nil. In JavaScript this would crash. And to free memory JS requires to clear all references, which is not required in Delphi/FPC. Therefore the compiler adds code to check for null, call the destructor and sets the variable to null.

It does not support freeing properties and function results. For example: List[i].Free; will give a compiler error. The property setter might create side effects, which would be incompatible to Delphi/FPC.

Version 0.8.13

  • 11 May 2017
  • $IF
  • $ELSEIF
  • $IFOPT
  • $Error
  • $Warning,
  • $Note
  • $Hint
  • And in the config files it supports #IF, #IFDEF, #IFNDEF, #ELSEIF, #ELSE, #ENDIF.

Version 0.8.12

  • 5 May 2017
  • dotted unit names and namespaces.

Version 0.8.11

  • 23 Apr 2017
  • dynamic arrays can now be initialized with a constant. Same syntax as static arrays: const a: array of string = ('one', 'two');
  • Classes can now be declared in the unit implementation.
  • Unit nodejs now has a console class TNJSConsole.
  • I added the fpcunit package. Successful tests already work. A fail is not yet caught.

Version 0.8.10

  • 22 Apr 2017
  • you can now use "if aJSValue then", which works just like the JS "if(v)".
  • added ParamCount, ParamStr, GetEnvironment* functions. The default is not doing much.
  • new package fcl_base_pas2js, containing custapp and nodejsapp: - TCustomApplication is the known class from the FCL, but with abstract methods.
  • TNodeJSApplication is a TCustomApplication using nodejs to read command line params and environment variables.

Version 0.8.9

  • 21 Apr 2017
  • The compiler now has the types 53bit NativeInt and 52bit NativeUInt. Keep in mind that there is still no range checking.

Current aliases:

  JSInteger = NativeInt;

  Integer = LongInt;
  Cardinal = LongWord;
  SizeInt = NativeInt;
  SizeUInt = NativeUInt;
  PtrInt = NativeInt;
  PtrUInt = NativeUInt;
  ValSInt = NativeInt;
  ValUInt = NativeUInt;
  ValReal = Double;
  Real = Double;
  Extended = Double;

  Int64 = NativeInt unimplemented;
  QWord = NativeUInt unimplemented;
  Single = Double unimplemented;
  Comp = Int64 unimplemented;

  UnicodeString = String;
  WideString = String;
  WideChar = char;

Version 0.8.8

  • 20 Apr 2017
  • bugfix release.

Version 0.8.7

  • 18 Apr 2017
  • $mod: the current module
  • Self: in a method with nested functions this holds the class or class instance.
  • overloads are now chosen like FPC/Delphi not only by type, but also by precision. This means if there are several compatible overloads, and none fits exactly it will choose the next higher. Formerly it gave an error.
  • cardinal is no longer a base type, but longword is. Same as FPC.

Version 0.8.6

  • 17 Apr 2017
  • bugfix release.

Version 0.8.5

  • 15 Apr 2017
  • bugfix for the analyzer.
  • supports published array properties and published records.
  • array properties for external classes.

Version 0.8.4

  • 14 Apr 2017
  • bugfix release.

Version 0.8.3

  • 4 Apr 2017
  • pas2js now has code navigation in Lazarus

Trunk

Navigation