You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/11/03 20:14:25 UTC
git commit: [flex-falcon] [refs/heads/develop] - add parens when
calling new on the result of a function call instead of new on a constructor
function
Repository: flex-falcon
Updated Branches:
refs/heads/develop 1aef32d64 -> 5b40806dd
add parens when calling new on the result of a function call instead of new on a constructor function
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5b40806d
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5b40806d
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5b40806d
Branch: refs/heads/develop
Commit: 5b40806ddc4b62faef62db2e44d30b3479240bd8
Parents: 1aef32d
Author: Alex Harui <ah...@apache.org>
Authored: Tue Nov 3 11:14:19 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Nov 3 11:14:19 2015 -0800
----------------------------------------------------------------------
.../internal/codegen/js/jx/FunctionCallEmitter.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5b40806d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
index 9f616c0..e531787 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
@@ -36,6 +36,7 @@ import org.apache.flex.compiler.internal.tree.as.VectorLiteralNode;
import org.apache.flex.compiler.projects.ICompilerProject;
import org.apache.flex.compiler.tree.ASTNodeID;
import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
import org.apache.flex.compiler.tree.as.IFunctionCallNode;
import org.apache.flex.compiler.utils.NativeUtils;
@@ -104,8 +105,19 @@ public class FunctionCallEmitter extends JSSubEmitter implements ISubEmitter<IFu
if (def instanceof ClassDefinition)
write(getEmitter().formatQualifiedName(def.getQualifiedName()));
else
+ {
+ IExpressionNode nameNode = node.getNameNode();
+ // wrap "new someFunctionCall(args)" in parens so the
+ // function call gets parsed and evaluated before new
+ // otherwise it just looks like any other "new function"
+ // in JS.
+ if (nameNode.getNodeID() == ASTNodeID.FunctionCallID)
+ write(ASEmitterTokens.PAREN_OPEN);
// I think we still need this for "new someVarOfTypeClass"
- getEmitter().getWalker().walk(node.getNameNode());
+ getEmitter().getWalker().walk(nameNode);
+ if (nameNode.getNodeID() == ASTNodeID.FunctionCallID)
+ write(ASEmitterTokens.PAREN_CLOSE);
+ }
write(ASEmitterTokens.PAREN_OPEN);
fjs.walkArguments(node.getArgumentNodes());
write(ASEmitterTokens.PAREN_CLOSE);