[Laszlo-checkins] r11834 - openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc
dda@openlaszlo.org
dda at openlaszlo.org
Wed Nov 19 18:34:56 PST 2008
Author: dda
Date: 2008-11-19 18:34:55 -0800 (Wed, 19 Nov 2008)
New Revision: 11834
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
Log:
Change 20081119-dda-c by dda at lester.local on 2008-11-19 18:04:20 EST
in /Users/dda/laszlo/src/svn/openlaszlo/trunk-d
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Do not emit 'public' identifier for top level functions.
New Features:
Bugs Fixed: LPP-7302 (swf9 top level functions get compiled in debug mode with "public" modifier, which is an error)
Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
When emitting code, track when we are in a class.
If we're not in class (that is, we're at the top level) and we're emitting a function,
don't insert a public in front of it -- we would normally do that in debug mode
to 'expose' methods and variables to the debugger. But a top level
'public function' is not allowed in SWF9.
Tests:
With LPP-7302.lzx:
<canvas>
<script when="immediate">
function foo (str1, str2) {
}
</script>
</canvas>
compiled via: lzc --runtime=swf9 -g LPP-7302.lzx --script
and verified that this change 'removed' the public modifier.
Regression: smokecheck SWF8,SWF9,DHTML
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java 2008-11-19 23:31:48 UTC (rev 11833)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java 2008-11-20 02:34:55 UTC (rev 11834)
@@ -71,6 +71,9 @@
/** State variable that is true while we are in a method */
private boolean inmethod = false;
+ /** State variable that is true while we are in a class */
+ private boolean inclass = false;
+
// Adjust the known operator names we output to include
// ones that we know about.
static {
@@ -111,6 +114,9 @@
if (!"class".equals(id.getName())) {
this.inmixin = true;
}
+ else {
+ this.inclass = true;
+ }
}
return super.previsit(node);
}
@@ -223,8 +229,13 @@
// override
public String visitModifiedDefinition(SimpleNode node, String[] children) {
- boolean forcePublic = config.forcePublicMembers && !inmethod &&
- !(node.getChildren()[0] instanceof ASTEmptyExpression);
+ SimpleNode subnode = node.getChildren()[0];
+ boolean forcePublic =
+ config.forcePublicMembers && !inmethod &&
+ !(subnode instanceof ASTEmptyExpression) &&
+ // top level functions cannot be marked public
+ (inclass || inmixin || !(subnode instanceof ASTFunctionDeclaration));
+
String mods = ((ASTModifiedDefinition)node).toJavascriptString(forcePublic);
return prependMods(children[0], mods);
}
@@ -268,8 +279,9 @@
}
sb.append("}\n");
- // Note: assumes no nested mixins
+ // Note: assumes no nested mixins/classes
inmixin = false;
+ inclass = false;
return annotateClass(classnm, sb.toString());
}
More information about the Laszlo-checkins
mailing list