History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-5336
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: P0 P0
Assignee: Unassigned
Reporter: Henry Minsky
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

add support for `cast` keyword in javascript

Created: 07/Jan/08 07:39 PM   Updated: 30/Jan/08 03:35 PM
Component/s: Compiler
Affects Version/s: RingDing (4.1), DevilDog
Fix Version/s: RingDing (4.1), DevilDog

Time Tracking:
Not Specified

Severity: Minor
Fixed in Change#: 7,773
Runtime: N/A
Fix in hand: False


 Description  « Hide
P T Withington to Donald, me, OpenLaszlo



Yes, we should support this. It should just pass through in js2 and
be a no-op in js1.

If you'll file a Jira request, I can do the trunk work and I'll let
Don integrate and do the swf9 back end.

Don if you can review the 'is' change that would help, since I'd like
to make these as separate changes but they obviously involve the same
files. Thanks.


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
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`.

P T Withington - 08/Jan/08 07:11 AM
Updating summary per comment above.

P T Withington - 08/Jan/08 11:42 AM
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:
LPP-5336 'add support for `cast` keyword in javascript'

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


P T Withington - 08/Jan/08 11:43 AM
To Don, to migrate to DevilDog (and implement the 'cast' -> 'as' translation for swf9 back-end).

Donald Anderson - 08/Jan/08 01:56 PM
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: LPP-5336

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: LPP-5336

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


------------------------------------------------------------------------


Mamye Kratt - 09/Jan/08 01:37 PM
(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.

Mamye Kratt - 09/Jan/08 01:37 PM
Needs to be tested in devildog.

Mamye Kratt - 30/Jan/08 03:35 PM
(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.