|
|
|
[
Permlink
| « Hide
]
P T Withington - 08/Jan/08 07:10 AM
In JS2 this operator is called `cast`. I propose that we use that term and that the swf9 back-end translate `cast` to `as`.
r7768 | ptw | 2008-01-08 14:41:34 -0500 (Tue, 08 Jan 2008) | 31 lines
Changed paths: M /openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java M /openlaszlo/trunk/test/lztest/lztest-class-impl.lzx Change 20080108-ptw-a by ptw@dueling-banjos.local on 2008-01-08 11:56:44 EST in /Users/ptw/OpenLaszlo/ringding-2 for http://svn.openlaszlo.org/openlaszlo/trunk Summary: add support for `cast` keyword in javascript Bugs Fixed: Technical Reviewer: dda@ddanderson.com (Message-Id: <AC18608E-42E5-4600-A8F0-89FDE03FCA17@ddanderson.com>) QA Reviewer: henry.minsky@gmail.com (pending) Doc Reviewer: lou@louiorio.com (pending) Documentation: We now support the JS2 `cast` operator: <value> cast <type expression>. In JS1 runtimes this is a no-op. In JS2 runtimes it will be passed through and ensures that the value is of the correct static type. Details: lztest-class-impl: Add tests suggested by Don for more complex `is` expressions. Add tests for `cast` expressions JavascriptGenerator, CodeGenerator, Parser, ParseTreePrinter: add support for `cast` as a no-op (just returns the value or lhs). Put back code that deals with null source files for now. Tests: lztest-class-impl To Don, to migrate to DevilDog (and implement the 'cast' -> 'as' translation for swf9 back-end).
Note: this addendum is SWF9 only, and fixed in devildog
Original change r7763 was fixed for RingDing only. ------------------------------------------------------------------------ r7773 | dda | 2008-01-08 16:53:49 -0500 (Tue, 08 Jan 2008) | 46 lines Changed paths: M /openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java M /openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java Change 20080108-dda-X by dda@lester.local on 2008-01-08 16:51:26 EST in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog for http://svn.openlaszlo.org/openlaszlo/branches/devildog Summary: SWF9: Added support for 'cast' and 'is' New Features: Bugs Fixed: Technical Reviewer: ptw (pending) QA Reviewer: hminsky (pending) Doc Reviewer: (pending) Documentation: Release Notes: Details: Building on support in trunk just added for 'cast' and 'is', this change allows these keywords to be passed through and emitted as is to the third party compiler. SWF9Generator.java: intercept JavascriptGenerator implementation of 'cast' and 'is' so they are not handled directly within the compiler, but left alone. SWF9ParseTreePrinter.java: added knowledge of 'cast' and 'is' operators to emit these as is. Tests: 1) Imported a few tests that use cast/is from lztest-class-impl.lzx into a private copy of LzNode.js: var xf1 = ( (new Sundae()) cast Vanilla instanceof Number ); var xt1 = ( (new Number()) cast Object instanceof Number ); var xf2 = ( (new Sundae()) cast Vanilla is Number ); var xt2 = ( (new Number()) cast Object is Number ); (along with modified versions of Sundae and Vanilla). Verified that these compiled and emitted the same in the output files fed to the third party compiler. 2) did smoketest ------------------------------------------------------------------------ ------------------------------------------------------------------------ r7773 | dda | 2008-01-08 16:53:49 -0500 (Tue, 08 Jan 2008) | 46 lines Changed paths: M /openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java M /openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java Change 20080108-dda-X by dda@lester.local on 2008-01-08 16:51:26 EST in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog for http://svn.openlaszlo.org/openlaszlo/branches/devildog Summary: SWF9: Added support for 'cast' and 'is' New Features: Bugs Fixed: Technical Reviewer: ptw (pending) QA Reviewer: hminsky (pending) Doc Reviewer: (pending) Documentation: Release Notes: Details: Building on support in trunk just added for 'cast' and 'is', this change allows these keywords to be passed through and emitted as is to the third party compiler. SWF9Generator.java: intercept JavascriptGenerator implementation of 'cast' and 'is' so they are not handled directly within the compiler, but left alone. SWF9ParseTreePrinter.java: added knowledge of 'cast' and 'is' operators to emit these as is. Tests: 1) Imported a few tests that use cast/is from lztest-class-impl.lzx into a private copy of LzNode.js: var xf1 = ( (new Sundae()) cast Vanilla instanceof Number ); var xt1 = ( (new Number()) cast Object instanceof Number ); var xf2 = ( (new Sundae()) cast Vanilla is Number ); var xt2 = ( (new Number()) cast Object is Number ); (along with modified versions of Sundae and Vanilla). Verified that these compiled and emitted the same in the output files fed to the third party compiler. 2) did smoketest ------------------------------------------------------------------------ (trunk 4 local build r7775)
Ran http://127.0.0.1:8080/trunk/test/lztest/lztest-class-impl.lzx in swf7, swf8 and dhtml and return: INFO: Passed all suites. (trunk 4 local build r7930)
Ran http://127.0.0.1:8080/trunk/test/lztest/lztest-class-impl.lzx in swf7, swf8 and dhtml, returns: INFO: Passed all suites. |
||||||||||||||||||||||||||||||||||||||||||||||||||||