Author: dda
Date: 2007-12-14 15:51:07 -0800 (Fri, 14 Dec 2007)
New Revision: 7555

Modified:
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
Log:
Change 20071214-dda-z by [EMAIL PROTECTED] on 2007-12-14 18:43:15 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary: Fixed modifiers for 'class'

New Features: none

Bugs Fixed: LPP-5178

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

Documentation: none

Release Notes: none

Details:
    Modifiers were not being emitted in the proper place for classes,
    in fact they were being emitted in the wrong output file.
    This is because the entire class declaration is boxed by
    'annotations' that are used in splitting files.  The
    modifiers need to be put inside the annotations, not
    just in front of them.

Tests:
    buildlfc with 'LzNode' class marked as dynamic now emits
    dynamic in the right place.



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
     2007-12-14 23:50:55 UTC (rev 7554)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
     2007-12-14 23:51:07 UTC (rev 7555)
@@ -52,23 +52,22 @@
   public static final String MULTILINE_COMMENT_BEGIN = "/*";
   public static final String MULTILINE_COMMENT_END = "*/";
 
-  // workaround an apparent third party compiler bug.
+  // push modifiers string next to the following keywords in the code.
+  // modifiers, like 'static' or 'dynamic' normally appear before
+  // keywords like 'function', 'class' or 'var'.  However, after
+  // a function/class is processed, the resulting string may
+  // contain comments, newlines or annotations.
   //
-  //   static
-  //   /* -*- file: some/file.lzs#50.1 -*- */
-  //   function ....
+  // The annotation in fact may state that the class is beginning
+  // at this point.  In order to get the modifier string into the right
+  // file, we need to push it past the annotation.
   //
-  // causes a parse error. whereas putting the static on
-  // the same line as 'function' does not (even with the comment
-  // in place).  To promote readability, we convert the above to:
+  // Also keywords like 'static' must appear on the same line as
+  // 'function' so as not to tickle a bug in the third party
+  // compiler.
   //
-  //   /* -*- file: some/file.lzs#50.1 -*- */
-  //   static function ....
-  //
-  // TODO: [2007-12-13 dda] might be able to revisit how
-  // the file comments are emitted to fix this, or just
-  // replace this by mods + code.
-  //
+  // Moving the modifier next to the next piece of real code
+  // resolves all these difficulties.
   protected String prependMods(String code, String mods)
   {
     if (mods.length() == 0)
@@ -79,13 +78,13 @@
     int pos = 0;
     int len = code.length();
     pos = skipWhitespace(code, pos);
-    if (!code.substring(pos).startsWith(MULTILINE_COMMENT_BEGIN))
-      return mods + code;
-    pos = code.indexOf(MULTILINE_COMMENT_END, pos);
-    if (pos < 0)
-      return mods + code;
-    pos += MULTILINE_COMMENT_END.length();
-    pos = skipWhitespace(code, pos);
+    if (code.substring(pos).startsWith(MULTILINE_COMMENT_BEGIN)) {
+      pos = code.indexOf(MULTILINE_COMMENT_END, pos);
+      if (pos < 0)
+        return mods + code;
+      pos += MULTILINE_COMMENT_END.length();
+      pos = skipWhitespace(code, pos);
+    }
     return code.substring(0, pos) + mods + code.substring(pos);
   }
 


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

Reply via email to