Author: dda
Date: 2007-12-12 15:12:51 -0800 (Wed, 12 Dec 2007)
New Revision: 7526

Modified:
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
Log:
Change 20071212-dda-X by [EMAIL PROTECTED] on 2007-12-12 18:05:00 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary: SWF9: More fixes for LzNode

New Features: none

Bugs Fixed: LPP-5234 (not completely fixed)

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

Documentation: none

Release Notes: none

Details:
    More fixes for LzNode:

 +  A previous commit added in a call to translateClassDirectivesBlocks,
    but that function moves vars/methods from a class block into properties.
    For SWF9, we want these functions to be real methods on the class,
    so there is a new compiler (internal) option, called KEEP_CLASS_METHODS
    that indicates that vars/methods should be kept as regular declared
    elements of the class.

 +  Fixed a method declaration the placement of setting the inDefaultClass which
    were causing the generator to not accurately know if it was in a function
    or a class.

Tests:
  buildlfc with only LzNode enabled.



Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
  2007-12-12 23:12:31 UTC (rev 7525)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
  2007-12-12 23:12:51 UTC (rev 7526)
@@ -391,7 +391,7 @@
 
   public void translateClassDirectivesBlock(SimpleNode[] dirs, String 
classnameString, List props, List classProps, List stmts) {
     dirs = (SimpleNode[])(flatten(dirs).toArray(new SimpleNode[0]));
-
+    boolean keepClassMethods = options.getBoolean(Compiler.KEEP_CLASS_METHODS);
     // Scope #pragma directives to block
     Compiler.OptionMap savedOptions = options;
     try {
@@ -411,7 +411,7 @@
           n = n.get(0);
           mod.verifyClassLevel(n);
         }
-        if (n instanceof ASTFunctionDeclaration) {
+        if (n instanceof ASTFunctionDeclaration && !keepClassMethods) {
           SimpleNode[] c = n.getChildren();
           assert c.length == 3;
           p.add(new ASTLiteral(((ASTIdentifier)c[0]).getName()));
@@ -419,7 +419,7 @@
           funexpr.setBeginLocation(n.filename, n.beginLine, n.beginColumn);
           funexpr.setChildren(c);
           p.add(funexpr);
-        } else if (n instanceof ASTVariableStatement) {
+        } else if (n instanceof ASTVariableStatement && !keepClassMethods) {
           SimpleNode [] c = n.getChildren();
           for (int j = 0, len = c.length; j < len; j++) {
             SimpleNode v = c[j];

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
 2007-12-12 23:12:31 UTC (rev 7525)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
 2007-12-12 23:12:51 UTC (rev 7526)
@@ -412,6 +412,7 @@
   public static String GENERATE_PREDICTABLE_TEMPS = "generatePredictableTemps";
   public static String INCLUDES = "processIncludes";
   public static String INSTR_STATS = "instrStats";
+  public static String KEEP_CLASS_METHODS = "keepClassMethods";
   public static String LINK = "link";
   public static String RUNTIME = "runtime";
   public static String METHOD_NAME = "methodName";

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
    2007-12-12 23:12:31 UTC (rev 7525)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
    2007-12-12 23:12:51 UTC (rev 7526)
@@ -115,32 +115,33 @@
     List props = new ArrayList();
     List classProps = new ArrayList();
     List stmts = new ArrayList();
-    translateClassDirectivesBlock(dirs, classnameString, props, classProps, 
stmts);
 
-    /*
-     * TODO: [2007-12-11 dda]  do anything with props/classProps?
-     */
-
-    // Plug the stmt children we found back into this node's children
-    SimpleNode[] newch = new SimpleNode[stmts.size() + 4];
-    int i;
-    for (i=0; i<4; i++)
-      newch[i] = children[i];
-    for (Iterator iter = stmts.iterator(); iter.hasNext(); ) {
-      SimpleNode n = (SimpleNode)iter.next();
-      newch[i++] = visitStatement(n);
-    }
-    node.setChildren(newch);
-
+    options.putBoolean(Compiler.KEEP_CLASS_METHODS, true);
     boolean savedInDefault = inDefaultClass;
     inDefaultClass = false;
     try {
+      translateClassDirectivesBlock(dirs, classnameString, props, classProps, 
stmts);
+
+      /*
+       * TODO: [2007-12-11 dda]  do anything with props/classProps?
+       */
+
+      // Plug the stmt children we found back into this node's children
+      SimpleNode[] newch = new SimpleNode[stmts.size() + 4];
+      int i;
+      for (i=0; i<4; i++)
+        newch[i] = children[i];
+      for (Iterator iter = stmts.iterator(); iter.hasNext(); ) {
+        SimpleNode n = (SimpleNode)iter.next();
+        newch[i++] = visitStatement(n);
+      }
+      node.setChildren(newch);
       visitChildren(node);
     }
     finally {
+      options.putBoolean(Compiler.KEEP_CLASS_METHODS, false);
       inDefaultClass = savedInDefault;
     }
-
     return node;
   }
 
@@ -182,7 +183,7 @@
    * Intercept JavascriptGenerator version, just to
    * track that we are within a function.
    */
-  public SimpleNode translateFunction(SimpleNode node, boolean isReferenced, 
SimpleNode[] children) {
+  SimpleNode translateFunction(SimpleNode node, boolean isReferenced, 
SimpleNode[] children) {
 
     boolean savedInMethod = inMethod;
     try {


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

Reply via email to