Sign in Join
Wiki copytemporary

Pas2JS Version Changes: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# Releases
22
33## Next Version
44
55- Fixed precedence multiply and power: *100 * 9 ** 0.5* results in *100 * (9 ** 0.5)*
66- Fixed Delphi style multiline string literals containing apostrophs.
77
88## 3.0.1
99
101027th Feb 2024
1111
1212Changes:
1313
1414- New download server for the precompiled binaries: <https://getpas2js.freepascal.org>
1515- Namespaces (unitnames with dotted prefixes):
1616 - added compiler option **-FN\<X\>**: add *\<x\>* to namespaces. Namespaces with trailing *-* are removed. Delphi calls this flag "unit scope names".
1717 - 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
1818 - This requires updating the -Fu paths in your pas2js.cfg, see [[pas2js.cfg|pas2js.cfg Example]]
1919- Removed submodule "compiler" and instead support "compiler" as copy, symlink or FPCDIR environment variable. See [[pas2js|Fetching pas2js source via git and compile]]
2020- Many external JS classes updated and extended
2121- FPC Wasm code can access the DOM and JS APIs through pas2js code: [[WebAssembly/DOM]]
2222- fixed marking *library export function result* sub elements as used
2323- fixed parsing *var* section after *class var* section
2424- fixed names of properties *MultilineStringsTrimLeft* and *MultilineStringsEOLStyle*
2525- fixed multilinestrings:
2626 - combos like \`abc\`#10
2727 - double backticks become, same as double apostrophs become one in string literals
2828 - apostroph
2929- fixed **anonymous procedure type**
3030- fixed **anonymous record type**
3131- fixed searching **TJSPromise** in global scopes, while context is a dot scope
3232- fixed typecast array literal to *TJSArray*
3333- added releasecreator, tool written in fpc to compile the compiler and tools
3434- Support for datamodules in resources
3535- Tool to import typescript declaration modules as external classes
3636- Split Web unit into units usable in service workers and main browser window.
3737- Many updates on the widgets, support for bulma-styled widgets
3838- JSONRPC client support and tool to generate import based on ExtJS-styled API.
3939- Add Debugcapture to send logging to server
4040- Add testinsight client.
4141
4242### 3.0.1 Incompatibilities
4343
4444### Unitpaths of default packages in pas2js.cfg
4545
4646- The default packages source paths have changed namespaced versions were added.
4747- Remedy: Update the -Fu paths in your pas2js.cfg, see [[pas2js.cfg|pas2js.cfg Example]]
4848
4949## Version 2.2.0
5050
515122th Feb 2022
5252
5353## All changes of version 2.2.0
5454
5555- moved from svn to gitlab
5656- 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-.
5757- Added RTTI *TProcedureFlag* **pfSafeCall** and **pfAsync**
5858- pas2js now creates unique method pointers (**@SomeMethod**), e.g. the following code will now remove the *@OnLoad*:
5959
60-` xhr.addEventListener('load', @OnLoad);`\
61-` xhr.removeEventListener('load', @OnLoad);`
60+```text
61+ xhr.addEventListener('load', @OnLoad);
62+ xhr.removeEventListener('load', @OnLoad);
63+```
6264
6365- Pascal **Library**
6466 - export for global functions and static methods
6567 - export for global variables
6668- **{\$linklib}** directive, see [[pas2js modules]]
6769- new -T platform **module**
6870- new -T platform **electron**
6971- mark record fields as used when passing record to a jsvalue parameter
7072- \$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.
7173- fixed delay init specializations after loading impl sections
7274- fixed specialize **try except on**, issue 38795
7375- fixed *float / 0.0* results at compiletime in *infinity* instead of div by zero, issue 38815
7476- fixed *low/high(aString)*
7577- fixed typecast *jsvalue* to *external class* instance not object checking by default, only when object checks are enabled. For example *TJSString(aJSValue).length*.
7678- fixed emulate compile time assign integer constant of different type
7779- fixed **typeinfo** *Module, Attributes, ResultType* and *Params* now have default value **nil**, not *undefined*.
7880- fixed cloning multi dim static array on assign
7981- fixed stack overflow on deep nested binary expressions
8082- fixed releasing com interface fields on destroy
8183- fixed class property getter for array property of static method
8284- fixed find generic proc overload without params, issue 38796
8385- fixed calling constructor of nested external class, issue 38858
8486- fixed await() as aclass, issue 39028
8587- fixed consistent error message on custom js file not found, issue 38978
8688- fixed writing sourceMappingURL only if map file enabled, issue 39210
8789- fixed Setlength(unicodestring) issue 39208
8890- fixed call type helper on type helper read from pcu
8991
9092### 2.2.0 Incompatibilities
9193
9294#### pas2js.cfg
9395
9496- The binary packages' file *pas2js.cfg* now enables *-Jc* (concatenate all js) by default. You can disable this with *-Jc-*.
9597
9698## Version 2.0.6
9799
9810015th Apr 2021
99101
100102- fixed **insert(item,array,pos)** when *array=nil*
101103- fixed published field with anonymous array
102104- fixed -O- and record const, issue 38683
103105- fixed multi add **a + ImplicitFuncCall + b**
104106- (generics) Add comparer version of TDictionary create.
105107- (generics) Fix wrong comparison of objects, adjusted patch by Henrique Werlang (Issue 38748)
106108- (db) Patch from Henrique Werlang to implement TDatasetField
107109- (rtti) Patch from Henrique Werlang to implement getting method parameters info
108110- (db) Fix in TDataSet.DefaultBytesToBlobData, index out of range
109111- (sysutils) TStringBuilder implementation
110112- (arrayutils) Start of array utils
111113- (web) Clipboard support (bug ID 0038726)
112114- (sysutils) Use TBoolStrs for Boolean.ToString helper
113115- (jsondataset) Publish OnRecordResolved, OnLoadFail
114116- (db) Implement TBlobField.DisplayValue
115117- (classes) Add ExtractStrings
116118- (classes) StringStream.ReadString/WritString. Fix TMemoryStream.LoadFromStream.
117119- (classes) Correctly handle CR/LF in GetNextLineBreak in TStrings.
118120- demos: Fix demo to work again with latest webwidget
119121- demos: Fixed demorouter example
120122- (packages) new flatpickr lib
121123- (sysutils) provide suitable defaults for Long- and ShortTimeFormat
122124- (web) Patch from Henrique Werlang to implement TJSCSSStyleDeclaration
123125- (web) Patch from Henrique Werlang to implement TJSElement.Remove
124126- (classes) correctly stream TStrings based properties
125127- (db) Patch from Henrique Werlang to let TDatalink transmit events ony when active
126128- (sysutils) Introduce FormatSettings
127129
128130## Version 2.0.4
129131
13013226th Mar 2021
131133
132134- fixed wrong setting *rtl.TObjectDestroy*
133135- fixed no hint when published method hides ancestor method
134136- fixed compileserver option **--simpleserver=** and **-d** relative path
135137- fixed stack overflow on long string concatenations
136138- fixed filer restore global shortrefs
137139
138140## Version 2.0.2
139141
1401429th Mar 2021
141143
142144- fixed freeing temporary class interface, if it is nil.
143145- removed obsolete *TTypeInfoDynArray.DimCount*
144146- fixed *TTypeInfoStaticArray.Dims*
145147- fixed *obj as COMIntfType*, when *obj* is ''nil': for FPC and Delphi compatibility nil returns nil and does not raise an exception.
146148- fixed checking statement after *except-on*
147149- fixed **if then asm a;b end**
148150- fixed **ord(integer)**
149151- fixed **Include(SetOfIntegerRange, integer)**
150152- fixed omitting hint for not used property
151153- fixed **var a: (b,c);**
152154- fixed calling **Instance.StaticMethod** not using Instance
153155- fixed fixed creating enum shortrefs for precompiled code for optimization *EnumValues*
154156
155157## Version 2.0.0
156158
15715911th Jan 2021
158160
159161[[Pas2JS Version Changes|All changes of version 2.0.0]]
160162
161163- fixed *TDictionary* with procedural type
162164- fixed *TTypeInfoRecord.RecordType*
163165
164166## Version 2.0.0RC8
165167
16616831th Dec 2020
167169
168170- fixed UTF-16 char literal *\#128..#255*
169171- fixed using invalid UTF-16 but valid string *\#\$DC00'b'*
170172- fixed checking class method modifiers match class interface (as in IUnknown)
171173- fixed typecast specialized array to specialized type
172174- fixed implicit call of specialized method
173175- 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.
174176- The param in **await(param)** must now be an async function, to avoid accidentally calling the wrong function or not a function at all.
175177- Allowing **await(T,jsvalue)**, because jsvalue could be a promise.
176178- fixed typecast implicit function call passing to arg, e.g. *aFunc(aType(obj.bFunc))*
177179- fixed delayed init specialized class interface
178180
179181## Version 2.0.0RC7
180182
18118313th Dec 2020
182184
183185- fixed optimization *shortrefglobals* and *enum value*
184186- fixed filer storing unix line ending and writing precompiled code with platform line ending
185187- fixed unit without implementatiom
186188- fixed record member type
187189
188190## Version 2.0.0RC6
189191
1901928th Dec 2020
191193
192194- the binary snapshot now use same directories as "make all". E.g. **bin\i386-win32** for the Windows 32bit executables.
193195- the binary snapshot now contains the **makestub** utility
194196- fixed filer, call type helper of unit, which unit implementation has not been parsed.
195197- fixed catching load file exceptions and turn into regular errors
196198- fixed generating typeinfo for classes with published members, but not referenced via typeinfo
197199
198200## Version 2.0.0RC5
199201
2002024th Dec 2020
201203
202204- fixed skipping non fully specialized types
203205- fixed filer, storing reference to *await* and *debugger*
204206- fixed filer, specialize signature of implementation of methods
205207- fixed filer, skipping generic reference to generic type
206208- fixed filer, reading inline specialize expression
207209- fixed filer, checking signatures needing indirect units of implementation
208210
209211## Version 2.0.0RC4
210212
21121330th Nov 2020
212214
213215- fixed **await** on **as** operator
214216- fixed **await(ProcArgument)**
215217- fixed hint *Await needs a promise*
216218- fixed calling **async function** with result type *COM interface*
217219- fixed checking *'await(T,callasyncfunc)* type match
218220- fixed **async** procedure modifier not needed in implementation of a procedure
219221- added *FormData* js keyword
220222- fixed *shortrefglobals* optimization of new/free instance fields
221223- fixed crash on parser error in inline specialize expression, issue 38111
222224- fixed typeinfo path of inline specialize type
223225- fixed **-OoShortRefGlobals**
224226- fixed error when using generic type without parameters
225227- fixed shortrefglobals when unit initialization uses unit of otherwise empty implementation section
226228
227229## Version 2.0.0RC3
228230
22923113th Nov 2020
230232
231233- fixed **typeinfo unicodestring** and **widechar**
232234- fixed passing *widechar* to *var argument char* and *unicodestring* to *string* and vice versus.
233235- rtl: system.pas: removed obsolete *UnicodeString=string* and *WideChar=char* type alias. They are normal compiler types.
234236- fixed typecast integer to **widechar**
235237- fixed **ord(widechar)**
236238- added overload *TryStrToInt64* with *int64*, *TryStrToQWord* with *QWord*, *TryStrToUInt64* with *UInt64*
237239
238240## Version 2.0.0RC2
239241
24024211th Nov 2020
241243
242244- fixed *shortrefglobals* for minimal class interface, issue 38042
243245- fixed disable optimization using fpc syntax e.g. **-OoNoShortRefGlobals**, issue 3804
244246- fixed *shortrefglobals* for procedure without args, issue 38043
245247- **-JRnone** now skips resource directives
246248
247249## Version 2.0.0RC1
248250
2492515th Nov 2020
250252
251253## All changes of version 2.0.0
252254
253255- the binary snapshots now use same directories as "make all". E.g. bin\i386-win32 for the Windows 32bit executables.
254256- [[pas2js Generics|Generics]]
255257- **Attributes**:
256258 - **Incompatibility**: **\$modeswitch ignoreattributes** was removed
257259 - base class *System.TCustomAttribute*
258260 - **\$modeswitch prefixedattributes**: enabled by default in *\$mode Delphi*
259261 - declare in front of any type, type member
260262 - the Delphi compiler attributes like *ref, weak, volatile*, etc are not supported.
261263 - query attributes of a type:
262264 - use either typinfo function **GetRTTIAttributes(typeinfo(SomeType).Attributes)**:
263265 - or use RTTI unit *r:=TRTTIContext*, *r.GetType(typeinfo(SomeType)).GetAttributes*
264266- **class constructors**:
265267 - for classes, records, class helpers, record helpers and type helpers.
266268 - Called in initialization section
267269 - Optimizer removes attributes if type is not used.
268270- **VarArg.Free**, e.g. *procedure DoIt(var Arg: TObject); begin Arg.Free end;* setting Arg to nil
269271- range checking for type helpers
270272- range checking for var/out arguments
271273- fixed **low/high(nativeint)** for 53 significand bits instead of only 52 explicit bits, increasing high to *\$1fffffffffffff = 9007199254740991*
272274- float literal: removing unneeded 0 in front of E e.g. 1.20E1 as 1.2E1
273275- **Overflow checks for integers** -Co *{\$overflowchecks on}* *{\$Q+}* for integer operators +, -, *. Checks if result is outside nativeint and raises EIntOverflow.
274276- **class abstract** modifier
275277- *type helper for classtype*, same as FPC
276278- *type helper for interfacetype*, no constructors, same as FPC
277279- Dispatch messages:
278280 - method modifier **message integer** and **message string**
279281 - directive **{\$DispatchField fieldname}** and **{\$DispatchStrField fieldname}**
280282
281283Insert 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.
282284
283285``` pascal
284286 TMyComponent = class
285287 {$DispatchField Msg}
286288 procedure Dispatch(var aMessage); virtual;
287289 {$DispatchStrField MsgStr}
288290 procedure DispatchStr(var aMessage); virtual;
289291 end;
290292 TMouseDownMsg = record
291293 Id: integer; // Id instead of Msg, works in FPC, but not in pas2js
292294 x,y: integer;
293295 end;
294296 TMouseUpMsg = record
295297 MsgStr: string;
296298 X,Y: integer;
297299 end;
298300 TWinControl = class
299301 procedure MouseDownMsg(var Msg: TMouseDownMsg); message 3; // warning: Dispatch requires record field Msg
300302 procedure MouseUpMsg(var Msg: TMouseUpMsg); message 'up'; // ok, record with string field name MsgStr
301303 end;
302304```
303305
304306- added rtti utility functions GetInterfaceProp, SetInterfaceProp, GetMethodProp, SetMethodProp
305307- TStream with TBytes
306308 - TBytesStream
307309- convert ord(const) to a const
308310- **Resource strings**:
309311 - Resource strings can now be written to file. This is controlled by the -Jr option, see the main wiki page for [[pas2js]].
310312- **TJSFunction(@obj.methodname)** is now converted to *classtype.methodname*
311313- Constructors of external classes are now supported in four ways:
312314 - *constructor New* is translated to *new ExtClass(params)*. Note the missing JS path.
313315 - *constructor New; external name 'GlobalFunc'* is translated to *new GlobalFunc()*. Note the missing JS path.
314316 - *constructor SomeName; external name '{}'* is translated to *{}* - a basic, empty JS object
315317 - Otherwise it is translated to *new ExtClass.FuncName(params)*
316318- You can now specify a type for the procedure modifier *varargs*: **varargs of *SomeType***. For example
317319
318320``` pascal
319321 procedure SumWords(); varargs of Word;
320322 ...
321323 SumWords(1,2,3); // this works
322324 SumWords(1,98765); // this gives a range check error
323325```
324326
325327- Srcmap for pju files
326328- allowing *using a unit twice*, with different names, e.g. *uses ns.unit1, unit1;* or *uses foo in 'unit1.pas', unit1;*
327329- option **-Sj** to allow/disallow typed const to be writable
328330- option **-im** to show available modeswitches
329331- option **-M\<modeswitch\>** to enable or disable a modeswitch, see option -im
330332- typecasting unrelated classes now gives only a warning "Class types are not related" instead of an error, Reason: FPC/Delphi compatibility
331333- 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.
332334- type helper for **bytebool, wordbool, longbool**
333335- *ArrayOfChar:=String* and pass *string* to *ArrayOfChar*
334336- **safecall** calling convention and rtl catch uncaught [[pas2js exceptions|exceptions]].
335337- [[pas2js AsyncAWait|Async procedure modifier]] and await functions:
336338 - *function await(AsyncFunctionOfResultT): T;* // implicit promise
337339 - *function await(aType; p: TJSPromise): aType;* // explicit promise requires the resolved type
338340 - *function await(aType; v: jsvalue): aType;* // explicit optional promise requires the resolved type
339341- Descending a Pascal class from a JS Function
340342- The [[pas2js makestub|makestub]] utility converts a Pascal import unit for importing Pascal classes to a unit that is compilable by Delphi
341343- *fcl-json* JSON interface from FPC.
342344- New units for Javascript libraries:
343345 - *libjitsimeet* interface to jitsi video conferencing.
344346 - *libopentok* interface to opentok video conferencing.
345347 - *libkurento* interface to kurento video conferencing.
346348 - *libfullcalendar(4/5)* interface to fullcalendar.io JS library
347349 - *libdatatables* interface to datatables.net JS library
348350 - *pushjs* interface to browser Push Notifications
349351 - *libbootstrap* interface to bootstrap classes.
350352 - *gmaps* interface to google maps interface.
351353- 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.
352354- Optimizations:
353355 - **-O2** : Level 2 optimizations (Level 1 + not debugger friendly)
354356 - **-OoShortRefGlobals\[-\]**: Insert a JS local var for each module, type and static function. Default enabled in *-O2*.
355357
356358### 2.0.0 Incompatibilities
357359
358360#### Signature for event handlers TEventListenerEvent and TJSEvent
359361
360362The signature for event handlers has been corrected. The class TEventListenerEvent is now an alias for TJSEvent
361363
362364
363365That means that the 2 event handler types
364366
365-` TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;`\
366-` TJSRawEventHandler = reference to Procedure(Event: TJSEvent);`
367+``` pascal
368+ TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;
369+ TJSRawEventHandler = reference to Procedure(Event: TJSEvent);
370+```
367371
368372
369373are now equivalent.
370374
371375#### TJSEvent type definition
372376
373377The TJSEvent type definition has been corrected
374378
375379
376380The currentTarget and Target properties of TJSEvent are now of type TJSEventTarget, as they are in the official specs:
377381
378-`  property currentTarget : TJSEventTarget Read FCurrentTarget;`\
379-`  property target : TJSEventTarget Read FTarget;`
382+```text
383+ property currentTarget : TJSEventTarget Read FCurrentTarget;
384+ property target : TJSEventTarget Read FTarget;
385+```
380386
381387
382388For convenience, a targetElement and CurrentTargetElement property have been added which are of type TJSElement:
383389
384-`   property currentTargetElement : TJSElement;`\
385-`   property targetElement : TJSElement;`
390+```text
391+ property currentTargetElement : TJSElement;
392+ property targetElement : TJSElement;
393+```
386394
387395#### modeswitch ignoreattributes was removed
388396
389397The workaround *{\$modeswitch ignoreattributes}* was removed. Attributes are now implemented.
390398
391399## Version 1.4.34
392400
39340128th Oct 2020
394402
395403- fixed passing in mode delphi a proc address to a proc type argument.
396404- fixed searching pju file, when uses-in-file missing
397405- fixed *a div b* for negative results
398406- fixed *aCurrency/bCurrency* for negative results
399407
400408## Version 1.4.32
401409
40241015th Oct 2020
403411
404412- fixed crash on class function
405413- fixed array shrink using *SetLength*
406414- fixed *try except on ExternalClass do ; end;*
407415- fixed dynamic array function **a:=concat(b);** // marking b as referenced
408416- fixed dynamic array function **c:=concat(a,b);**
409417- fixed *\$ancestor* of all root classes is *null* instead of *undefined*
410418- fixed *rtl.spaceLeft* return value
411419
412420## Version 1.4.30
413421
4144228th July 2020
415423
416424- fixed assign record with field of dynamic array
417425- fixed **SysUtils.AnsiSameText** comparing strings with umlauts.
418426
419427## Version 1.4.28
420428
4214293rd Jul 2020
422430
423431- fixed **system.inc()**
424432- fixed namespace search order
425433 - Reason: Delphi/FPC compatibility.
426434 - Old behaviour: search default namespace (aka prepend program namespace), prepend command line namespaces, no namespace (i.e. as written in uses section)
427435 - New behaviour: search no namespace (i.e. as written in uses section), prepend command line namespaces, prepend default namespace (aka program namespace)
428436 - For example program that uses "classes" and units classes.pas and system.classes.pas are in unit search path.
429437- fixed *try exit(value) finally read Result end*
430438
431439## Version 1.4.26
432440
4334416th Jun 2020
434442
435443- fixed RTTI of record/class field with shared anonymous array, e.g. *type t = record a,b:array of byte; end;*
436444
437445## Version 1.4.24
438446
43944711th May 2020
440448
441449- fixed assign array
442450
443451## Version 1.4.22
444452
44545310th May 2020
446454
447455- fixed allowing member with same name as an ancestor member in \$mode delphi
448456- fixed allow **static** directive repetition in method implementation
449457- fixed type helper for **NativeInt** and **NativeUInt**
450458- fixed type helper **Self** in nested procedure
451459- fixed **(i*i).helperfunc**
452460- fixed **SetLength(array,..)** using resize instead of clone, when not shared. Assign marks an array with a hidden property *\$pas2jsrefcnt*.
453461
454462## Version 1.4.20
455463
45646411th April 2020
457465
458466- fixed stack overflow on long procedures
459467- fixed class helper in with-do
460468
461469## Version 1.4.18
462470
46347115th Dec 2019
464472
465473- access modifier **constref**: works as *const*, gives a warning for non records, arrays
466474- omit not used resourcestrings
467475- fixed sourcemap for Firefox
468476
469477## Version 1.4.16
470478
47147915th Oct 2019
472480
473481- fixed helper for type alias type
474482- fixed selecting last declared helper
475483- replaced rtl.setArrayLength with faster non recursive version
476484- fixed external static class method
477485- fixed check for helper class method for external class must be static
478486- fixed marking implicit call in property parameter
479487
480488## Version 1.4.14
481489
48249030th Aug 2019
483491
484492- source map: when using -Jmabsolute -Jmsourceroot=<file://> prepend the absolute source files with *<file://>*. Needed by Firefox.
485493- fixed longword bitwise operations *not, and, or, xor, shl, shr* for numbers *\> \$7fffffff*
486494- fixed creating relative paths without shared based directory, e.g. in source maps *C:\foo\project1.js.map C:\bar\project1.pas*
487495
488496## Version 1.4.12
489497
49049828th Aug 2019
491499
492500- fixed get method reference of Self inside anonymous method without self
493501- fixed typecast nil to class, interface, dynamic array
494502- fixed endless loop on *type TArr = array of TArr*
495503- no warning "function result not set" for fieldless record
496504- fixed check for duplicate unit, when names differ
497505- fixed *ComInterfaceInstance is/as InterfaceType* to use *QueryInterface*
498506- fixed passing dynamic array to open array var parameter
499507
500508## Version 1.4.10
501509
50251010th Jul 2019
503511
504512- added separate error message duplicate published method
505513- fixed allowing reintroduce published method
506514- fixed *high(dynarrayvar with expr)*
507515- fixed *class var a:t; b:t;*
508516- fixed type helper in other unit
509517
510518## Version 1.4.8
511519
51252024th June 2019
513521
514522- fixed var a: somearray = nil
515523- fixed fixed assignment inside anonymous proc inside for-loop
516524- fixed ArcTan definition (bug ID 35655)
517525- setlength(arr) now always clone for FPC/Delphi compatibility. Formerly it merely resized the array.
518526
519527## Version 1.4.6
520528
52152920th Apr 2019
522530
523531- fixed advanced records
524532- fixed linux rtl.js
525533
526534## Version 1.4.4
527535
52853619th Apr 2019
529537
530538- fixed duplicate identifier when redefining a procedure.
531539- fixed escaping string literals in asm blocks
532540
533541## Version 1.4.2
534542
53554311th Apr 2019
536544
537545- fixed optimization of NewInstance function
538546- fixed filer class helper
539547- fixed passing TExt.new as parameter
540548- fixed writing workingdirectory
541549- fixed advanced record constructor
542550- handling environment options **PAS2JS_OPTS**
543551- fixed nodejs *GetEnvironmentVariable* returning empty string for non existing variables
544552
545553## Version 1.4.0
546554
54755524th Mar 2019
548556
549557- fixed supporting older node.js (\<7.0.0) using *Math.pow* instead of newer exponential operator ******.
550558
551559## Version 1.4.0RC7
552560
55356116th Mar 2019
554562
555563- fixed accessing Self in anonymous function
556564- fixed *UntypedArg:=recordvar* and *RecordType(UntypedArg)*
557565- an external method of a helper is treated like an external method of the helped type
558566- updated examples
559567- fixed hint method hides identifier with same signature
560568- fixed hint argument not used, with array argument and only writing an element
561569- fixed hint argument not used, with array argument passed as argument
562570
563571## Version 1.4.0RC6
564572
5655738th Mar 2019
566574
567575- fixed passing *class var* to *var* argument
568576- fixed reading precompiled units by default
569577
570578## Version 1.4.0RC5
571579
5725806th Mar 2019
573581
574582- fixed overload var arg and type alias
575583- added overload TryStrToFloat with type extended
576584- nativeint **shr** int
577585- nativeint **shl** int
578586- no hint when hiding private method
579587- fixed passing multiple -vm parameters
580588- fixed include file search in module directoy
581589- allow typecast external class to unrelated external class in *\$mode delphi*, e.g. TJSEventTarget(aJSWindow). Normally you need *TJSEventTarget(TJSObject(aJSWindow))*.
582590
583591## Version 1.4.0RC4
584592
5855933rd Mar 2019
586594
587595- fixed *{\$warn identifier error}*
588596- fixed **and/or/xor** with *nativeint*
589597- warn on *nativeint shl/shr int* using only 32bit
590598- fixed type helper call as arg
591599- fixed *(f*f).helpercall*
592600- fixed info message *macro name set to "value"*
593601- *make all* now creates a default bin/targetcpu-targetos/pas2js.cfg, so that pas2js.exe works out-of-the box.
594602
595603## Version 1.4.0RC3
596604
59760527th Feb 2019
598606
599607- renamed **\$modeswitch multiplescopehelpers** to **multihelpers**, same as FPC
600608- fixed *TAliasOfEnumType.EnumValue*
601609- fixed emitting hints for not used units
602610- fixed SetBufListSize
603611
604612## Version 1.4.0RC2
605613
60661418th Feb 2019
607615
608616- fixed typecast jsvalue(anobject/interface), not doing getObject,
609617- fixed *obj.Free* set to *nil* if already *nil*
610618- added **unit websvg.pas** providing API to SVG elements
611619- fixed *getdelimitedtext*, quoting was wrong
612620- fixed array-of-const references in precompiled units
613621- Added some missing routines in strutils (containstext, containsstr)
614622
615623## Version 1.4.0RC1
616624
61762516th Feb 2019
618626
619627- Highlights:
620628 - class helpers
621629 - record helpers
622630 - type helpers
623631 - advanced records
624632 - array of const
625633 - added locate to JSONdataset, as well as lookup and support for lookup fields.
626634 - Added Indexes (sorting) to JSONDataset.
627635
628636- Incompatibilities:
629637 - pas2js now searches units first in the folder of the current module as Delphi does.
630638 - JSArguments declaration was changed from an array of jsvalue to TJSFunctionArguments.
631639
632640## All changes of version 1.4.0
633641
634642- Pas2js supports class helpers, record helpers and type helpers since 1.3. The extend is only virtual, the helped type is kept untouched.
635643 - A **class helper** can "extend" Pascal classes and external JS classes.
636644 - A **record helper** can "extend" a record type. In \$mode delphi a record helper can extend other types as well, see *type helper*
637645 - 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.
638646 - Type helpers are available by default in *\$mode delphi* and disabled in *\$mode objfpc*. You can enable them with **{\$modeswitch typehelpers}**.
639647 - 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.
640648 - Nested helpers (e.g. *TDemo.TSub.THelper*) are elevated. Visibility is ignored. Same as FPC/Delphi.
641649 - Helpers cannot be forward defined (e.g. no *THelper = helper;*).
642650 - Helpers must not have fields.
643651 - **Class Var, Const, Type**
644652 - **Visibility** : *strict private .. published*
645653 - **Function, procedure**: In class and record helpers *Self* is the class/record instance. For other types Self is a reference to the passed value.
646654 - **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.
647655 - **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.
648656 - no destructor
649657 - **Property** : getters/setters can refer to members of the helper, its ancestors and the helped class/record.
650658 - **Class property** : getter can be static or non static. Delphi/FPC only allows static.
651659 - **Ancestors** : Helpers can have an ancestor helper, but they do not have a shared root class, especially not *TObject*.
652660 - **no virtual, abstract, override**. Delphi allows them, but 10.3 crashes when calling.
653661 - *inherited* inside a method of a class/record calls helper of ancestor.
654662 - *inherited* inside a helper depends on the \$mode:
655663 - *\$mode objfpc* : *inherited;* and *inherited Name(args);* work the same and searches first in HelperForType, then in ancestor(s).
656664 - *\$mode delphi: inherited;* : skip ancestors and HelperForType, searches first in helper(s) of ancestor of HelperForType.
657665 - *\$mode delphi: inherited name(args);* : same as \$mode objfpc first searches in HelperForType, then Ancestor(s)
658666 - In any case if *inherited;* has no ancestor to call, it is silently ignored, while *inherited Name;* gives an error.
659667 - **RTTI**: *typeinfo(somehelper)* returns a pointer to *TTypeInfoHelper* with *Kind tkHelper*.
660668 - There are some special cases when using a **type helper** function/procedure on a value:
661669 - *function result* : using a temporary variable
662670 - *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.
663671 - *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.
664672 - *with value do ;* : uses a temporary variable. Delphi/FPC do not support it.
665673- built-in function **concat** *(string1,string2,...)*
666674- local types (declared inside functions) are now created in the global scope
667675- added locate to JSONdataset, as well as lookup and support for lookup fields.
668676- Added Indexes (sorting) to JSONDataset.
669677- Added unit fpexprpars.pas, an expression parser unit (needed for dataset filtering...)
670678- 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
671679- **records are now created as *Object*, instead of JS *function***
672680 - records now have hidden (not enumerable) functions *\$new, \$assign, \$clone, \$eq*
673681 - passing records to *var argument* now passes the record directly instead of creating a temporary setter
674682 - **Assigning a record**, e.g. *aRecord:=value*, now copies the values, while keeping the JS object. This makes *pointer of record* Delphi/FPC compatible.
675683- **Advanced records**: enabled in \$mode delphi, disabled im \$mode objfpc, enable with **{\$modeswitch AdvancedRecords}**
676684 - visibility private, strict private, public, default is public
677685 - methods, class methods (must be static like in FPC/Delphi), constructors
678686 - class vars
679687 - const
680688 - property, class property, array property, default array property
681689 - nested types
682690 - RTTI
683691- Records can now have external fields with '\[2\]', '\["a b"\]'
684692- 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:
685693
686694``` pascal
687695type
688696 TClassOfBird = class of TBird;
689697const k = 1;
690698type
691699 TBird = class end;
692700```
693701
694702- **lo(), hi()** in \$mode delphi returning the lo/hi byte, in \$mode objfpc returning the lo/hi byte\|word\|longword.
695703- char range with non ascii literals: 'Б'..'Я'
696704- typecast char to word and other integers
697705- added option -Jmabsolute to store absolute filenames in sourcemaps
698706- **JSArguments declaration was changed** from an array of jsvalue to TJSFunctionArguments.
699707- fixed expr\[\]\[\] with default properties
700708- fixed assigning class vars
701709- pas2js now searches units first in the folder of the current module as Delphi does.
702710- fixed case-of with non ascii literals
703711- implemented **ProcVar:=StaticClassMethod**
704712- implemented **ProcVar:=ClassMethod** inside static class method
705713- class property getter/setter can now be static or non static.
706714- **array of const**:
707715 - Works the same: vtInteger, vtBoolean, vtPointer, vtObject, vtClass, vtWideChar, vtInterface, vtUnicodeString
708716 - longword is converted to vtNativeInt instead of mangling to vtInteger
709717 - vtExtended is double, Delphi/FPC: PExtended
710718 - vtCurrency is currency, Delphi/FPC: PCurrency
711719 - Not supported: vtChar, vtString, vtPChar, vtPWideChar, vtAnsiString, vtVariant, vtWideString, vtInt64, vtQWord
712720 - only in pas2js: vtNativeInt, vtJSValue
713721- fixed *o.ProcVar()* when ProcVar is typeless property
714722- fixed const evaluation float - currency
715723- fixed reading \#\$00xx as widechar, bug 34923
716724- fixed relative paths in srcmap in Windows
717725- nicer error message on invalid set element type
718726
719727## Version 1.2.0
720728
721729- 23th Dec 2018
722730- SVN release tag is <https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_2_0>
723731- added **dataabstract**: support for Remobjects Data Abstract: The TDAConnection and TDADataset classes
724732- set rtl.js version to 10200
725733- fixed parsing comment in \$IFDEF, \$IFNDEF, issue 34711
726734- fixed searching unit
727735
728736## Version 1.2.0RC1
729737
730738- 16th Dec 2018
731739- SVN release tag is <https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_2_0RC1>
732740- **Anonymous Functions**:
733741
734742``` pascal
735743type
736744 TRefProc = reference to procedure;
737745 TProc = procedure;
738746procedure DoIt(arg: TRefProc);
739747var
740748 ref: TRefProc;
741749 proc: TProc;
742750begin
743751 ref:=procedure begin end; // assign to "reference of procedure" type
744752 ref:=procedure // note the omitted semicolon
745753 var i: integer; // var, types, const, local procedures
746754 begin
747755 end;
748756 DoIt(procedure begin end); // pass as argument
749757 refproc:=procedure assembler asm // embed JavaScript
750758 console.log("foo");
751759 end;
752760 // Note that typecasting to non "reference to" does not make a difference
753761 // because in JS all functions are closures:
754762 proc:=TProc(procedure begin end);
755763end;
756764```
757765
758766- added variable rtl.version, which corresponds to the compiler version Major*10000+Minor*100+Release
759767- added option **-JoCheckVersion**:
760768 - -JoCheckVersion- : do not add rtl version check, default.
761769 - -JoCheckVersion=main : insert rtl.checkVersion() into main.
762770 - -JoCheckVersion=system : insert rtl.checkVersion() into system unit.
763771 - -JoCheckVersion=unit : insert rtl.checkVersion() into every unit.
764772- moved classtopas function to a class2pas unit, improved the interface so it uses a stringlist. Adapted the demo.
765773- Fix System.Int() so it also works on IE (where Math.trunc is missing).
766774- allow typecasting *string(apointer)* and *pointer(astring)*
767775- 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.
768776- Fix FormatFloat() rounding logic (actually FloatToDecimal)
769777- Fix stringofchar for count\<=0
770778- Fix quotestring and add quotedstr
771779- implemented special includes like **{\$i %date%}:**
772780 - %date%: current date as string literal, '\[yyyy/mm/dd\]'
773781 - %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.
774782 - %line%: current source line number as string literal, e.g. '123'
775783 - %linenum%: current source line number as integer, e.g. *123*
776784 - %currentroutine%: name of current routine as string literal
777785 - %pas2jstarget%, %pas2jstargetos%, %fpctarget%, %fpctargetos%: target os as string literal, e.g. 'Browser'
778786 - %pas2jstargetcpu%, %fpctargetcpu%: target cpu as string literal, e.g. 'ECMAScript5'
779787 - %pas2jsversion%, %fpcversion%: compiler version as string literal, e.g. '1.0.2'
780788 - 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.
781789- implemented *pred(char)*, *succ(char)*
782790- allow typecasting *TypedPointer(UntypedPointer)*
783791- allow assign *UntypedPointer:=TypedPointer*
784792- skip double quotes in asm-blocks, e.g. *s = "end"+"'";*
785793- 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.
786794- 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 [[pas2js minifier|minifier]].
787795- 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.
788796- Changed operator precedence level of **is** to same as **and**, **or**, **xor**. Same as fpc/delphi.
789797- fixed assert to raise on false, bug 34643
790798- built-in *procedure **val**(const string; out enum; out int)*
791799- added option *-JoRTL-\<x\>=\<y\>* to change the name of a autogenerated identifier. See the list of available identifiers with *-iJ*.
792800
793801## Version 1.0.4
794802
795803- 14th Nov 2018
796804- SVN release tag is <https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_4>
797805- fixed calling *destructor* after exception in *constructor*
798806- fixed initializing static array of record
799807- fixed parsing *if expr then raise else*
800808- fixed local record and enum types
801809- fixed *for e in set do*
802810- fixed for-in of shared sets
803811- fixed *inc(classvar)*
804812- fixed assigning *class var* of descendant classes
805813- fixed error position on include file not found
806814- fixed loading include file from cache
807815- fixed range check of *o.aString\[index\]* and *o.aArray\[index\]*
808816- fixed Result:=inherited;
809817- fixed escaping invalid UTF-16 in string literals
810818- fixed not generating octal literals in ECMAScript5, it bites strict mode
811819- fixed IsNaN on ECMAScript6
812820- fixed error on method in record
813821- fixed name clash published property and external
814822- fixed *str(aCurrency)*
815823- catch *ECompilerTerminate* while parsing params
816824- *sLineBreak* and *LineEnding* are now **var** under platform NodeJS
817825
818826## Version 1.0.3
819827
820828- 28th Oct 2018
821829- SVN release tag is <https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_3>
822830- fixed *char(#10)*
823831- fixed: allow array property accessor argument mismatch const/default for simple types, e.g.:
824832
825-`function GetItems(const i: integer): byte;`\
826-`property Items[i: integer]: byte read GetItems;`
833+``` pascal
834+function GetItems(const i: integer): byte;
835+property Items[i: integer]: byte read GetItems;
836+```
827837
828838- fixed *high(intvar)*
829839- fixed WPO when using record constants
830840- fixed *include(FuncResultSet,enum)*
831841- fixed *if then \<empty\> else \<something\>;*
832842- fixed *p^.x:=*
833843- fixed *acurrency:=aninteger* to become *acurrency:=aninteger*10000*
834844- fixed *integer(acurrency)* to become *Math.floor(acurrency/10000)*
835845- fixed calling *\$final*, clearing references on destroy
836846- fixed not calling *BeforeDestruction* on exception in constructor
837847- fixed *\$class* be a property of the class, not the object
838848- fixed local var modifier *absolute* in method
839849- fixed using external const in const expression, e.g. *const tau = 2*pi;*
840850- fixed selecting procedure overload, preferring lossy int over int to float
841851- fixed calling Free inside method
842852- fixed System.Int() so it also works on IE (where Math.trunc is missing).
843853- fixed FormatFloat() rounding logic (actually FloatToDecimal)
844854- fixed stringofchar for count\<=0
845855- fixed quotestring and add quotedstr
846856
847857## Version 1.0.2
848858
849859- 26 Sep 2018
850860- SVN release tag is <https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_2>
851861- fixed multiple class interface maps
852862
853863## Version 1.0.1
854864
855865- 19 Sep 2018
856866- SVN release tag is <https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_1>
857867- fixed generating srcmap for precompiled javascript
858868
859869## Version 1.0.0
860870
861871- 9 Aug 2018
862872- SVN release tag is <https://svn.freepascal.org/svn/projects/pas2js/tags/release_1_0_0>
863873- SVN fixes branch is <https://svn.freepascal.org/svn/projects/pas2js/branches/fixes_1_0>
864874- fixed override method of class interface
865875- fixed crash on checking body element of empty proc
866876- use default source filename in pcu/pju files
867877
868878## Version 1.0.0rc1
869879
870880- 24 Jul 2018
871881- fixed *TObject.Create()*
872882- -vd shows stacktraces
873883
874884## Version 0.9.32
875885
876886- 17 Jul 2018
877887- fixed memory leaks and double frees
878888
879889## Version 0.9.31
880890
881891- 10 Jul 2018
882892- fixed aIntSet:=\[0\]
883893- fixed crash on **List.Items.Dummy**
884894- fixed some mem leaks
885895- fixed -MDelphi + \$mode objfpc + overloads withouts overload keyword
886896- **TGUIDString** is now **type string**
887897- RTL: added websockets
888898
889899## Version 0.9.30
890900
891901- 4 Jul 2018
892902- fixed calling COM interface _Release function for expressions.
893903- fixed catching exception in pju variant of pas2js
894904- 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.
895905- fixed property RTTI for alias type in other unit
896906- fixed default value of integer variables, using 0 even if it is outside range. Reason: Delphi/FPC compatibility.
897907
898908## Version 0.9.29
899909
900910- 29 Jun 2018
901911- fixed pcu reading alias type
902912- fixed analyzer: element needing typeinfo marks indirect elements as used normally
903913- hint for text after final "end.", disable with \$warn GARBAGE off
904914- \$warn BOUNDS_ERROR off: disable range check warnings at compile time
905915- \$warn MESSAGE_DIRECTIVE off: disable \$message notes
906916
907917## Version 0.9.28
908918
909919- 27 Jun 2018
910920- fixed static array of char = stringlit+stringlit
911921- fixed libpas2js disk full error
912922- \$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.
913923 - CONSTRUCTING_ABSTRACT: Constructing an instance of a class with abstract methods.
914924 - IMPLICIT_VARIANTS: Implicit use of the variants unit.
915925 - NO_RETVAL: Function result is not set
916926 - SYMBOL_DEPRECATED: Deprecated symbol
917927 - SYMBOL_EXPERIMENTAL: Experimental symbol
918928 - SYMBOL_LIBRARY
919929 - SYMBOL_PLATFORM: Platform-dependent symbol
920930 - SYMBOL_UNIMPLEMENTED: Unimplemented symbol
921931 - HIDDEN_VIRTUAL: method hides virtual method of ancestor
922932
923933## Version 0.9.27
924934
925935- 26 Jun 2018
926936- mode delphi: fixed passing static array to open array
927937- allow assigning aTypeInfo:=pointer, needed by units with and without using unit typinfo
928938
929939## Version 0.9.26
930940
931941- 25 Jun 2018
932942- **typecast function address to JS function**, e.g. TJSFunction(@IntToStr)
933943- **typecast function reference to JS function**, e.g. TJSFunction(OnClick)
934944- **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.
935945- 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.
936946- 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.
937947- Assignation using constant array. For instance **Arr:=\[1,2,3\]**, where Arr is a dynamic array.
938948- **+ operator for arrays**: This concatenation operator is available using the new **modeswitch arrayoperators**, which is enabled by default in mode delphi.
939949- unit webgl updated
940950- unit webaudio added
941951- unit webbluetooth added
942952- db unit: ftDataset field type added (not supported)
943953- JSONDataset unit: TField.OldValue now works for TJSONDataset
944954- **webidl2pas** tool added. A command line tool to create Pascal units from idl specs.
945955- allow **external record fields**.
946956- hint 5024 'Parameter "%s" not used' was split into two:
947957 - 4501 for virtual/override methods
948958 - 5024 for others
949959
950960## Version 0.9.25
951961
952962- 7 Jun 2018
953963- **TComponent now supports IInterface**
954964- **-o** is now always **relative to working directory**, even if -FU or -FE is given. Reason: FPC compatibility
955965- fixed typeinfo(typeintegerrange)
956966- fixed using interface ancestor methods
957967- fixed 'make' building with fpc 3.0.4
958968
959969## Version 0.9.24
960970
961971- 2 Jun 2018
962972- fixed precompiled js formatting to same options as compiled js
963973- fixed unit analyzer private method used by protected property
964974- fixed class-of RTTI
965975- fixed precompiled resolve pending scopes before pending units
966976
967977## Version 0.9.23
968978
969979- 28 May 2018
970980- added webgl demos from Ryan Joseph
971981- **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.
972982- allow **typecast array to TJSObject**
973983- allow **typecast TJSObject to array**
974984- Unicode **character constants outside of BMP**, e.g. \#\$10437
975985- allow **{\$H+}**, error on {\$H-}
976986- 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.
977987- added option **-Sm** to enable macro replacements
978988
979989## Version 0.9.22
980990
981991- 17 May 2018
982992- Fixed *\$00ff00*
983993
984994## Version 0.9.21
985995
986996- 16 May 2018
987997- 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.
988998- fixed WPO typeinfo of inherited property
989999- for easier FPC integration the following message IDs were changed:
9901000 - nVirtualMethodXHasLowerVisibility = 3250; // was 3050
9911001 - nConstructingClassXWithAbstractMethodY = 4046; // was 3080
9921002 - nNoMatchingImplForIntfMethodXFound = 5042; // was 3088
9931003 - nSymbolXIsDeprecated = 5043; // was 3062
9941004 - nSymbolXBelongsToALibrary = 5065; // was 3061
9951005 - nSymbolXIsDeprecatedY = 5066; // 3063
9961006 - nSymbolXIsNotPortable = 5076; // was 3058
9971007 - nSymbolXIsNotImplemented = 5078; // was 3060
9981008 - nSymbolXIsExperimental = 5079; // was 3059
9991009
10001010## Version 0.9.20
10011011
10021012- 11 May 2018
10031013- fixed passing typecasted alias type to var parameter
10041014- forbid typecast rectordtype to other recordtype
10051015- remove leading zeroes in number literals
10061016- added **namespace option -FN\<x\>**, **marked -NS as obsolete**. Reason: fpc compatibility.
10071017- added option **-vz** : write messages to stderr, -o. still uses stdout.
10081018- added option **-ic** : Write list of supported JS processors usable by -P\<x\>
10091019- added option **-io** : Write list of supported optimizations usable by -Oo\<x\>
10101020- added option **-it** : Write list of supported targets usable by -T\<x\>
10111021- added option **-SIcom**, **-SIcorba** interface style
10121022- added option **-vv** : Write pas2jsdebug.log with lots of debugging info
10131023- fixed option -va including option -vt
10141024- fixed combination of -Jc -o.
10151025- option -vt now writes used unit scopes
10161026- **external class fields with brackets**. e.g. *X: nativeint external name '\[0\]'*
10171027- autogenerated interface GUIDs now consider the unitname
10181028
10191029## Version 0.9.19
10201030
10211031- 2 May 2018
10221032- **type alias type**, e.g. *type TCaption = type string;*
10231033- **record const**, e.g. *const p: TPoint = (x:1; y:2);*
10241034- **{\$WriteableConst on\|off}**: treat typed constants as readonly, e.g. *const i:byte=3;... i:=4;* creates a compile time error.
10251035- forbid assignment of for-loop variable
10261036- **nested classes**
10271037- **property specifier nodefault**
10281038- **default(type)** returning the initial value of the type, e.g. default(recordtype).
10291039- **external typed const**: e.g. *const NaN: Double; external name 'NaN';*
10301040- **case string of** support for ranges
10311041- fixed typecast shortint(integer)
10321042
10331043## Version 0.9.18
10341044
10351045- 26 Apr 2018
10361046- Fixed rcArrR in rtl.js
10371047
10381048## Version 0.9.17
10391049
10401050- 25 Apr 2018
10411051- Fix recno calculation for TJSONDataset
10421052- Fix initializing next buffers in TDataset.
10431053- Implemented **Currency** as double, values are multiplied by 10000 and truncated, so a 2.7 is stored as 27000.
10441054- Implemented **pointer of record**. It's simply a reference.
10451055 - *p:=@r* translates to *p=r*
10461056 - *p^.x* becomes *p.x*
10471057 - intrinsics new(PointerOfRecord), dispose(PointerOfRecord). dispose(p) sets p to null if possible.
10481058- **enumerator for jsvalue**: e.g. *var v: jsvalue; key: string; **for key in jsvalue do*** translates to *for (key in jsvalue){}*
10491059- **enumerator for external class**: e.g. *var o: TJSObject; key: string; for key in o do* translates to *for (key in o){}*
10501060- **range checking \$R+**
10511061 - compile time: warnings become errors
10521062 - run time: int:=, int+=, enum:=, enum+=, intrange:=, intrange+=, enumrange:=, enumrange+=, char:=, charrange:=
10531063 - run time: parameters: int, enum, intrange, enumrange, char, charrange
10541064 - run time: array\[index\], string\[index\]
10551065- **type cast integer to integer**, e.g. *byte(aLongInt)*
10561066 - with range checking enabled: error if outside range
10571067 - without range checking: emulates the FPC/Delphi behaviour: e.g. *byte(value)* translates to *value & 0xff*, *shortint(value)* translates to *value & 0xff \<\<24 \>\>24*.
10581068- case-of statement: error on duplicate values
10591069- fixed error on int:=double
10601070
10611071## Version 0.9.16
10621072
10631073- 21 Apr 2018
10641074- mode delphi: allow "ObjVar is IntfType" and "ObjVar as IntfType" with unrelated types.
10651075- TVirtualInterface - create an implementation at runtime. rtl unit rtti.pas
10661076- typecast a class type to JS Object, e.g. TJSObject(TObject)
10671077- typecast an interface type to JS Object, e.g. TJSObject(IUnknown)
10681078- typecast a record type to JS Object, e.g. TJSObject(TPoint)
10691079- not jsvalue is converted to !jsvalue
10701080- "=" operator for records with static array fields
10711081- changed TGuid to record
10721082- TGUID record
10731083 - GuidVar:='{guid}', StringVar:=GuidVar, GuidVar:=IntfTypeOrVar, GuidVar=IntfTypeOrVar, GuidVar=string
10741084 - pass IntfTypeOrVar to GuidVar parameter
10751085- added new type TGuidString to system unit
10761086 - GuidString:=IntfTypeOrVar, GuidString=IntfTypeOrVar
10771087 - pass IntfTypeOrVar to GuidString parameter
10781088- added option -JoUseStrict, to enable or disable adding "use strict"
10791089
10801090## Version 0.9.15
10811091
10821092- 8 Apr 2018
10831093- fixed crash when ancestor implements more interfaces than current class.
10841094
10851095## Version 0.9.14
10861096
10871097- 8 Apr 2018
10881098- fixed duplicates in rtl/strutils.pas
10891099- fixed reference counts on reading element lists
10901100- implemented using function result variable in for-loop. e.g. for Result:=..., for Result in ...
10911101- fixed for string in arrayofstring do
10921102- fixed \$scopedenums with anonymous enumtype. e.g. type TSet = set of (A,B);
10931103- implemented class interfaces:
10941104 - methods, properties, default property
10951105 - {\$interfaces com\|corba\|default}
10961106 - 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
10971107 - CORBA: lightweight, no automatic reference counting, no default ancestor, fast support checks.
10981108 - inheriting
10991109 - GUIDs are simple string literals, TGUID = string.
11001110 - An interface without a GUID gets one autogenerated from its name and method names.
11011111 - a class implementing an interface must not be external
11021112 - 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.
11031113 - method resolution, procedure IUnknown._AddRef = IncRef;
11041114 - delegation: property Name: interface\|class read Field\|Getter implements AnInterface;
11051115 - is-operator:
11061116 - IntfVar is IntfType - types must be releated
11071117 - IntfVar is ClassType - types can be unrelated, class must not be external
11081118 - ObjVar is IntfType - can be unrelated
11091119 - as-operator
11101120 - IntfVar as IntfType - types must be releated
11111121 - IntfVar as ClassType - types can be unrelated, nil returns nil, invalid raises EInvalidCast
11121122 - ObjVar as IntfType - mode delphi: types must be related, objfpc: can be unrelated, nil if not found, COM: uses _AddRef
11131123 - typecast:
11141124 - IntfType(IntfVar) - must be related
11151125 - ClassType(IntfVar) - can be unrelated, nil if invalid
11161126 - IntfType(ObjVar) - mode delphi: must be related, objfpc: can be unrelated, nil if not found, COM: if ObjVar has delegate uses _AddRef
11171127 - TJSObject(intfvar)
11181128 - Assign operator:
11191129 - IntfVar:=nil
11201130 - IntfVar:=IntfVar2 - IntfVar2 must be same type or a descendant
11211131 - IntfVar:=ObjVar - nil if unsupported
11221132 - jsvalue:=IntfVar
11231133 - Assigned(IntfVar)
11241134 - RTTI
11251135 - \$modeswitch ignoreinterfaces was removed
11261136 - Not supported: array of interface, interface as record member
11271137
11281138## Version 0.9.13
11291139
11301140- 21 Mar 2018
11311141- fixed keeping methods AfterConstruction, BeforeDestruction
11321142- fixed modeswitch ignoreinterfaces
11331143
11341144## Version 0.9.12
11351145
11361146- 19 Mar 2018
11371147- fixed parsing procedure p(var a; b: t)
11381148- fixed checking duplicate implementation of unit interface procedure
11391149
11401150## Version 0.9.11
11411151
11421152- 16 Mar 2018
11431153- fixed loading files encoded in non UTF-8, e.g. UTF-8 with BOM. This was a regression.
11441154
11451155## Version 0.9.10
11461156
11471157- 13 Mar 2018
11481158- fixed renaming overloads of unit interface at end of interface, not at end of module. Needed for unit cycles.
11491159
11501160## Version 0.9.9
11511161
11521162- 13 Mar 2018
11531163- Fixed libpas2js to use WorkingDir parameter instead of GetCurrentDir
11541164- Fixed static array clone function.
11551165
11561166## Version 0.9.8
11571167
11581168- 9 Mar 2018
11591169- fixed optimizer keep overrides
11601170
11611171## Version 0.9.7
11621172
11631173- 7 Mar 2018
11641174- fixed pass local variable *v* as argument to a var parameter.
11651175
11661176## Version 0.9.6
11671177
11681178- 6 Mar 2018
11691179- static arrays are now cloned on assignment or when passed as argument to a function (no const, var, out)
11701180- Fixed array\[enum..enum\] of
11711181- pas2jslib: fixed checks of directoryexists to use cache
11721182- 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'.
11731183
11741184## Version 0.9.5
11751185
11761186- 12 Feb 2018
11771187- Error on duplicate forward class
11781188- Error on method class in other unit
11791189- Fixed index property override
11801190
11811191## Version 0.9.4
11821192
11831193- 8 Feb 2018
11841194- Removed debug writeln, fixing Disk Full errors in libpas2js.
11851195- Nicer error messages on illegal qualifier.
11861196
11871197## Version 0.9.3
11881198
11891199- 4 Feb 2018
11901200- Fixed number literals outside int64.
11911201- Shorten float numbers, e.g. 1.00000E+001 to 10
11921202- unexpected exception now sets ExitCode to 1
11931203
11941204## Version 0.9.2
11951205
11961206- 4 Feb 2018
11971207- Fixed -constant, when constant is a negative number
11981208
11991209## Version 0.9.1
12001210
12011211- 3 Feb 2018
12021212- Fixed class const evaluating expression.
12031213
12041214## Version 0.9.0
12051215
12061216- 31 Jan 2018
12071217- Fixed srcmap header. It must be )\]}' to work in Firefox. Added option -JmXSSIHeader to exclude or include the XSSI protection header.
12081218- Ignore procedure modifier "inline"
12091219- Char(int)
12101220- search units and include files case insensitive by default. Enable FPC like search with parameter -JoSearchLikeFPC.
12111221- Const in external classes:
12121222 - *const c: type = value, const c = value* are translated to the value.
12131223 - *const c: type, class const c: type* are treated like readonly variables.
12141224
12151225## Version 0.8.45
12161226
12171227- 23 Jan 2018
12181228- is-operator: jsvalue is class-type, jsvalue is class-of-type
12191229- assertions: -Sa, \$C+\|-, \$Assertions on\|off, Assert(boolean), Assert(boolean,string)
12201230- object checks: -CR, \$ObjectChecks on\|off, check method calls, check object type casts
12211231- some bugfixes for alias types
12221232- multi dimensional static array const, e.g. array\[1..2,3..4\] of byte = ((5,6),(7,8))
12231233- fixed overloads when skipping class interface
12241234- fixed s\[i\]:= when s is a var parameter
12251235
12261236## Version 0.8.44
12271237
12281238- 15 Jan 2018
12291239- State of directives \$Hints\|Notes\|Warnings on\|off at end of procedure is used for analyzer hints, e.g. "local variable x not used".
12301240- Fixed re-reading directories after Reset.
12311241
12321242## Version 0.8.43
12331243
12341244- 4 Jan 2018
12351245- Fixed -Fi include path
12361246- Read directories instead of checking every single file. Added hooks for ReadDir to libpas2js.
12371247
12381248## Version 0.8.42
12391249
12401250- 25 Dec 2017
12411251- var absolute modifier for local variables
12421252- \$scopedenums
12431253- \$hint, \$note, \$warn, \$error, \$fatal, \$message text
12441254- \$message hint\|note\|warn\|error\|fatal text
12451255- \$hints, \$notes, \$warnings on\|off
12461256
12471257## Version 0.8.41
12481258
12491259- 25 Dec 2017
12501260- Enumerators:
12511261 - ordinal types: char, boolean, byte, ..., longword, enums, sets, static array, custom range
12521262 - const set
12531263 - variables: set, string, array
12541264 - class GetEnumerator
12551265 - It does not support operator enumerator, IEnumerator, member modifier enumerator.
12561266
12571267## Version 0.8.40
12581268
12591269- File read callback for pas2jslib
12601270
12611271## Version 0.8.39
12621272
12631273- 14 Dec 2017
12641274- fixed circular unit dependencies
12651275
12661276## Version 0.8.38
12671277
12681278- 12 Dec 2017
12691279- support for * and ? in search paths
12701280- fixed converting a typecast to an alias proc type
12711281- fixed inherited-identifier-as-expr
12721282- emit warning method-hides-method-in-base-type only for virtual methods
12731283- reduced function hides identifier from level hint to info
12741284- fixed unit contnrs to always use mode objfpc.
12751285
12761286## Version 0.8.37
12771287
12781288- 5 Dec 2017
12791289- Bugfixed a combination of overload/override
12801290
12811291## Version 0.8.36
12821292
12831293- 5 Dec 2017
12841294- fixed missing brackets in binary expression and left side has a call (a-f(b)) / (c-d)
12851295
12861296## Version 0.8.35
12871297
12881298- 20 Nov 2017
12891299- fixed a bug in the overload code
12901300
12911301## Version 0.8.34
12921302
12931303- 19 Nov 2017
12941304- fixed skipping attributes behind procedure declarations.
12951305- Procedures/methods now properly hides procs with same name.
12961306- In mode delphi overloads now always require the 'overload' modifier.
12971307- In mode objfpc the modifier is required when using different scopes.
12981308- hints for hiding identifiers of other units.
12991309- implemented system.built-in-identifier.
13001310
13011311## Version 0.8.33
13021312
13031313- 14 Nov 2017
13041314- srcmaps with included sources now ignores untranslatable local paths and simply uses the full local path.
13051315- custom enum ranges, e.g. TBlobType = ftBlob..ftBla
13061316- custom integer ranges, e.g. TSome = 1..5
13071317- custom char ranges
13081318- set of custom enum/integer/char ranges
13091319- 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.
13101320
13111321## Version 0.8.32
13121322
13131323- 8 Nov 2017
13141324- some bug fixes for warnings
13151325
13161326## Version 0.8.31
13171327
13181328- 29 Oct 2017
13191329- bugfix for implicit function calls of parameters of some built in functions.
13201330
13211331## Version 0.8.30
13221332
13231333- 19 Oct 2017
13241334- nicer "can't find unit" position
13251335- fixed a crash parsing uses clause
13261336
13271337## Version 0.8.29
13281338
13291339- 16 Oct 2017
13301340- bugfixes
13311341- it now supports directive \$M alias \$TypeInfo
13321342
13331343## Version 0.8.28
13341344
13351345- fixed passing static array
13361346
13371347## Version 0.8.27
13381348
13391349- 4 Oct 2017
13401350- implemented resourcestrings
13411351- implemented logical xor
13421352- fixed class-of-typealias
13431353- fixed property index modifier expression
13441354
13451355## Version 0.8.26
13461356
13471357- 3 Oct 2017
13481358- fixed RTTI for static arrays
13491359- implemented property modifier index
13501360- implemented FuncName:=
13511361
13521362## Version 0.8.25
13531363
13541364- 1 Oct 2017
13551365- bugfixes
13561366- a new modeswitch ignoreattributes to ignore attributes.
13571367
13581368## Version 0.8.24
13591369
13601370- 28 Sep 2017
13611371- implemented multi dimensional SetLength
13621372- fixed keeping old values when using SetLength
13631373- fixed method override of override
13641374
13651375## Version 0.8.23
13661376
13671377- 27 Sep 2017
13681378- property default value for sets
13691379- custom integer ranges, like TValueRelationship
13701380- typecast enums to integer type (same as ord function)
13711381- new modeswitch ignoreinterfaces to parse class interfaces, but neither resolve nor convert them. Using them will cause an error.
13721382
13731383## Version 0.8.22
13741384
13751385- 24 Sep 2017
13761386- fixed loading dotted units
13771387- implemented property stored and default modifiers
13781388
13791389## Version 0.8.21
13801390
13811391- 21 Sep 2017
13821392- fixed aString\[index\]:=
13831393- fixed analyzer to mark default values of arguments
13841394- many improvements for sourcemaps making step-over/into nicer in Chrome.
13851395- new tool fpc/packages/fcl-js/examples/srcmapdump to dump the produced sourcemap.
13861396- unicodestring and widechar are now declared by the compiler instead of system.pas
13871397
13881398## Version 0.8.20
13891399
13901400- 14 Sep 2017
13911401- Static array const are now implemented. For example:
13921402- array\['a'..'d'\] of integer = (1,2,3,4);
13931403- array\[1..3\] of char = 'pas';
13941404
13951405## Version 0.8.19
13961406
13971407- 12 Sep 2017
13981408- several bug fixes
13991409- started static arrays:
14001410 - array\[2..6\] of char
14011411 - array\['a'..'z'\] of char
14021412 - array\[boolean\] of longint
14031413 - array\[byte\] of string
14041414 - array\[enum\] of longint
14051415 - array\[char\] of boolean // Note that char is widechar!
14061416 - low(), high()
14071417
14081418## Version 0.8.18
14091419
14101420- 6 Sep 2017
14111421- Anonymous arrays in record members are now supported:
14121422
14131423``` pascal
14141424 TFloatRec = Record
14151425 ...
14161426 Digits: Array Of Char;
14171427 End;
14181428```
14191429
14201430## Version 0.8.17
14211431
14221432- 3 Sep 2017
14231433- checks for semicolons between statements
14241434- fixed proc type of procedure in Delphi mode
14251435- implemented @@ operator for proc types in Delphi mode.
14261436- compile time evaluation, range and overflow checking for boolean, base integer types, enums, sets, custom integer ranges, char, widechar, string, single and double.
14271437
14281438## Version 0.8.16
14291439
14301440- 28 Jul 2017
14311441- bugfix release.
14321442
14331443## Version 0.8.15
14341444
14351445- 8 Jul 2017
14361446- compiler can now generate source maps when passing option -Jm
14371447
14381448## Version 0.8.14
14391449
14401450- 17 May 2017
14411451- now supports TObject.Free.
14421452
14431453In 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.
14441454
14451455It 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.
14461456
14471457## Version 0.8.13
14481458
14491459- 11 May 2017
14501460- \$IF
14511461- \$ELSEIF
14521462- \$IFOPT
14531463- \$Error
14541464- \$Warning,
14551465- \$Note
14561466- \$Hint
14571467- And in the config files it supports \#IF, \#IFDEF, \#IFNDEF, \#ELSEIF, \#ELSE, \#ENDIF.
14581468
14591469## Version 0.8.12
14601470
14611471- 5 May 2017
14621472- dotted unit names and namespaces.
14631473
14641474## Version 0.8.11
14651475
14661476- 23 Apr 2017
14671477- dynamic arrays can now be initialized with a constant. Same syntax as static arrays: const a: array of string = ('one', 'two');
14681478- Classes can now be declared in the unit implementation.
14691479- Unit nodejs now has a console class TNJSConsole.
14701480- I added the fpcunit package. Successful tests already work. A fail is not yet caught.
14711481
14721482## Version 0.8.10
14731483
14741484- 22 Apr 2017
14751485- you can now use "if aJSValue then", which works just like the JS "if(v)".
14761486- added ParamCount, ParamStr, GetEnvironment* functions. The default is not doing much.
14771487- new package fcl_base_pas2js, containing custapp and nodejsapp: - TCustomApplication is the known class from the FCL, but with abstract methods.
14781488- TNodeJSApplication is a TCustomApplication using nodejs to read command line params and environment variables.
14791489
14801490## Version 0.8.9
14811491
14821492- 21 Apr 2017
14831493- The compiler now has the types 53bit NativeInt and 52bit NativeUInt. Keep in mind that there is still no range checking.
14841494
14851495Current aliases:
14861496
14871497 JSInteger = NativeInt;
14881498
14891499 Integer = LongInt;
14901500 Cardinal = LongWord;
14911501 SizeInt = NativeInt;
14921502 SizeUInt = NativeUInt;
14931503 PtrInt = NativeInt;
14941504 PtrUInt = NativeUInt;
14951505 ValSInt = NativeInt;
14961506 ValUInt = NativeUInt;
14971507 ValReal = Double;
14981508 Real = Double;
14991509 Extended = Double;
15001510
15011511 Int64 = NativeInt unimplemented;
15021512 QWord = NativeUInt unimplemented;
15031513 Single = Double unimplemented;
15041514 Comp = Int64 unimplemented;
15051515
15061516 UnicodeString = String;
15071517 WideString = String;
15081518 WideChar = char;
15091519
15101520## Version 0.8.8
15111521
15121522- 20 Apr 2017
15131523- bugfix release.
15141524
15151525## Version 0.8.7
15161526
15171527- 18 Apr 2017
15181528- \$mod: the current module
15191529- Self: in a method with nested functions this holds the class or class instance.
15201530- 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.
15211531- cardinal is no longer a base type, but longword is. Same as FPC.
15221532
15231533## Version 0.8.6
15241534
15251535- 17 Apr 2017
15261536- bugfix release.
15271537
15281538## Version 0.8.5
15291539
15301540- 15 Apr 2017
15311541- bugfix for the analyzer.
15321542- supports published array properties and published records.
15331543- array properties for external classes.
15341544
15351545## Version 0.8.4
15361546
15371547- 14 Apr 2017
15381548- bugfix release.
15391549
15401550## Version 0.8.3
15411551
15421552- 4 Apr 2017
15431553- pas2js now has code navigation in Lazarus
15441554
15451555# Trunk
15461556
15471557# Navigation
15481558
15491559- Back to [[pas2js]]
15501560- Back to [[lazarus pas2js integration]]
15511561
15521562---
15531563*From the Free Pascal wiki, page "Pas2JS Version Changes", as it stood on 2024-02-28 after a change by Mattias2, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
15541564Category: Pas2js

Back to history