[Laszlo-checkins] r10409 - in openlaszlo/trunk/WEB-INF/lps/server: sc/src/org/openlaszlo/sc/parser src/org/openlaszlo/sc
dda@openlaszlo.org
dda at openlaszlo.org
Thu Jul 17 14:50:41 PDT 2008
Author: dda
Date: 2008-07-17 14:50:33 -0700 (Thu, 17 Jul 2008)
New Revision: 10409
Modified:
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTFormalParameterList.java
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTLiteral.java
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTOperator.java
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTPassthroughDirective.java
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/SimpleNode.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
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
Log:
Change 20080716-dda-V by dda at 97.sub-75-192-214.myvzw.com on 2008-07-16 21:26:41 EDT
in /Users/dda/laszlo/src/svn/openlaszlo/trunk-a
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Fix remapLocals and withThis in SWF9
New Features:
Bugs Fixed: LPP-6637
Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
The SWF9 code generator has had a long standing bug that prevented
the withThis pragma from working. This change set fixes the fundamental bug and
other smaller problems in order to allow withThis to function properly.
withThis is necessary for the new approach to handling states.
The code that disables the withThis from being operation has been removed.
The bug was an extra visit of the function - the second visit sees some
artifacts left by the first visit, and gets confused. This has been fixed.
Mixins in SWF9 are handled by keeping the AST for the mixin and visiting
it whenever it is mixed in. The visited AST was not a complete copy,
only a shallow copy, and this exposed the same sort of extra visit bug.
A deep copy function for SimpleNode (the basis for AST) was added.
This required minor changes to all existing handcoded AST classes to
support deep copy. Fortunately there are not many of these classes,
but if we add any, we'll need to implement the deepCopy() function.
Remapped formal arguments, (e.g. function foo(a, b) => function foo($1, $2)),
must retain any ellipsis from the original declaration (e.g. function foo(a, ...b) => function foo($1, ...$2))
I am also retaining type info, (e.g. function foo(a:*, b) => function foo($1:*, $2))
Tests:
Passes test case given by ptw in LPP-6637.
Builds LFC without errors with withThis code enabled.
Regression tests: smokecheck for swf8/dhtml.
Unfortunately SWF9 hello seems broken (not due to this change),
so unable to test that.
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTFormalParameterList.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTFormalParameterList.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTFormalParameterList.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -3,7 +3,7 @@
* ****************************************************************************/
/* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2007 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2007, 2008 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* J_LZ_COPYRIGHT_END *********************************************************/
@@ -28,4 +28,9 @@
this.returnType = type;
}
+ public SimpleNode deepCopy() {
+ ASTFormalParameterList result = (ASTFormalParameterList)super.deepCopy();
+ result.returnType = this.returnType;
+ return result;
+ }
}
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTIdentifier.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -16,6 +16,17 @@
private boolean ellipsis = false;
private boolean isconstructor = false;
+ public SimpleNode deepCopy() {
+ ASTIdentifier result = (ASTIdentifier)super.deepCopy();
+ result.name = this.name;
+ result.type = this.type;
+ result.hash = this.hash;
+ result.ellipsis = this.ellipsis;
+ result.isconstructor = this.isconstructor;
+ return result;
+ }
+
+ // Note: this is an immutable class once configured, instances may be shared
public static class Type {
public String typeName = null;
public boolean nullable = false; // has "?"
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTLiteral.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTLiteral.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTLiteral.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -8,6 +8,12 @@
private Object mValue = null;
+ public SimpleNode deepCopy() {
+ ASTLiteral result = (ASTLiteral)super.deepCopy();
+ result.mValue = this.mValue; // we expect that mValue is immutable once configured
+ return result;
+ }
+
public ASTLiteral(int id) {
super(id);
}
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -22,6 +22,18 @@
private Token t;
+ public SimpleNode deepCopy() {
+ ASTModifiedDefinition result = (ASTModifiedDefinition)super.deepCopy();
+ result.access = this.access;
+ result.isStatic = this.isStatic;
+ result.isFinal = this.isFinal;
+ result.isDynamic = this.isDynamic;
+ result.isOverride = this.isOverride;
+ result.namespace = this.namespace;
+ result.t = this.t;
+ return result;
+ }
+
public ASTModifiedDefinition(int id) {
super(id);
}
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTOperator.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTOperator.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTOperator.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -13,6 +13,12 @@
private int operatorCode = -1;//todo: EOF;
+ public SimpleNode deepCopy() {
+ ASTOperator result = (ASTOperator)super.deepCopy();
+ result.operatorCode = this.operatorCode;
+ return result;
+ }
+
public ASTOperator(int id) {
super(id);
}
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTPassthroughDirective.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTPassthroughDirective.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTPassthroughDirective.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -26,6 +26,13 @@
super(p, id);
}
+ public SimpleNode deepCopy() {
+ ASTPassthroughDirective result = (ASTPassthroughDirective)super.deepCopy();
+ result.text = this.text;
+ result.options = this.options;
+ return result;
+ }
+
public static Node jjtCreate(int id) {
return new ASTPassthroughDirective(id);
}
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/SimpleNode.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/SimpleNode.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/SimpleNode.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -162,6 +162,33 @@
return this.comment;
}
+ public SimpleNode deepCopy() {
+ SimpleNode result;
+ try {
+ result = (SimpleNode)getClass().getConstructor(new Class[]{int.class}).
+ newInstance(new Object[]{new Integer(id)});
+ }
+ catch (Exception e) {
+ // could be thrown if a subclass does not have a constructor(id)
+ // all javacc generated classes have it.
+ throw new RuntimeException(e);
+ }
+ result.copyFields(this);
+ return result;
+ }
+
+ public void copyFields(SimpleNode that) {
+ this.id = that.id;
+ this.parser = that.parser;
+ this.filename = that.filename;
+ this.beginLine = that.beginLine;
+ this.beginColumn = that.beginColumn;
+ this.comment = that.comment;
+ for (int i=0; i<that.children.length; i++) {
+ this.set(i, that.children[i].deepCopy());
+ }
+ }
+
/** Accept the visitor */
public Object jjtAccept(ParserVisitor visitor, Object data) {
return visitor.visit(this, data);
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 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -842,9 +842,21 @@
public static class PassThroughNode extends SimpleNode {
public SimpleNode realNode;
+ private PassThroughNode() { }
+
public PassThroughNode (SimpleNode realNode) {
this.realNode = realNode;
}
+
+ public SimpleNode deepCopy() {
+ PassThroughNode result = new PassThroughNode();
+ result.copyFields(this);
+ return result;
+ }
+
+ public void copyFields(SimpleNode that) {
+ this.realNode = ((PassThroughNode)that).realNode.deepCopy();
+ }
}
//
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 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -1629,6 +1629,11 @@
if (registers != null && registers.containsKey(name)) {
String register = (String)registers.get(name);
ASTIdentifier newNode = new ASTIdentifier(0);
+ if (node instanceof ASTIdentifier) {
+ ASTIdentifier oldid = (ASTIdentifier)node;
+ newNode.setEllipsis(oldid.getEllipsis());
+ newNode.setType(oldid.getType());
+ }
newNode.setName(register);
this.node = new Compiler.PassThroughNode(newNode);
return;
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java 2008-07-17 21:04:55 UTC (rev 10408)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java 2008-07-17 21:50:33 UTC (rev 10409)
@@ -118,15 +118,6 @@
*/
private Map mixinRef = new HashMap();
- // override superclass version - we don't want to remap names
- // of class variables
-
- public boolean remapLocals() {
- // TODO: [2007-12-11 dda] maybe remap selectively - anything that is
- // private may be remapped.
- return false;
- }
-
// override superclass version - we do not want the
// generator to replace optional function parameters
// or variable arguments (e.g. function f(a1, a2=0, a3=0, ...rest)),
@@ -220,11 +211,8 @@
// emitted.
//
if (!isClass) {
- // before visiting, create a shallow copy of the mixin for the interface
- mixinInterface = new ASTClassDefinition(0);
- for (int i=0; i<children.length; i++) {
- mixinInterface.set(i, children[i]);
- }
+ // before visiting, create a copy of the mixin for the interface
+ mixinInterface = node.deepCopy();
}
translateClassDefinition(node, classnameString, TranslateHow.AS_CLASS);
@@ -260,7 +248,6 @@
newch[i++] = visitStatement(n);
}
node.setChildren(newch);
- visitChildren(node);
}
/**
@@ -468,8 +455,9 @@
// actual arguments for the super(arg1, arg2, ...) call
List actuals = new ArrayList();
for (int i=0; i<origparams.length; i++) {
- if (origparams[i] instanceof ASTIdentifier) {
- ASTIdentifier id = (ASTIdentifier)origparams[i];
+ SimpleNode origparam = passThrough(origparams[i]);
+ if (origparam instanceof ASTIdentifier) {
+ ASTIdentifier id = (ASTIdentifier)origparam;
if (id.getEllipsis()) {
// Somewhat difficult to handle this case, and unknown
More information about the Laszlo-checkins
mailing list