Author: dda
Date: 2008-01-12 15:13:15 -0800 (Sat, 12 Jan 2008)
New Revision: 7813

Modified:
   openlaszlo/branches/devildog/WEB-INF/lps/lfc/build.xml
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
   
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
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
   openlaszlo/branches/devildog/build.properties
Log:
Change 20080112-dda-a by [EMAIL PROTECTED] on 2008-01-12 18:05:49 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary: SWF9: move code outside classes to 'main' class.

New Features:

Bugs Fixed: LPP-5234

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

Documentation:

Release Notes:

Details:

This change is motivated by discussions with Henry on where to
put the main class.

The big change was to put everything that appears outside of a class
into the LFCApplication class (if we are building a
library), or the LzApplication class (if we are building an
application).  We expect that these classes exist in the input stream.
If they do not we should throw an error - I'm not currently doing
that, but rather temporarily creating a class by that name to hold
this stuff - because the 'LzApplication' class is not currently being
created by the tag compiler.  That code is marked by a TODO.

Since we're collecting code and later stuffing it into a particular
spot in the class, and to more nicely support the concept of
'top-level', this change adds the concept of 'insertStream markers'.
We already had the concept of collecting output into different streams; now
when we encounter one of these insert stream markers, we can insert
the contents of a stream (for example the 'top-level stream' containing
stuff marked with #passthrough (toplevel:true)) at a certain
point.  This substitution happens at the end of processing a
translation unit.

The smaller change was to fix the build to actually build LFC9.swc,
and put it in the right place.  Building 'debug', 'profile' versions
etc. are ready to go in lps/lfc/build.xml, but are disabled for the
moment (marked by TODO) until we get the basics of building an
application end to end sorted out.

With this change, the LFC builds cleanly, and an application
with just a <canvas> and simple <script> builds cleanly,
modulo the warning about a missing 'LzApplication' class,
since we're adding that as discussed above.

Tests:
  builds lfc as checked into the tree.
  builds the simplest app <canvas><script>var x = 1;</script></canvas>
   against the built lfc.

  runs smoketest for SWF8, DHTML.



Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/build.xml
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/build.xml      2008-01-12 
23:12:55 UTC (rev 7812)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/build.xml      2008-01-12 
23:13:15 UTC (rev 7813)
@@ -6,7 +6,7 @@
 <!--  build.xml                                                             -->
 
 <!-- * 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 ****************************************************** -->
 
@@ -116,7 +116,7 @@
       <srcfileset dir="." includes="**/*" excludes="*.lzl" />
       <srcfileset dir="${sc.dir}" includes="**/*" />
       <srcfileset dir="${LPS_HOME}/WEB-INF/lps/server/src/org/openlaszlo/sc" 
includes="**/*" />
-      <targetfileset dir="${LFCdir}" includes="*.js,*.lzl" 
excludes="lzpreloader.lzl"/>
+      <targetfileset dir="${LFCdir}" includes="*.js,*.lzl,*.swc" 
excludes="lzpreloader.lzl"/>
     </dependset>
 
     <script language="javascript">
@@ -207,40 +207,45 @@
       }
     }
 
