Author: dda
Date: 2008-01-10 11:45:34 -0800 (Thu, 10 Jan 2008)
New Revision: 7806

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
   
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
   openlaszlo/trunk/test/typevar.lzx
Log:
Change 20080109-dda-l by [EMAIL PROTECTED] on 2008-01-09 16:00:35 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Script compiler: Backported :* typing from devildog to trunk; added 
typing in 'for var in' statements.

New Features: Any variable can be declared with :* (in addition to :typename as 
before).

Bugs Fixed: LPP-5059

Technical Reviewer: ptw (pending)
QA Reviewer: hminsky (pending)
Doc Reviewer: (pending)

Documentation:
   Conforms with ECMAScript-4 draft standard.

Release Notes:

Details:
   One part of this change (:* types) is backported from devildog -
   the change was small and relatively independent and should have been
   made in trunk/RingDing before.

   The other part of this change is a small grammar change to allow
   typing in 'for var in' statements, like so:
     for (var:typename in xxx)
   or
     for (var:* in xxx)
   etc.

Tests:
   smoketest

   Updated test/typevar.lzx to have a couple tests for 'for var in' and :*, 
which
   were not there before.



Modified: 
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt     
2008-01-10 19:45:08 UTC (rev 7805)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt     
2008-01-10 19:45:34 UTC (rev 7806)
@@ -707,12 +707,13 @@
 
 ASTIdentifier.Type TypeIdentifier() #void : { Token t; ASTIdentifier.Type type 
= new ASTIdentifier.Type(); }
 {
-  (
+ ("*"                   {type.typeName = "*"; type.untyped = true;}
+ |(
     t = <IDENTIFIER>    {type.typeName = t.image;}
       [ NotNullable()   {type.notnullable = true; }
       | Nullable()      {type.nullable = true; }
       ]
-  ) {
+  )) {
     return type;
   }
 }
@@ -807,9 +808,16 @@
      "for" "(" { setAllowIn(false); } Expression() { setAllowIn(true); } "in" 
Expression() ")" Statement()
 }
 
-void ForVarInStatement() #ForVarInStatement : {}
+void ForVarInStatement() #ForVarInStatement : {ASTIdentifier id; 
ASTIdentifier.Type type;}
 {
-     "for" "(" "var" Identifier() ({ setAllowIn(false); } [Initializer()] { 
setAllowIn(true); }) #EmptyExpression(jjtree.nodeArity()==0) "in" Expression() 
")" Statement()
+     "for" "(" "var" id = Identifier()
+     (
+        [ ":" type = TypeIdentifier() { id.setType(type); } ]
+        { setAllowIn(false); }
+        [Initializer()]
+        { setAllowIn(true); }
+     ) #EmptyExpression(jjtree.nodeArity()==0)
+     "in" Expression() ")" Statement()
 }
 
 void ContinueStatement() #ContinueStatement : {}

Modified: 
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
===================================================================
--- 
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
      2008-01-10 19:45:08 UTC (rev 7805)
+++ 
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
      2008-01-10 19:45:34 UTC (rev 7806)
@@ -3,7 +3,7 @@
 * ****************************************************************************/
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -18,6 +18,7 @@
         public String typeName = null;
         public boolean nullable = false; // has "?"
         public boolean notnullable = false; // has "!"
+        public boolean untyped = false;     // is "*"
     }
 
     public ASTIdentifier(int id) {

Modified: openlaszlo/trunk/test/typevar.lzx
===================================================================
--- openlaszlo/trunk/test/typevar.lzx   2008-01-10 19:45:08 UTC (rev 7805)
+++ openlaszlo/trunk/test/typevar.lzx   2008-01-10 19:45:34 UTC (rev 7806)
@@ -16,6 +16,7 @@
       var v_typed_init:int = val * 2;
       var v_typed_q:int? = 123;
       var v_typed_ex:int! = 234;
+      var v_star:* = 345;
 
       // These must be set before use
       v_plain = 99;
@@ -71,6 +72,27 @@
          estatus.setText("FAIL 7");
       }
 
+      if (v_star == 345) {
+         Debug.write("test8 passed");
+      } else {
+         Debug.write("FAIL: test8");
+         estatus.setText("FAIL 8");
+      }
+
+      var arr = [0,1,2];
+      var s = "";
+      for (var fv_star:* in arr) {
+          s += fv_star;
+      }
+
+      // There is no guarantee about the ordering of for var in
+      if (s == "012" || s == "021" || s == "102" || s == "120" || s == "201" 
|| s == "210") {
+         Debug.write("test9 passed");
+      } else {
+         Debug.write("FAIL: test9");
+         estatus.setText("FAIL 9, got: " + s);
+      }
+
     </method>
   </view>
 
@@ -84,6 +106,6 @@
 
 </canvas>
 <!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * X_LZ_COPYRIGHT_END ****************************************************** -->


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

Reply via email to