Author: dda
Date: 2007-09-19 13:26:31 -0700 (Wed, 19 Sep 2007)
New Revision: 6529
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
Log:
Change 20070919-dda-f by [EMAIL PROTECTED] on 2007-09-19 13:41:48 EDT
in
/Users/dda/laszlo/src/svn/openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc
for
http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc
Summary: generatePredictableTemps option for script compiler
New Features:
added new option generatePredictableTemps that allows for direct comparison
of compiler outputs.
Bugs Fixed:
Technical Reviewer: ptw
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
The new option, is specified to the compiler like this:
--option generatePredictableTemps=true
Note that this option is *not* the default, nor is it recommended for anyone
that is not doing side-by-side tests of the compiler. When used, it may
in fact *break* functionality. It provides some capabilities to assist
in internal testing, and specifically for testing the refactoring work.
When this is option is set, variables that normally use a UUID-like naming
(for uniqueness between runs)
are changed to have predictable names, that is names that will be identical
each time
the compiler is rerun. Such predictable names (like "$lzsc$1", "$lzsc$2",
etc.) will
collide with the same names used in other compilations that appear in the
same applications,
which may cause problems at runtime. This option uses a simple increment to
generate
names. Seeding the random number generator with a fixed value, like 0, would
also work
but the output will appear more obfuscated.
The intention is that this option can be used when making an architectural or
'cleanup'
change to the compiler that is not intended to change any behavior. When
this change
is done, a suitably complete test input can be fed to the old and new
compiler, both
with the generatePredictableTemps option, and comparisons of outputs can be
made directly.
Tests:
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
===================================================================
---
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
2007-09-19 19:48:04 UTC (rev 6528)
+++
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
2007-09-19 20:26:31 UTC (rev 6529)
@@ -1854,9 +1854,19 @@
}
// TODO: [2007-08-20 ptw] Replace with Java 1.5 UUID
+ private Boolean usePredictable = null;
private Random rand = new Random();
- private Integer UUID() {
- return new Integer(rand.nextInt(Integer.MAX_VALUE));
+ private int uuidCounter = 1;
+ protected Integer UUID() {
+ if (usePredictable == null) {
+ usePredictable = new
Boolean(options.getBoolean(Compiler.GENERATE_PREDICTABLE_TEMPS));
+ }
+ if (usePredictable.equals(Boolean.TRUE)) {
+ return new Integer(uuidCounter++);
+ }
+ else {
+ return new Integer(rand.nextInt(Integer.MAX_VALUE));
+ }
}
public boolean visitCallExpression(SimpleNode node, boolean isReferenced,
SimpleNode[] children) {
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
2007-09-19 19:48:04 UTC (rev 6528)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
2007-09-19 20:26:31 UTC (rev 6529)
@@ -399,6 +399,7 @@
public static String FLASH_COMPILER_COMPATABILITY =
"flashCompilerCompatability";
public static String GENERATE_FUNCTION_2 = "generateFunction2";
public static String GENERATE_FUNCTION_2_FOR_LZX = "generateFunction2ForLZX";
+ public static String GENERATE_PREDICTABLE_TEMPS = "generatePredictableTemps";
public static String INCLUDES = "processIncludes";
public static String INSTR_STATS = "instrStats";
public static String LINK = "link";
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
===================================================================
---
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
2007-09-19 19:48:04 UTC (rev 6528)
+++
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
2007-09-19 20:26:31 UTC (rev 6529)
@@ -1421,9 +1421,19 @@
}
// TODO: [2007-08-20 ptw] Replace with Java 1.5 UUID
+ private Boolean usePredictable = null;
private Random rand = new Random();
- private Integer UUID() {
- return new Integer(rand.nextInt(Integer.MAX_VALUE));
+ private int uuidCounter = 1;
+ protected Integer UUID() {
+ if (usePredictable == null) {
+ usePredictable = new
Boolean(options.getBoolean(Compiler.GENERATE_PREDICTABLE_TEMPS));
+ }
+ if (usePredictable.equals(Boolean.TRUE)) {
+ return new Integer(uuidCounter++);
+ }
+ else {
+ return new Integer(rand.nextInt(Integer.MAX_VALUE));
+ }
}
// Could do inline expansions here, like setAttribute
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins