Author: dda
Date: 2008-02-12 15:02:09 -0800 (Tue, 12 Feb 2008)
New Revision: 8010

Modified:
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
Log:
Change 20080212-dda-g by [EMAIL PROTECTED] on 2008-02-12 17:34:01 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary:  SWF9: fix global variables errantly created within 'default' class, 
fix debug temp files

New Features:

Bugs Fixed: LPP-5425

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

Documentation:

Release Notes:

Details:
    This is actually two changes.
    
    - A one line change to fix the problem reported by Henry in LPP-5425.
      We now track that we are within a method correctly.  This makes
      the simple algorithm work: if we are not in a method and we are
      outside of a class definition (i.e. within the 'default class'),
      then vars are tracked as globals.

    - To help debug this, needed to fix the creation of temp files
      that show the original source, processed source and AST.  A previous
      change broke this - presumably these files were created in the
      'current directory', rather than in the /tmp/lzswf9/lzgen*
      directory.  Some cleanup done, some error checking added,
      in the name of making this code clearer and that error no longer possible.
      

Tests:



Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
     2008-02-12 22:44:13 UTC (rev 8009)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
     2008-02-12 23:02:09 UTC (rev 8010)
@@ -41,7 +41,7 @@
    */
   public static final boolean USE_COMPILER_DEBUG_FLAG = true;
 
-  private File tempdir = getCompilationTempDir();
+  private File tempdir = createCompilationTempDir();
   private Compiler.OptionMap options;
 
   /**
@@ -99,7 +99,7 @@
    * and return a File for it.
    * @throw CompilerError when directory creation fails
    */
-  public File getCompilationTempDir()
+  private File createCompilationTempDir()
   {
     // TODO: [2007-11-20 dda] Need some provisions for file
     // cleanup on error, and on success too.
@@ -123,6 +123,19 @@
   }
 
   /**
+   * For a relative file name, return an absolute path name
+   * as the file would appear in the work directory for the compiler.
+   */
+  public String workDirectoryName(String file)
+  {
+    if (new File(file).isAbsolute()) {
+      throw new IllegalArgumentException("workDirectoryName: file name must be 
relative");
+    }
+    return tempdir.getPath() + File.separator + file;
+  }
+
+
+  /**
    * Close an input stream unconditionally.
    */
   public static void closeit(InputStream is)
@@ -437,7 +450,7 @@
       String buildsh = "#!/bin/sh\n";
       buildsh += "cd " + dir + "\n";
       buildsh += prettycmd + "\n";
-      emitFile("build.sh", buildsh);
+      emitFile(workDirectoryName("build.sh"), buildsh);
     }
 
     Process proc = Runtime.getRuntime().exec(cmdstr, null, new File(dir));
@@ -705,6 +718,9 @@
     FileWriter writer = null;
     try {
       File f = new File(filename);
+      if (!f.isAbsolute()) {
+        throw new IllegalArgumentException("emitFile: file name cannot be 
relative");
+      }
       f.delete();
       writer = new FileWriter(f);
       tw.emit(writer);

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-02-12 22:44:13 UTC (rev 8009)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
    2008-02-12 23:02:09 UTC (rev 8010)
@@ -418,6 +418,7 @@
   SimpleNode translateFunction(SimpleNode node, boolean isReferenced, 
SimpleNode[] children) {
 
     boolean savedInMethod = inMethod;
+    inMethod = true;
     try {
       return super.translateFunction(node, isReferenced, children);
     }
@@ -510,9 +511,9 @@
     SWF9External ex = new SWF9External(options);
 
     if (DEBUG_OUTPUT) {
-      ex.emitFile("source.txt", savedSource);
-      ex.emitFile("program.txt", (new 
SWF9ParseTreePrinter()).text(savedProgram));
-      ex.emitFile("progdump.txt", savedProgram);
+      ex.emitFile(ex.workDirectoryName("source.txt"), savedSource);
+      ex.emitFile(ex.workDirectoryName("program.txt"), (new 
SWF9ParseTreePrinter()).text(savedProgram));
+      ex.emitFile(ex.workDirectoryName("progdump.txt"), savedProgram);
     }
 
     for (Iterator iter = tunits.iterator(); iter.hasNext(); ) {


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

Reply via email to