merge defineProp work into develop branch. FLEX-34771 breaks and will be fixed in next commit
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/4d501de5 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/4d501de5 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/4d501de5 Branch: refs/heads/develop Commit: 4d501de58344108b8e910e122febbdde2f4f45c9 Parents: c899a8d b974c9a Author: Alex Harui <[email protected]> Authored: Wed Apr 8 08:00:36 2015 -0700 Committer: Alex Harui <[email protected]> Committed: Wed Apr 8 08:00:36 2015 -0700 ---------------------------------------------------------------------- .../js/flexjs/TestFlexJSAccessorMembers.java | 71 +- .../codegen/js/flexjs/TestFlexJSAccessors.java | 8 +- .../codegen/js/flexjs/TestFlexJSClass.java | 8 +- .../js/flexjs/TestFlexJSExpressions.java | 50 +- .../codegen/js/flexjs/TestFlexJSInterface.java | 6 +- .../internal/codegen/js/goog/TestGoogClass.java | 14 +- .../codegen/js/goog/TestGoogEmiter.java | 2 +- .../flexjs/files/FlexJSTest_again_result.js | 92 +- .../flexjs/files/MyInitialView_result.js | 411 ++++----- .../files/controllers/MyController_result.js | 18 +- .../flexjs/files/models/MyModel_result.js | 55 +- .../projects/interfaces/interfaces/IE_result.js | 20 +- .../flexjs/projects/super/Base_result.js | 29 +- .../flexjs/projects/super/Super_result.js | 25 +- .../test-files/goog/files/call-super_result.js | 4 +- .../test-files/goog/files/output.js | 2 +- .../test-files/goog/files/poc_result.js | 2 +- .../goog/files/qualify-new-object_result.js | 2 +- .../compiler/internal/codegen/as/ASEmitter.java | 6 + .../internal/codegen/js/JSEmitterTokens.java | 1 + .../codegen/js/flexjs/JSFlexJSEmitter.java | 913 ++++++++++++------- .../js/flexjs/JSFlexJSEmitterTokens.java | 2 + .../internal/codegen/js/goog/JSGoogEmitter.java | 34 +- .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java | 92 +- .../mxml/flexjs/MXMLFlexJSPublisher.java | 56 +- .../compiler/internal/graph/GoogDepsWriter.java | 156 +++- .../apache/flex/compiler/utils/ASNodeUtils.java | 5 +- .../utils/JSClosureCompilerWrapper.java | 17 +- .../utils/VF2JSClosureCompilerWrapper.java | 2 +- 29 files changed, 1247 insertions(+), 856 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4d501de5/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java ---------------------------------------------------------------------- diff --cc compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java index 7968c21,51a3510..d78c83f --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java @@@ -752,107 -948,10 +949,11 @@@ public class JSFlexJSEmitter extends JS } } - IDefinition parentDef = (nodeDef != null) ? nodeDef.getParent() : null; - boolean isNative = (parentDef != null) - && NativeUtils.isNative(parentDef.getBaseName()); - if ((identifierIsAccessorFunction && !isNative) - || (nodeDef instanceof VariableDefinition && ((VariableDefinition) nodeDef) - .isBindable())) - { - IASNode anode = node - .getAncestorOfType(BinaryOperatorAssignmentNode.class); - - boolean isAssignment = false; - if (anode != null) - { - IASNode leftNode = anode.getChild(0); - if (anode == parentNode) - { - if (node == leftNode) - isAssignment = true; - } - else - { - IASNode pnode = parentNode; - IASNode thisNode = node; - while (anode != pnode) - { - if (pnode instanceof IMemberAccessExpressionNode) - { - if (thisNode != pnode.getChild(1)) - { - // can't be an assignment because - // we're on the left side of a memberaccessexpression - break; - } - } - if (pnode instanceof IDynamicAccessNode) - { - if (thisNode != pnode.getChild(1)) - { - // can't be an assignment because - // we're on the left side of a DynamicAccessNode - break; - } - } - if (pnode == leftNode) - { - isAssignment = true; - } - thisNode = pnode; - pnode = pnode.getParent(); - } - } - String op = ((IBinaryOperatorNode) anode).getOperator() - .getOperatorText(); - if (op.contains("==") || !op.contains("=")) - isAssignment = false; - } - - if (parentNode.getNodeID() == ASTNodeID.MemberAccessExpressionID - && parentNode.getChild(0).getNodeID() == ASTNodeID.SuperID) - { - IClassNode cnode = (IClassNode) node - .getAncestorOfType(IClassNode.class); - - // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation - if (cnode == null && MXMLJSC.jsOutputType == JSOutputType.VF2JS) - return; - - if (cnode == null && thisClass != null) - write(formatQualifiedName(thisClass.getQualifiedName())); - else - write(formatQualifiedName(cnode.getQualifiedName())); - write(ASEmitterTokens.MEMBER_ACCESS); - write(JSGoogEmitterTokens.GOOG_BASE); - write(ASEmitterTokens.PAREN_OPEN); - write(ASEmitterTokens.THIS); - writeToken(ASEmitterTokens.COMMA); - write(ASEmitterTokens.SINGLE_QUOTE); - writeGetSetPrefix(!isAssignment); - write(nodeDef.getQualifiedName()); - write(ASEmitterTokens.SINGLE_QUOTE); - if (isAssignment) - { - writeToken(ASEmitterTokens.COMMA); - } - } - else - { - writeGetSetPrefix(!isAssignment); - write(node.getName()); - write(ASEmitterTokens.PAREN_OPEN); - } + - if (anode != null && isAssignment) - { - getWalker().walk(((BinaryOperatorAssignmentNode) anode) - .getRightOperandNode()); - } - - write(ASEmitterTokens.PAREN_CLOSE); - } - else if (emitName) + //IDefinition parentDef = (nodeDef != null) ? nodeDef.getParent() : null; + //boolean isNative = (parentDef != null) + // && NativeUtils.isNative(parentDef.getBaseName()); + if (emitName) { if (nodeDef != null) write(formatQualifiedName(nodeDef.getQualifiedName())); @@@ -882,102 -974,81 +976,84 @@@ if (fnode == null) fnode = (IFunctionNode) fcnode .getAncestorOfType(IFunctionNode.class); - } - - if (fnode != null && fnode.isConstructor() && !hasSuperClass(fnode)) - return; - - IClassNode cnode = (IClassNode) node - .getAncestorOfType(IClassNode.class); - // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation - if (cnode == null && MXMLJSC.jsOutputType == JSOutputType.VF2JS) - return; - - if (cnode == null && thisClass != null) - write(formatQualifiedName(thisClass.getQualifiedName())); - else - write(formatQualifiedName(cnode.getQualifiedName())); - write(ASEmitterTokens.MEMBER_ACCESS); - write(JSGoogEmitterTokens.GOOG_BASE); - write(ASEmitterTokens.PAREN_OPEN); - write(ASEmitterTokens.THIS); - - if (fnode != null && fnode.isConstructor()) - { - writeToken(ASEmitterTokens.COMMA); - write(ASEmitterTokens.SINGLE_QUOTE); - write(JSGoogEmitterTokens.GOOG_CONSTRUCTOR); - write(ASEmitterTokens.SINGLE_QUOTE); - } - - if (fnode != null && !fnode.isConstructor()) - { - writeToken(ASEmitterTokens.COMMA); - write(ASEmitterTokens.SINGLE_QUOTE); - if (fnode.getNodeID() == ASTNodeID.GetterID - || fnode.getNodeID() == ASTNodeID.SetterID) - writeGetSetPrefix(fnode.getNodeID() == ASTNodeID.GetterID); - write(fnode.getName()); - write(ASEmitterTokens.SINGLE_QUOTE); - } - - IASNode[] anodes = null; - boolean writeArguments = false; - if (fcnode != null) - { - anodes = fcnode.getArgumentNodes(); - - writeArguments = anodes.length > 0; - } - else if (fnode != null && fnode.isConstructor()) - { - anodes = fnode.getParameterNodes(); - - writeArguments = (anodes != null && anodes.length > 0); - } - else if (fnode == null && node instanceof BinaryOperatorAssignmentNode) - { - BinaryOperatorAssignmentNode bnode = (BinaryOperatorAssignmentNode) node; - - IFunctionNode pnode = (IFunctionNode) bnode.getAncestorOfType(IFunctionNode.class); - - if (pnode.getNodeID() == ASTNodeID.SetterID) - { - writeToken(ASEmitterTokens.COMMA); - write(ASEmitterTokens.SINGLE_QUOTE); - writeGetSetPrefix(false); - getWalker().walk(bnode.getLeftOperandNode()); - write(ASEmitterTokens.SINGLE_QUOTE); - writeToken(ASEmitterTokens.COMMA); - getWalker().walk(bnode.getRightOperandNode()); - } - } - - if (writeArguments) - { - int len = anodes.length; - for (int i = 0; i < len; i++) - { - writeToken(ASEmitterTokens.COMMA); - - getWalker().walk(anodes[i]); - } - } - - write(ASEmitterTokens.PAREN_CLOSE); + if (fnode != null && fnode.isConstructor() && !hasSuperClass(fnode)) + return; - if (type == CONSTRUCTOR_FULL) - { - write(ASEmitterTokens.SEMICOLON); - writeNewline(); - } - else if (type == CONSTRUCTOR_EMPTY) - { - write(ASEmitterTokens.SEMICOLON); + IClassNode cnode = (IClassNode) node + .getAncestorOfType(IClassNode.class); + + // ToDo (erikdebruin): add VF2JS conditional -> only use check during full SDK compilation - if (cnode == null) ++ if (cnode == null && MXMLJSC.jsOutputType == JSOutputType.VF2JS) + return; + + if (fnode != null && (fnode.getNodeID() == ASTNodeID.GetterID + || fnode.getNodeID() == ASTNodeID.SetterID)) + { + write(JSFlexJSEmitterTokens.LANGUAGE_QNAME); + write(ASEmitterTokens.MEMBER_ACCESS); + if (fnode.getNodeID() == ASTNodeID.GetterID) + write(JSFlexJSEmitterTokens.SUPERGETTER); + else + write(JSFlexJSEmitterTokens.SUPERSETTER); + write(ASEmitterTokens.PAREN_OPEN); - write(formatQualifiedName(cnode.getQualifiedName())); ++ if (cnode == null && thisClass != null) ++ write(formatQualifiedName(thisClass.getQualifiedName())); ++ else ++ write(formatQualifiedName(cnode.getQualifiedName())); + writeToken(ASEmitterTokens.COMMA); + write(ASEmitterTokens.THIS); + writeToken(ASEmitterTokens.COMMA); + write(ASEmitterTokens.SINGLE_QUOTE); + write(fnode.getName()); + write(ASEmitterTokens.SINGLE_QUOTE); + + IASNode[] anodes = null; + boolean writeArguments = false; + if (fcnode != null) + { + anodes = fcnode.getArgumentNodes(); + + writeArguments = anodes.length > 0; + } + else if (fnode != null && fnode.isConstructor()) + { + anodes = fnode.getParameterNodes(); + + writeArguments = (anodes != null && anodes.length > 0); + } + else if (fnode == null && node instanceof BinaryOperatorAssignmentNode) + { + BinaryOperatorAssignmentNode bnode = (BinaryOperatorAssignmentNode) node; + + IFunctionNode pnode = (IFunctionNode) bnode.getAncestorOfType(IFunctionNode.class); + + if (pnode.getNodeID() == ASTNodeID.SetterID) + { + writeToken(ASEmitterTokens.COMMA); + getWalker().walk(bnode.getRightOperandNode()); + } + } + + if (writeArguments) + { + int len = anodes.length; + for (int i = 0; i < len; i++) + { + writeToken(ASEmitterTokens.COMMA); + + getWalker().walk(anodes[i]); + } + } + + write(ASEmitterTokens.PAREN_CLOSE); + return; + } } + super.emitSuperCall(node, type); } - + + /* @Override protected void emitDefaultParameterCodeBlock(IFunctionNode node) {
