Author: dda
Date: 2008-01-08 13:53:49 -0800 (Tue, 08 Jan 2008)
New Revision: 7773

Modified:
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
Log:
Change 20080108-dda-X by [EMAIL PROTECTED] 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



Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
    2008-01-08 21:53:10 UTC (rev 7772)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
    2008-01-08 21:53:49 UTC (rev 7773)
@@ -153,6 +153,24 @@
 
   /**
    * Intercept JavascriptGenerator version.
+   * We pass through 'cast' and 'is' keywords without modification.
+   * 'cast' will be transformred to 'as' on output.
+   */
+  public SimpleNode visitBinaryExpressionSequence(SimpleNode node, boolean 
isReferenced, SimpleNode[] children) {
+    ASTOperator op = (ASTOperator)children[1];
+    if (ParserConstants.CAST ==  op.getOperator() ||
+        ParserConstants.IS ==  op.getOperator()) {
+      children[0] = visitExpression(children[0]);
+      children[2] = visitExpression(children[2]);
+      return node;
+    }
+    else {
+      return super.visitBinaryExpressionSequence(node, isReferenced, children);
+    }
+  }
+
+  /**
+   * Intercept JavascriptGenerator version.
    * We keep track of variables that are implicitly global.
    */
   public SimpleNode visitVariableDeclaration(SimpleNode node, SimpleNode[] 
children) {

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
     2008-01-08 21:53:10 UTC (rev 7772)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
     2008-01-08 21:53:49 UTC (rev 7773)
@@ -34,6 +34,13 @@
 // This class supports the Javascript translator
 public class SWF9ParseTreePrinter extends ParseTreePrinter {
 
+  // Adjust the known operator names we output to include
+  // ones that we know about.
+  static {
+    OperatorNames[Ops.CAST] = "as";
+    OperatorNames[Ops.IS] = "is";
+  }
+  
   public SWF9ParseTreePrinter() {
       // never compress
       this(false, false);


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to