-    var swfruntimes = [7, 8];
+    var swfruntimes = [7, 8, 9];
 
     for (var s in swfruntimes) {
       var v = swfruntimes[s];
 
+      var ext = (v == 9) ? ".swc" : ".lzl";
+      var shlibopt = "--option buildSharedLibrary=true ";
+
       // Check whether the options tell us to build this runtime at all
       var buildThisRuntime = lfc.getProperty("build.lfc.runtime.swf" + v);
       if (buildThisRuntime != null) {
-        var plain = LFCdir + "LFC" + v + ".lzl";
+        var plain = LFCdir + "LFC" + v + ext;
         if (!(new File(plain)).exists()) {
-          dobuild(plain, "swf" + v, "");
+          dobuild(plain, "swf" + v, shlibopt);
         }
-        if (buildDebug) {
-          var dest = LFCdir + "LFC" + v + "-debug.lzl";
+        // TODO: [2008-01-11 dda] when ready, add extra builds for SWF9
+        if (buildDebug && v != 9) {
+          var dest = LFCdir + "LFC" + v + "-debug" + ext;
           if (!(new File(dest)).exists()) {
             // TODO: [2006-06-07 ptw] (LPP-2034) When the LFC is 'clean' of
             // warnings, the options can be changed to simply --debug
             dobuild(dest,
                     "swf" + v,
-                    "--option nameFunctions --option warnGlobalAssignments 
'-D$debug=true'");
+                    shlibopt + "--option nameFunctions --option 
warnGlobalAssignments '-D$debug=true'");
           }
-          var dest = LFCdir + "LFC" + v + "-backtrace.lzl";
+          var dest = LFCdir + "LFC" + v + "-backtrace" + ext;
           if (!(new File(dest)).exists()) {
             // TODO: [2006-06-07 ptw] (LPP-2034) When the LFC is 'clean' of
             // warnings, the options can be changed to simply -g3
             dobuild(dest,
                     "swf" + v,
-                    "--option debugBacktrace --option nameFunctions --option 
warnGlobalAssignments '-D$debug=true'");
+                    shlibopt + "--option debugBacktrace --option nameFunctions 
--option warnGlobalAssignments '-D$debug=true'");
           }
         }
-        if (buildProfile) {
-          var profile = LFCdir + "LFC" + v + "-profile.lzl";
+        // TODO: [2008-01-11 dda] when ready, add extra builds for SWF9
+        if (buildProfile && v != 9) {
+          var profile = LFCdir + "LFC" + v + "-profile" + ext;
           if (!(new File(profile)).exists()) {
-            dobuild(profile, "swf" + v, "--profile");
+            dobuild(profile, "swf" + v, shlibopt + "--profile");
           }
         }
       }
@@ -258,8 +263,9 @@
 
   <target name="clean" depends="init,doc.clean">
     <delete failonerror="false">
-      <!-- TODO: [2006-11-30 ptw] Remove next 2 lines after Legals Beta 1 -->
+      <!-- TODO: [2006-11-30 ptw] Remove next 3 lines after Legals Beta 1 -->
       <fileset dir="." includes="*.lzl" />
+      <fileset dir="." includes="*.swc" />
       <fileset dir="." includes="LFC*.js" />
       <fileset dir="${LFCdir}" includes="*" excludes="defaultpreloader.swf" />
     </delete>

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
      2008-01-12 23:12:55 UTC (rev 7812)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
      2008-01-12 23:13:15 UTC (rev 7813)
@@ -190,7 +190,7 @@
 
   public List makeTranslationUnits(SimpleNode translatedNode, boolean 
compress, boolean obfuscate)
   {
-    return (new ParseTreePrinter(compress, 
obfuscate)).makeTranslationUnits(translatedNode);
+    return (new ParseTreePrinter(compress, 
obfuscate)).makeTranslationUnits(translatedNode, options);
   }
 
   public byte[] postProcess(List tunits) {

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
 2008-01-12 23:12:55 UTC (rev 7812)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
 2008-01-12 23:13:15 UTC (rev 7813)
@@ -828,9 +828,8 @@
     return "throw" + delimit(children[0]);
   }
   
-  public List makeTranslationUnits(SimpleNode node)
-  {
-    return makeTranslationUnits(visit(node));
+  public List makeTranslationUnits(SimpleNode node, Compiler.OptionMap 
options) {
+    return makeTranslationUnits(visit(node), options);
   }
 
   public String text(SimpleNode node) {
@@ -842,10 +841,11 @@
   }
   
   public static final char ANNOTATE_MARKER = '\u0001';
-  // note: numbers are reserved for annotation to streams
-  public static final char ANNOTATE_OP_LINENUM = 'L';
+  // note: number codes are reserved for annotation to streams
   public static final char ANNOTATE_OP_CLASSNAME = 'C';
   public static final char ANNOTATE_OP_CLASSEND = 'c';
+  public static final char ANNOTATE_OP_INSERTSTREAM = 'i';
+  public static final char ANNOTATE_OP_LINENUM = 'L';
   public static final char ANNOTATE_OP_NODENAME = 'N';
   public static final char ANNOTATE_OP_NODEEND = 'n';
   public static final char ANNOTATE_OP_TEXT = 'T';
@@ -900,6 +900,13 @@
     return makeAnnotation((char)('0' + streamNum), str);
   }
 
+  // This marker will be replaced by the contents of the designated stream.
+  public String annotateInsertStream(int streamNum) {
+    StringBuffer sb = new StringBuffer();
+    sb.append(makeAnnotation(ANNOTATE_OP_INSERTSTREAM, 
String.valueOf(streamNum)));
+    return sb.toString();
+  }
+
   /**
    * Add annotations, which look like \u0001 opchar operand \u0001
    * opchar is a single character.
@@ -965,6 +972,8 @@
             return "#class " + operand + ": ";
           case ANNOTATE_OP_CLASSEND:
             return "#endclass";
+          case ANNOTATE_OP_INSERTSTREAM:
+            return "#insertstream " + operand + ": ";
           case ANNOTATE_OP_NODENAME:
             nodestack.addLast(operand);
             return "#node " + operand + ": ";
@@ -981,7 +990,7 @@
     return ap.process(annotated);
   }
 
-  public List makeTranslationUnits(String annotated) {
+  public List makeTranslationUnits(String annotated, Compiler.OptionMap 
options) {
     final ArrayList tunits = new ArrayList();
     final TranslationUnit defaulttu = new TranslationUnit(true);
 
@@ -1006,6 +1015,12 @@
             curtu.setName(operand);
             tunits.add(curtu);
             return "";
+          case ANNOTATE_OP_INSERTSTREAM:
+            // Since the contents of each stream is not fully formed yet,
+            // we can't insert it verbatim yet.  TranslationUnit will
+            // handle the insertion in a final pass.
+            curtu.addInsertStreamMarker(Integer.parseInt(operand));
+            return "";
           case ANNOTATE_OP_CLASSEND:
             curtu = defaulttu;
             return "";

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-12 23:12:55 UTC (rev 7812)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
    2008-01-12 23:13:15 UTC (rev 7813)
@@ -46,12 +46,11 @@
    */
   public static final boolean USE_COMPILER_DEBUG_FLAG = true;
 
-  /* The user 'main' class is DefaultApplication which extends LfcApplication 
*/
-  public final static String DEFAULT_APP_CLASSNAME = "DefaultApplication";
+  /** The user 'main' class, which extends LFCApplication */
+  public final static String DEFAULT_APP_CLASSNAME = "LzApplication";
 
-  // TODO: [2008-1-4 dda] make this LfcApplication when we remove our
-  // bootstrapping toy-lfc library.
-  public final static String DEFAULT_LIB_CLASSNAME = "LzApplication";
+  /** The LFC 'main' class, which extends nothing */
+  public final static String DEFAULT_LIB_CLASSNAME = "LFCApplication";
 
   /**
    * Saved program node, to show during debugging
@@ -177,20 +176,27 @@
    * Intercept JavascriptGenerator version.
    * We keep track of variables that are implicitly global.
    */
-  public SimpleNode visitVariableDeclaration(SimpleNode node, SimpleNode[] 
children) {
-    if (inDefaultClass && !inMethod) {
+  public SimpleNode visitVariableStatement(SimpleNode node, SimpleNode[] 
children) {
+    if (inDefaultClass && !inMethod &&
+        children.length == 1 &&
+        children[0] instanceof ASTVariableDeclaration) {
+      // capture declarations for globals, they'll get into their own
+      // program units.
       String initializer = null;
-      if (children.length > 1) {
-        initializer = (new SWF9ParseTreePrinter()).text(children[1]);
+      SimpleNode[] varchildren = children[0].getChildren();
+      if (varchildren.length > 1) {
+        initializer = (new SWF9ParseTreePrinter()).text(varchildren[1]);
       }
-      if (children.length > 0) {
-        ASTIdentifier id = (ASTIdentifier)children[0];
+      if (varchildren.length > 0) {
+        ASTIdentifier id = (ASTIdentifier)varchildren[0];
         ASTIdentifier.Type type = id.getType();
         addGlobalVar(id.getName(), type == null ? null : type.toString(), 
initializer);
-        return node;
       }
+      node = new ASTStatement(0);
+      node.set(0, new ASTEmptyExpression(0));
+      return node;
     }
-    return super.visitVariableDeclaration(node, children);
+    return super.visitVariableStatement(node, children);
   }
 
   public void setOriginalSource(String source) {
@@ -684,6 +690,7 @@
   public byte[] flexCompile(List tunits, String tempdir, String apptype)
     throws IOException
   {
+    TranslationUnit appTunit = null;
     boolean buildSharedLibrary = 
options.getBoolean(Compiler.BUILD_SHARED_LIBRARY);
     assert (apptype != null && !buildSharedLibrary) : "application class type 
never set";
 
@@ -706,7 +713,14 @@
     cmd += " -output " + swcfilebase;
     cmd += " --";
     for (Iterator iter = tunits.iterator(); iter.hasNext(); ) {
-      cmd += " " + ((TranslationUnit)iter.next()).getName();
+      TranslationUnit tunit = (TranslationUnit)iter.next();
+      // The application main is built in a final step after this.
+      if (buildSharedLibrary || !tunit.isMainTranslationUnit()) {
+        cmd += " " + tunit.getName();
+      }
+      else {
+        appTunit = tunit;
+      }
     }
 
     execCompileCommand(cmd, tempdir, tunits, swcfilename);
@@ -715,15 +729,7 @@
       return getBytes(swcfilename);
     }
 
-    TranslationUnit stubtunit = new TranslationUnit();
-    stubtunit.setName("_stubapp");
-    stubtunit.addText("  import flash.display.Sprite\n" +
-                      "  public class _stubapp extends Sprite {\n" +
-                      "    public function _stubapp() {\n" +
-                      "      var app:LzApplication = new " + apptype + "();\n" 
+
-                      "    }\n" +
-                      "  }\n");
-    writeOutputFile(stubtunit, DEFAULT_FILE_PREAMBLE, DEFAULT_FILE_EPILOG);
+    assert(appTunit != null);
 
     String appBuilderCmd = getLPSPathname("compiler.swf9.lib.builder");
     cmd = appBuilderCmd;
@@ -735,23 +741,20 @@
     if (USE_COMPILER_DEBUG_FLAG)
       cmd += " -debug=true";
     cmd += " -output " + outfilebase;
-    cmd += " _stubapp";
+    cmd += " " + appTunit.getName();
 
-    // empty list of translation units, so no error line number translation
-    execCompileCommand(cmd, tempdir, new ArrayList(), outfilename);
+    execCompileCommand(cmd, tempdir, tunits, outfilename);
     return getBytes(outfilename);
   }
 
   public List makeTranslationUnits(SimpleNode translatedNode, boolean 
compress, boolean obfuscate)
   {
-    return (new SWF9ParseTreePrinter(compress, 
obfuscate)).makeTranslationUnits(translatedNode);
+    return (new SWF9ParseTreePrinter(compress, 
obfuscate)).makeTranslationUnits(translatedNode, options);
   }
 
   public void writeOutputFile(TranslationUnit tunit, String pre, String post) {
     String name = tunit.getName();
     String body = tunit.getContents();
-    // Everything inserted by #passthrough (toplevel:true) goes into stream 1
-    String toplevel = tunit.getStreamText(1);
     String infilename = tempdir + File.separator + name + ".as";
     tunit.setSourceFileName(infilename);
 
@@ -764,7 +767,6 @@
     try {
       fos = new FileOutputStream(infilename);
       fos.write(pre.getBytes());
-      fos.write(toplevel.getBytes());
       fos.write(body.getBytes());
       fos.write(post.getBytes());
       fos.close();
@@ -862,31 +864,6 @@
       String preamble = DEFAULT_FILE_PREAMBLE;
       String epilog = DEFAULT_FILE_EPILOG;
 
-      if (tunit.isDefaultTranslationUnit()) {
-        if (buildSharedLibrary) {
-          String name = DEFAULT_LIB_CLASSNAME;
-          tunit.setName(name);
-          preamble += "public class " + name + " {\n";
-          epilog = "\n}" + epilog;
-        }
-        else {
-          String name = DEFAULT_APP_CLASSNAME;
-          apptype = name;
-          tunit.setName(name);
-          preamble += "public class " + name +
-            " extends " + DEFAULT_LIB_CLASSNAME +
-            " {\n";
-          preamble += "  function _lzAppInit () {\n";
-          preamble += "    lzApplicationInstance = this;\n";
-          preamble += "    return 0;\n";
-          preamble += "  }\n";
-          preamble += "  var _lzAppInitIgnored = _lzAppInit();\n";
-
-          epilog = "\n}" + epilog;
-
-          addGlobalVar("lzApplicationInstance", name, null);
-        }
-      }
       writeOutputFile(tunit, preamble, epilog);
     }
 

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-12 23:12:55 UTC (rev 7812)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
     2008-01-12 23:13:15 UTC (rev 7813)
@@ -34,6 +34,22 @@
 // This class supports the Javascript translator
 public class SWF9ParseTreePrinter extends ParseTreePrinter {
 
+  /** We collect certain parts of translation units
+   * into the 'top level', appearing outside a class.
+   */
+  public final static int TOP_LEVEL_STREAM = 1;
+
+  /** We collect certain parts of translation units
+   * to appear just inside the class declaration.
+   */
+  public final static int CLASS_BEGIN_STREAM = 2;
+
+  /** We collect certain parts of translation units
+   * to appear at the end of the class declaration.
+   */
+  public final static int CLASS_END_STREAM = 3;
+
+
   // Adjust the known operator names we output to include
   // ones that we know about.
   static {
@@ -56,6 +72,57 @@
       super(false, false);
   }
 
+  // Override parent class.
+  //
+  // We need a translation unit (class) to put all the executable
+  // statements appearing outside the class definitions - initially
+  // these are put into the 'default' translation unit.  For building an
+  // application or the LFC, we have a 'main' class that must
+  // be present to accept these statements.
+  //
+  public List makeTranslationUnits(String annotated, Compiler.OptionMap 
options) {
+    List result = super.makeTranslationUnits(annotated, options);
+    TranslationUnit defaultTunit = null;
+    TranslationUnit mainTunit = null;
+    boolean sharedLibrary = options.getBoolean(Compiler.BUILD_SHARED_LIBRARY);
+    String mainClassName = sharedLibrary ?
+      SWF9Generator.DEFAULT_LIB_CLASSNAME : 
SWF9Generator.DEFAULT_APP_CLASSNAME;
+    for (Iterator iter = result.iterator(); iter.hasNext(); ) {
+      TranslationUnit tunit = (TranslationUnit)iter.next();
+      if (tunit.isDefaultTranslationUnit()) {
+        defaultTunit = tunit;
+        iter.remove();
+      }
+      else if (tunit.getName().equals(mainClassName)) {
+        mainTunit = tunit;
+      }
+    }
+
+    assert (defaultTunit != null);
+
+    // If the main class is not present, we'll need to revisit
+    // our assumptions about where we put top level statements.
+    if (mainTunit != null) {
+      mainTunit.addStreamText(CLASS_END_STREAM, defaultTunit.getContents());
+      mainTunit.setMainTranslationUnit(true);
+    }
+    else {
+      // TODO: [2008-1-11 dda] throw an error for this case, rather than fudge
+      //throw new CompilerError("Could not find application main or library 
main class");
+      System.err.println("Warning: could not find main class: " + 
mainClassName + ", creating one");
+      defaultTunit.setMainTranslationUnit(true);
+      defaultTunit.setName(mainClassName);
+      defaultTunit.addText("class " + mainClassName);
+      if (!sharedLibrary) {
+        defaultTunit.addText(" extends " + 
SWF9Generator.DEFAULT_LIB_CLASSNAME);
+      }
+      defaultTunit.addText(" { }\n");
+      result.add(defaultTunit);
+    }
+
+    return result;
+  }
+
   public static final String MULTILINE_COMMENT_BEGIN = "/*";
   public static final String MULTILINE_COMMENT_END = "*/";
 
@@ -128,6 +195,9 @@
   public String visitClassDefinition(SimpleNode node, String[] children) {
     String classnm = unannotate(children[1]);
     StringBuffer sb = new StringBuffer();
+
+    // Everything inserted by #passthrough (toplevel:true) goes here.
+    sb.append(annotateInsertStream(TOP_LEVEL_STREAM));
     sb.append("class" + SPACE + classnm + SPACE);
     if (unannotate(children[2]).length() > 0)
       sb.append("extends" + SPACE + children[2] + SPACE);
@@ -136,9 +206,11 @@
     // if (unannotate(children[3]).length() > 0) ....
 
     sb.append("{\n");
+    sb.append(annotateInsertStream(CLASS_BEGIN_STREAM));
     for (int i=4; i<children.length; i++) {
       sb.append(children[i]);
     }
+    sb.append(annotateInsertStream(CLASS_END_STREAM));
     sb.append("}\n");
 
     return annotateClass(classnm, sb.toString());
@@ -151,7 +223,7 @@
     ASTPassthroughDirective passthrough = (ASTPassthroughDirective)node;
     String text = passthrough.getText();
     if (passthrough.getBoolean(SWF9Generator.PASSTHROUGH_TOPLEVEL))
-      text = annotateStream(1, text);
+      text = annotateStream(TOP_LEVEL_STREAM, text);
     return text;
   }
 

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
  2008-01-12 23:12:55 UTC (rev 7812)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
  2008-01-12 23:13:15 UTC (rev 7813)
@@ -23,9 +23,16 @@
   private SortedMap lnums = new TreeMap();
   private int linenum = 1;
   private String srcFilename;   // name of associated source file, if 
applicable
-  private boolean isDefault = false;
+  private boolean isDefault = false; // stuff not within a class goes to 
default
+  private boolean isMain = false;    // designated classes, like LFCApplication
   private Map streams = new HashMap(); // alternate streams, indexed by number
+  private int maxInserts = 0;          // bound the number of stream insert 
replacements
 
+  // When these appear in the contents they will be replaced
+  // by the indicated stream whenever contents is retrieved.
+  public static final String INSERT_STREAM_MARK = "#insertStream(";
+  public static final String INSERT_END_MARK = ")";
+
   public String getName() {
     return name;
   }
@@ -51,18 +58,41 @@
   }
 
   public String getContents() {
-    return contents.toString();
+    String result = contents.toString();
+    for (int i=1; i<=maxInserts; i++) {
+      String mark = INSERT_STREAM_MARK + i + INSERT_END_MARK;
+      int markPos = result.indexOf(mark);
+      if (markPos >= 0) {
+        result = result.substring(0, markPos) + getStreamText(i) +
+          result.substring(markPos + mark.length());
+      }
+    }
+    return result;
   }
 
   public boolean isDefaultTranslationUnit() {
     return isDefault;
   }
 
+  public boolean isMainTranslationUnit() {
+    return isMain;
+  }
+
+  public void setMainTranslationUnit(boolean value) {
+    isMain = value;
+  }
+
   public void addText(String s) {
     contents.append(s);
     linenum += countOccurence(s, '\n');
   }
 
+  public void addInsertStreamMarker(int streamNum) {
+    contents.append(INSERT_STREAM_MARK + streamNum + INSERT_END_MARK);
+    if (streamNum > maxInserts)
+      maxInserts = streamNum;
+  }
+
   public void addStreamText(int streamNum, String s) {
     Integer key = new Integer(streamNum);
     String cur = (String)streams.get(key);

Modified: openlaszlo/branches/devildog/build.properties
===================================================================
--- openlaszlo/branches/devildog/build.properties       2008-01-12 23:12:55 UTC 
(rev 7812)
+++ openlaszlo/branches/devildog/build.properties       2008-01-12 23:13:15 UTC 
(rev 7813)
@@ -23,6 +23,7 @@
 # build.lfc.runtime.swf6 = true
 build.lfc.runtime.swf7 = true
 build.lfc.runtime.swf8 = true
+build.lfc.runtime.swf9 = true
 build.lfc.runtime.dhtml = true
 
 # LFC variants to build


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

Reply via email to