A new DWScript 2.3 source archive is available (417 kB) for the SVN-averse, the previous available zip was the 2.2 version, which is quite outdated. Given the continuous extension of the unit tests suite, this should hopefully be one of the most stable versions to date, in addition to being the most advanced, but it’s likely less stable and less advanced than the SVN version will be when you’ll read these lines 😉
Language changes:
- overloading object methods is now supported
- support for multi-line quoted strings (double-quote ” delimited)
- support for multi-line indented strings (started with hash double-quote #”)
- added support for “resourcestring” declaration and localization via IdwsLocalizer
- added support for “array [Boolean] of“
- added Sign() and StrBeginsWith() to the standard functions
- RandSeed has been deprecated (but SetRandSeed is still supported)
Library, Demos and Script engine changes:
- partial support for RTTI exposure of static and dynamic arrays (thx Dorin Duminica)
- minimal resolution to allow calling overloaded methods via RTTI (thx Dorin Duminica)
- many error improvements related to abuse and misuse of “@” (thx Alexey Kazantsev)
- optimized “in” evalution when used against small enumerations
- added support for various hinting levels
- added JSON exporter for the SourceContextMap
- fixed Simple DWS server demo (thx Mason Wheeler)
- fixed CallStack when function pointers are in the call stack
- fixes and minor speedups to JSON parsing for for the dwsJSON unit (thx Jon Burnham)
JavaScript CodeGen changes
- fixed occasionally mis-handled “var” parameters
- smart-linker can now eliminate unused virtual methods
- added verbosity option (controls extra comments in the JS output)
- Simple Format() calls can now be optimized to inline string concatenations
- improved initialization of large static arrays
- Random() function is now based on Alea.js and uses Marsaglia’s “Multiply With Carry”
Very nice work, indeed.
Do array[byte] or array[TEnumeration] work also, just like array[boolean]?
Why are you using external .js files for something like Alea.js or stringRepeat.js which may be perhaps more “elegant” if implemented as plain DWS (and also shared with other codegen/execution stack)?
Very cool! One thing I’m curious about is “smart-linker can now eliminate unused virtual methods”. How do you do that? I am not a compiler expert, but I thought this was a hard problem.
@A. Bouchez
array [TEnumeration] already worked, byte isn’t supported, though at some point there will likely be an “array [any type]”.
Pascal-based source is likely to come at some point (but time is a limited quantity).
@David M
It’s a “whole program” optimization: if a virtual method is never used in the whole program (or only used in methods/classes that aren’t used) it can be eliminated.
Would be nice if DWScript could run on apache (as a module?) to be able to use DWScript for server side pages as well in such a way that all hosting companies could install it onto their web servers for cheap web hosting/delphi solutions ! 😉
Even better would be compiling/interpreting straight to php which was probably original goal, but failed ?
Most web hosting companies/apache web servers already have php support, though php a bit dangerous security wise/bug wise, but would still be nice 😉 🙂
You can already do that for Apache on Windows servers, and should be able to do that on Linux ones once FreePascal bugs mentioned at http://wiki.freepascal.org/DelphiWebScript are fixed or a Delphi compiler for Linux comes out.
AFAIK compiling to PHP was never a goal, even the original DWS (DWS1 & DWSII) was really to have the script engine run in a Delphi binary, and the goal of the current JS CodeGen is to run things on the client-side (so no PHP either).