This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit 86b4fff6dec364c7c1dd7714638d13020156c3d1 Author: Josh Tynjala <[email protected]> AuthorDate: Wed Nov 9 14:44:12 2022 -0800 null conditional operator (references #219) --- .../royale/compiler/internal/parsing/as/ASParser.g | 5 + .../compiler/internal/parsing/as/ASToken.java | 1 + .../compiler/internal/parsing/as/BaseASParser.java | 75 +++++++++ .../internal/parsing/as/StreamingASTokenizer.java | 1 + .../tree/as/MemberAccessExpressionNode.java | 9 +- .../internal/parsing/as/RawASTokenizer.lex | 5 + .../java/as/ASNullConditionalOperatorTests.java | 187 +++++++++++++++++++++ ...tionalOperatorTests_testEmptyString_swfdump.xml | 159 ++++++++++++++++++ ...lConditionalOperatorTests_testFalse_swfdump.xml | 158 +++++++++++++++++ ...ullConditionalOperatorTests_testNaN_swfdump.xml | 158 +++++++++++++++++ ...onditionalOperatorTests_testNotNull_swfdump.xml | 159 ++++++++++++++++++ ...ditionalOperatorTests_testNullField_swfdump.xml | 159 ++++++++++++++++++ ...alOperatorTests_testNullNestedField_swfdump.xml | 170 +++++++++++++++++++ ...llConditionalOperatorTests_testNull_swfdump.xml | 157 +++++++++++++++++ ...nalOperatorTests_testUndefinedField_swfdump.xml | 157 +++++++++++++++++ ...ratorTests_testUndefinedNestedField_swfdump.xml | 168 ++++++++++++++++++ ...ditionalOperatorTests_testUndefined_swfdump.xml | 156 +++++++++++++++++ ...llConditionalOperatorTests_testZero_swfdump.xml | 158 +++++++++++++++++ 18 files changed, 2041 insertions(+), 1 deletion(-) diff --git a/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g b/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g index 552fd3c6c..90432099a 100644 --- a/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g +++ b/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g @@ -3095,6 +3095,7 @@ xmlAttributeName returns [ExpressionNodeBase result] * foo::bar * foo[bar] * foo.<bar> + * foo?.bar */ propertyAccessExpression [ExpressionNodeBase l] returns [ExpressionNodeBase n] { @@ -3106,6 +3107,10 @@ propertyAccessExpression [ExpressionNodeBase l] returns [ExpressionNodeBase n] { n = new MemberAccessExpressionNode(l, op, r); } | TOKEN_OPERATOR_DESCENDANT_ACCESS r=accessPart { n = new MemberAccessExpressionNode(l, op, r); } + | TOKEN_OPERATOR_NULL_CONDITIONAL_ACCESS r=accessPart + { + n = transformNullConditional(l, op, r); + } | TOKEN_OPERATOR_NS_QUALIFIER r=nsAccessPart { if (l instanceof NamespaceIdentifierNode) { diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ASToken.java b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ASToken.java index 9d2d592b8..de34ff3f8 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ASToken.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ASToken.java @@ -374,6 +374,7 @@ public class ASToken extends TokenBase implements IASToken, ASTokenTypes case TOKEN_OPERATOR_ATSIGN: case TOKEN_OPERATOR_DESCENDANT_ACCESS: case TOKEN_OPERATOR_NULLISH_COALESCING: + case TOKEN_OPERATOR_NULL_CONDITIONAL_ACCESS: return true; default: return false; diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/BaseASParser.java b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/BaseASParser.java index 99bcb31c8..9a647b3da 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/BaseASParser.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/BaseASParser.java @@ -73,6 +73,7 @@ import org.apache.royale.compiler.internal.scopes.ASScope; import org.apache.royale.compiler.internal.semantics.PostProcessStep; import org.apache.royale.compiler.internal.tree.as.ArrayLiteralNode; import org.apache.royale.compiler.internal.tree.as.BaseDefinitionNode; +import org.apache.royale.compiler.internal.tree.as.BinaryOperatorEqualNode; import org.apache.royale.compiler.internal.tree.as.BinaryOperatorNodeBase; import org.apache.royale.compiler.internal.tree.as.BinaryOperatorNotEqualNode; import org.apache.royale.compiler.internal.tree.as.BlockNode; @@ -3145,6 +3146,80 @@ abstract class BaseASParser extends LLkParser implements IProblemReporter ASToken ternaryOp = new ASToken(ASTokenTypes.TOKEN_OPERATOR_TERNARY, -1, -1, -1, -1, "?"); TernaryOperatorNode ternaryNode = new TernaryOperatorNode(ternaryOp, conditionalNode, left, right); + + return ternaryNode; + } + + private class NullConditionalTernaryOperatorNode extends TernaryOperatorNode + { + public NullConditionalTernaryOperatorNode(IASToken op, ExpressionNodeBase conditionalNode, ExpressionNodeBase leftOperandNode, ExpressionNodeBase rightOperandNode) + { + super(op, conditionalNode, leftOperandNode, rightOperandNode); + } + } + + private final NullConditionalTernaryOperatorNode nestNullConditional(NullConditionalTernaryOperatorNode l, ASToken op, ExpressionNodeBase r) + { + // we'll keep using this for the outer condition + ExpressionNodeBase prevConditionNode = (ExpressionNodeBase) l.getConditionalNode(); + // this is the expression where we know everything's not null + ExpressionNodeBase prevRightNode = (ExpressionNodeBase) l.getRightOperandNode(); + + ASToken innerConditionEqualToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_EQUAL, -1, -1, -1, -1, "=="); + ASToken innerConditionNullToken = new ASToken(ASTokenTypes.TOKEN_KEYWORD_NULL, -1, -1, -1, -1, "null"); + LiteralNode innerConditionNullNode = new LiteralNode(innerConditionNullToken, LiteralType.NULL); + BinaryOperatorEqualNode innerConditionNode = new BinaryOperatorEqualNode(innerConditionEqualToken, prevRightNode, innerConditionNullNode); + + NullConditionalTernaryOperatorNode innerTernaryNode = null; + if (prevRightNode instanceof NullConditionalTernaryOperatorNode) + { + // recursively convert nested null conditionals + innerTernaryNode = nestNullConditional((NullConditionalTernaryOperatorNode) prevRightNode, op, r); + } + else + { + ASToken memberAccessOperator = new ASToken(ASTokenTypes.TOKEN_OPERATOR_MEMBER_ACCESS, op.getStart(), op.getEnd(), op.getLine(), op.getColumn(), "."); + MemberAccessExpressionNode memberAccessNode = new MemberAccessExpressionNode(prevRightNode, memberAccessOperator, r); + memberAccessNode.setAllowE4XFilter(false); + + ASToken ternaryOperator = new ASToken(ASTokenTypes.TOKEN_OPERATOR_TERNARY, -1, -1, -1, -1, "?"); + ASToken innerResultNullToken = new ASToken(ASTokenTypes.TOKEN_KEYWORD_NULL, -1, -1, -1, -1, "null"); + LiteralNode innerResultNullNode = new LiteralNode(innerResultNullToken, LiteralType.NULL); + innerTernaryNode = new NullConditionalTernaryOperatorNode(ternaryOperator, innerConditionNode, innerResultNullNode, memberAccessNode); + innerTernaryNode.setHasParenthesis(true); + } + + ExpressionNodeBase outerResultCondition = prevConditionNode; + ASToken outerTernaryOperator = new ASToken(ASTokenTypes.TOKEN_OPERATOR_TERNARY, -1, -1, -1, -1, "?"); + ASToken outerResultNullToken = new ASToken(ASTokenTypes.TOKEN_KEYWORD_NULL, -1, -1, -1, -1, "null"); + LiteralNode outerResultNullNode = new LiteralNode(outerResultNullToken, LiteralType.NULL); + NullConditionalTernaryOperatorNode outerTernaryNode = new NullConditionalTernaryOperatorNode(outerTernaryOperator, outerResultCondition, outerResultNullNode, innerTernaryNode); + outerTernaryNode.setHasParenthesis(true); + return outerTernaryNode; + } + + protected final ExpressionNodeBase transformNullConditional(ExpressionNodeBase l, ASToken op, ExpressionNodeBase r) + { + if (l instanceof NullConditionalTernaryOperatorNode) + { + return nestNullConditional((NullConditionalTernaryOperatorNode) l, op, r); + } + + ASToken conditionEqualToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_EQUAL, -1, -1, -1, -1, "=="); + ASToken conditionNullToken = new ASToken(ASTokenTypes.TOKEN_KEYWORD_NULL, -1, -1, -1, -1, "null"); + LiteralNode conditionNullNode = new LiteralNode(conditionNullToken, LiteralType.NULL); + BinaryOperatorEqualNode conditionNode = new BinaryOperatorEqualNode(conditionEqualToken, l, conditionNullNode); + + ASToken memberAccessOperator = new ASToken(ASTokenTypes.TOKEN_OPERATOR_MEMBER_ACCESS, op.getStart(), op.getEnd(), op.getLine(), op.getColumn(), "."); + MemberAccessExpressionNode memberAccessNode = new MemberAccessExpressionNode(l, memberAccessOperator, r); + memberAccessNode.setAllowE4XFilter(false); + + ASToken ternaryOperator = new ASToken(ASTokenTypes.TOKEN_OPERATOR_TERNARY, -1, -1, -1, -1, "?"); + ASToken resultNullToken = new ASToken(ASTokenTypes.TOKEN_KEYWORD_NULL, -1, -1, -1, -1, "null"); + LiteralNode resultNullNode = new LiteralNode(resultNullToken, LiteralType.NULL); + NullConditionalTernaryOperatorNode ternaryNode = new NullConditionalTernaryOperatorNode(ternaryOperator, conditionNode, resultNullNode, memberAccessNode); + ternaryNode.setHasParenthesis(true); + return ternaryNode; } } diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/StreamingASTokenizer.java b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/StreamingASTokenizer.java index 49f6242d2..d16f7cc6e 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/StreamingASTokenizer.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/StreamingASTokenizer.java @@ -1198,6 +1198,7 @@ public class StreamingASTokenizer implements ASTokenTypes, IASTokenizer, Closeab case TOKEN_E4X_BINDING_CLOSE: case TOKEN_E4X_BINDING_OPEN: case TOKEN_OPERATOR_DESCENDANT_ACCESS: + case TOKEN_OPERATOR_NULL_CONDITIONAL_ACCESS: case TOKEN_NAMESPACE_ANNOTATION: case TOKEN_NAMESPACE_NAME: case TOKEN_BLOCK_OPEN: diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/MemberAccessExpressionNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/MemberAccessExpressionNode.java index 42d77b8ff..59a7484db 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/MemberAccessExpressionNode.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/MemberAccessExpressionNode.java @@ -96,7 +96,7 @@ public class MemberAccessExpressionNode extends BinaryOperatorNodeBase implement { nodeID = ASTNodeID.Op_DescendantsID; } - else if (rightOperandNode != null && rightOperandNode.hasParenthesis()) + else if (allowE4XFilter && rightOperandNode != null && rightOperandNode.hasParenthesis()) { nodeID = ASTNodeID.E4XFilterID; } @@ -264,6 +264,13 @@ public class MemberAccessExpressionNode extends BinaryOperatorNodeBase implement // Other methods // + private boolean allowE4XFilter = true; + + public void setAllowE4XFilter(boolean allow) + { + allowE4XFilter = allow; + } + public boolean isSuper(ExpressionNodeBase node) { if (!(node instanceof ILanguageIdentifierNode)) diff --git a/compiler/src/main/jflex/org/apache/royale/compiler/internal/parsing/as/RawASTokenizer.lex b/compiler/src/main/jflex/org/apache/royale/compiler/internal/parsing/as/RawASTokenizer.lex index f21ae0d71..e4a0eee83 100644 --- a/compiler/src/main/jflex/org/apache/royale/compiler/internal/parsing/as/RawASTokenizer.lex +++ b/compiler/src/main/jflex/org/apache/royale/compiler/internal/parsing/as/RawASTokenizer.lex @@ -626,6 +626,11 @@ REGEX_CLASS="[" ({REGEX_ESCAPE}|[^\n\r\]\\])* "]" return buildToken(TOKEN_OPERATOR_DESCENDANT_ACCESS, ".."); } +<YYINITIAL> "?." +{ + return buildToken(TOKEN_OPERATOR_NULL_CONDITIONAL_ACCESS, "?."); +} + <YYINITIAL> "," { return buildToken(TOKEN_COMMA, ","); diff --git a/compiler/src/test/java/as/ASNullConditionalOperatorTests.java b/compiler/src/test/java/as/ASNullConditionalOperatorTests.java new file mode 100644 index 000000000..ed045b524 --- /dev/null +++ b/compiler/src/test/java/as/ASNullConditionalOperatorTests.java @@ -0,0 +1,187 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package as; + +import java.io.File; + +import org.junit.Assert; +import org.junit.Test; + +public class ASNullConditionalOperatorTests extends ASFeatureTestsBase +{ + @Test + public void testNull() + { + String[] testCode = new String[] + { + "var o:Object = null;", + "var result:* = o?.field;", + "assertEqual('null conditional', result, null);", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + // 0 is considered falsy, but not nullish + @Test + public void testUndefined() + { + String[] testCode = new String[] + { + "var o:* = undefined;", + "var result:* = o?.field;", + "assertEqual('null conditional', result, null);", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + // false is considered falsy, but not nullish + @Test + public void testFalse() + { + String[] testCode = new String[] + { + "var o:Boolean = false;", + "var result:* = o?.toString();", + "assertEqual('null conditional', result, 'false');", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + // NaN is considered falsy, but not nullish + @Test + public void testNaN() + { + String[] testCode = new String[] + { + "var o:Number = NaN;", + "var result:* = o?.toString();", + "assertEqual('null conditional', result, 'NaN');", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + // 0 is considered falsy, but not nullish + @Test + public void testZero() + { + String[] testCode = new String[] + { + "var o:Number = 0;", + "var result:* = o?.toString();", + "assertEqual('null conditional', result, '0');", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + // empty string is considered falsy, but not nullish + @Test + public void testEmptyString() + { + String[] testCode = new String[] + { + "var o:String = '';", + "var result:* = o?.toString();", + "assertEqual('null conditional', result, '');", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + @Test + public void testNotNull() + { + String[] testCode = new String[] + { + "var o:Object = {a: 123.4};", + "var result:* = o?.a;", + "assertEqual('null conditional', result, 123.4);", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + @Test + public void testNullField() + { + String[] testCode = new String[] + { + "var o:Object = {a: null};", + "var result:* = o?.a;", + "assertEqual('null conditional', result, null);", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + @Test + public void testUndefinedField() + { + String[] testCode = new String[] + { + "var o:Object = {};", + "var result:* = o?.a;", + "assertEqual('null conditional', result, undefined);", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + @Test + public void testNullNestedField() + { + String[] testCode = new String[] + { + "var o:Object = {a: null};", + "var result:* = o?.a?.b;", + "assertEqual('null conditional', result, null);", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } + + @Test + public void testUndefinedNestedField() + { + String[] testCode = new String[] + { + "var o:Object = {};", + "var result:* = o?.a?.b;", + "assertEqual('null conditional', result, null);", + }; + String source = getAS(new String[0], new String[0], testCode, new String[0]); + + compileAndRun(source); + } +} \ No newline at end of file diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testEmptyString_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testEmptyString_swfdump.xml new file mode 100644 index 000000000..af8db45d5 --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testEmptyString_swfdump.xml @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=838 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 35 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushstring "" + 3 coerce_s + 4 setlocal2 + 5 getlocal2 + 6 pushnull + 7 ifne bb2 + bb1 + succs=[bb3] + 8 pushnull + 9 jump bb3 + bb2 + succs=[bb3] + 10 getlocal2 + 11 getproperty toString + bb3 + succs=[] + 12 getlocal0 + 13 call 0 + 14 setlocal3 + 15 findpropstrict assertEqual + 16 pushstring "null conditional" + 17 getlocal3 + 18 pushstring "" + 19 callpropvoid + 20 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testFalse_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testFalse_swfdump.xml new file mode 100644 index 000000000..db160aaaf --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testFalse_swfdump.xml @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=842 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 33 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushfalse + 3 setlocal2 + 4 getlocal2 + 5 pushnull + 6 ifne bb2 + bb1 + succs=[bb3] + 7 pushnull + 8 jump bb3 + bb2 + succs=[bb3] + 9 getlocal2 + 10 getproperty toString + bb3 + succs=[] + 11 getlocal0 + 12 call 0 + 13 setlocal3 + 14 findpropstrict assertEqual + 15 pushstring "null conditional" + 16 getlocal3 + 17 pushstring "false" + 18 callpropvoid + 19 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNaN_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNaN_swfdump.xml new file mode 100644 index 000000000..dcbc1dea8 --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNaN_swfdump.xml @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=840 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 33 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushnan + 3 setlocal2 + 4 getlocal2 + 5 pushnull + 6 ifne bb2 + bb1 + succs=[bb3] + 7 pushnull + 8 jump bb3 + bb2 + succs=[bb3] + 9 getlocal2 + 10 getproperty toString + bb3 + succs=[] + 11 getlocal0 + 12 call 0 + 13 setlocal3 + 14 findpropstrict assertEqual + 15 pushstring "null conditional" + 16 getlocal3 + 17 pushstring "NaN" + 18 callpropvoid + 19 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNotNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNotNull_swfdump.xml new file mode 100644 index 000000000..70674c8f3 --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNotNull_swfdump.xml @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=961 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 37 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushstring "a" + 3 pushdouble + 4 newobject 1 + 5 coerce Object + 6 setlocal2 + 7 getlocal2 + 8 pushnull + 9 ifne bb2 + bb1 + succs=[bb3] + 10 pushnull + 11 jump bb3 + bb2 + succs=[bb3] + 12 getlocal2 + 13 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::a + bb3 + succs=[] + 14 setlocal3 + 15 findpropstrict assertEqual + 16 pushstring "null conditional" + 17 getlocal3 + 18 pushdouble + 19 callpropvoid + 20 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNullField_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNullField_swfdump.xml new file mode 100644 index 000000000..6e761eae4 --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNullField_swfdump.xml @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=951 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 35 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushstring "a" + 3 pushnull + 4 newobject 1 + 5 coerce Object + 6 setlocal2 + 7 getlocal2 + 8 pushnull + 9 ifne bb2 + bb1 + succs=[bb3] + 10 pushnull + 11 jump bb3 + bb2 + succs=[bb3] + 12 getlocal2 + 13 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::a + bb3 + succs=[] + 14 setlocal3 + 15 findpropstrict assertEqual + 16 pushstring "null conditional" + 17 getlocal3 + 18 pushnull + 19 callpropvoid + 20 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNullNestedField_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNullNestedField_swfdump.xml new file mode 100644 index 000000000..126257d0e --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNullNestedField_swfdump.xml @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=968 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 50 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushstring "a" + 3 pushnull + 4 newobject 1 + 5 coerce Object + 6 setlocal2 + 7 getlocal2 + 8 pushnull + 9 ifne bb2 + bb1 + succs=[bb5] + 10 pushnull + 11 jump bb5 + bb2 + succs=[bb3,bb4] + 12 getlocal2 + 13 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::a + 14 pushnull + 15 ifne bb4 + bb3 + succs=[bb5] + 16 pushnull + 17 jump bb5 + bb4 + succs=[bb5] + 18 getlocal2 + 19 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::a + 20 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::b + bb5 + succs=[] + 21 setlocal3 + 22 findpropstrict assertEqual + 23 pushstring "null conditional" + 24 getlocal3 + 25 pushnull + 26 callpropvoid + 27 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNull_swfdump.xml new file mode 100644 index 000000000..8ac55976c --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testNull_swfdump.xml @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=948 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 31 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushnull + 3 coerce Object + 4 setlocal2 + 5 getlocal2 + 6 pushnull + 7 ifne bb2 + bb1 + succs=[bb3] + 8 pushnull + 9 jump bb3 + bb2 + succs=[bb3] + 10 getlocal2 + 11 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::field + bb3 + succs=[] + 12 setlocal3 + 13 findpropstrict assertEqual + 14 pushstring "null conditional" + 15 getlocal3 + 16 pushnull + 17 callpropvoid + 18 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefinedField_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefinedField_swfdump.xml new file mode 100644 index 000000000..7d252d6d6 --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefinedField_swfdump.xml @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=948 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 32 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 newobject 0 + 3 coerce Object + 4 setlocal2 + 5 getlocal2 + 6 pushnull + 7 ifne bb2 + bb1 + succs=[bb3] + 8 pushnull + 9 jump bb3 + bb2 + succs=[bb3] + 10 getlocal2 + 11 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::a + bb3 + succs=[] + 12 setlocal3 + 13 findpropstrict assertEqual + 14 pushstring "null conditional" + 15 getlocal3 + 16 pushundefined + 17 callpropvoid + 18 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefinedNestedField_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefinedNestedField_swfdump.xml new file mode 100644 index 000000000..a271e0b5b --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefinedNestedField_swfdump.xml @@ -0,0 +1,168 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=965 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 47 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 newobject 0 + 3 coerce Object + 4 setlocal2 + 5 getlocal2 + 6 pushnull + 7 ifne bb2 + bb1 + succs=[bb5] + 8 pushnull + 9 jump bb5 + bb2 + succs=[bb3,bb4] + 10 getlocal2 + 11 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::a + 12 pushnull + 13 ifne bb4 + bb3 + succs=[bb5] + 14 pushnull + 15 jump bb5 + bb4 + succs=[bb5] + 16 getlocal2 + 17 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::a + 18 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::b + bb5 + succs=[] + 19 setlocal3 + 20 findpropstrict assertEqual + 21 pushstring "null conditional" + 22 getlocal3 + 23 pushnull + 24 callpropvoid + 25 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefined_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefined_swfdump.xml new file mode 100644 index 000000000..8659f1a5b --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testUndefined_swfdump.xml @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=943 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 29 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushundefined + 3 setlocal2 + 4 getlocal2 + 5 pushnull + 6 ifne bb2 + bb1 + succs=[bb3] + 7 pushnull + 8 jump bb3 + bb2 + succs=[bb3] + 9 getlocal2 + 10 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::field + bb3 + succs=[] + 11 setlocal3 + 12 findpropstrict assertEqual + 13 pushstring "null conditional" + 14 getlocal3 + 15 pushnull + 16 callpropvoid + 17 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf> diff --git a/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testZero_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testZero_swfdump.xml new file mode 100644 index 000000000..9bb903a5c --- /dev/null +++ b/compiler/src/test/resources/swfdumps/as_ASNullConditionalOperatorTests_testZero_swfdump.xml @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<!-- Parsing swf file:/Users/joshtynjala/Development/apache/royale-compiler/compiler/target/junit-temp/%0.swf --> +<swf xmlns="http://macromedia/2003/swfx" version="14" framerate="24.0" size="10000x7500" compressed="true" > + <!-- framecount=1 length=847 --> + <FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/> + <Metadata> + <![CDATA[<?xml version="1.0" ?> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1" xmlns:asc="http://ns.adobe.com/asc/2012"> + <dc:format>application/x-shockwave-flash</dc:format> + <asc:compiler name="Apache Royale Compiler" version="0.9.10" build="0"/> + </rdf:Description> +</rdf:RDF> +]]> + </Metadata> + <SetBackgroundColor color="#FFFFFF"/> + <ScriptLimits scriptRecursionLimit="1000" scriptTimeLimit="60"/> + <DoABC> +// script 0 + +// class_id=0 slot_id=0 +public class %0 extends Object +{ + + // method_id=3 + public function %0():* + { + // derivedName %0 + // method_info 3 + // max_stack 1 + // max_regs 1 + // scope_depth 0 + // max_scope 1 + // code_length 6 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getlocal0 + 3 constructsuper 0 + 4 returnvoid + } + + private function initHandler(Object):void + { + // derivedName initHandler + // method_info 1 + // max_stack 4 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 34 + bb0 + succs=[bb1,bb2] + 0 getlocal0 + 1 pushscope + 2 pushdouble + 3 setlocal2 + 4 getlocal2 + 5 pushnull + 6 ifne bb2 + bb1 + succs=[bb3] + 7 pushnull + 8 jump bb3 + bb2 + succs=[bb3] + 9 getlocal2 + 10 getproperty toString + bb3 + succs=[] + 11 getlocal0 + 12 call 0 + 13 setlocal3 + 14 findpropstrict assertEqual + 15 pushstring "null conditional" + 16 getlocal3 + 17 pushstring "0" + 18 callpropvoid + 19 returnvoid + } + + private function assertEqual(String,*,*):void + { + // derivedName assertEqual + // method_info 2 + // max_stack 1 + // max_regs 4 + // scope_depth 0 + // max_scope 1 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } + + public static function %0$():* + { + // derivedName null + // method_info 4 + // max_stack 0 + // max_regs 1 + // scope_depth 0 + // max_scope 0 + // code_length 1 + bb0 + succs=[] + 0 returnvoid + } +} + +function script0$init():* +{ + // derivedName null + // method_info 0 + // max_stack 3 + // max_regs 1 + // scope_depth 0 + // max_scope 2 + // code_length 14 + bb0 + succs=[] + 0 getlocal0 + 1 pushscope + 2 getscopeobject 0 + 3 getlex Object + 4 dup + 5 pushscope + 6 newclass + 7 popscope + 8 initproperty %0 + 9 returnvoid +} + + </DoABC> + <SymbolClass> + <Symbol idref="0" className="%0" /> + </SymbolClass> + <ShowFrame/> +</swf>
