You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2022/11/30 00:02:01 UTC
[royale-compiler] branch develop updated (4a6536f57 -> 0de1e9248)
This is an automated email from the ASF dual-hosted git repository.
joshtynjala pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
from 4a6536f57 Tests: more nullish coalescing operator tests
new 86b4fff6d null conditional operator (references #219)
new 0de1e9248 Tests: more tests for nullish coalescing
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../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 +++++++++++++++++++++
.../java/as/ASNullishCoalescingOperatorTests.java | 83 ++++++++-
...ionalOperatorTests_testEmptyString_swfdump.xml} | 74 ++++----
...ConditionalOperatorTests_testFalse_swfdump.xml} | 67 ++++----
...llConditionalOperatorTests_testNaN_swfdump.xml} | 69 ++++----
...nditionalOperatorTests_testNotNull_swfdump.xml} | 74 ++++----
...itionalOperatorTests_testNullField_swfdump.xml} | 74 ++++----
...lOperatorTests_testNullNestedField_swfdump.xml} | 89 +++++-----
...lConditionalOperatorTests_testNull_swfdump.xml} | 62 +++----
...alOperatorTests_testUndefinedField_swfdump.xml} | 70 ++++----
...atorTests_testUndefinedNestedField_swfdump.xml} | 87 +++++-----
...itionalOperatorTests_testUndefined_swfdump.xml} | 71 ++++----
...lConditionalOperatorTests_testZero_swfdump.xml} | 73 ++++----
...scingOperatorTests_testEmptyString_swfdump.xml} | 35 ++--
...hCoalescingOperatorTests_testFalse_swfdump.xml} | 36 ++--
...ishCoalescingOperatorTests_testNaN_swfdump.xml} | 38 ++---
...eratorTests_testNonNullMemberAccess_swfdump.xml | 72 ++++----
...CoalescingOperatorTests_testNonNull_swfdump.xml | 18 +-
...gOperatorTests_testNullMemberAccess_swfdump.xml | 72 ++++----
...ishCoalescingOperatorTests_testNull_swfdump.xml | 48 +++---
...lescingOperatorTests_testUndefined_swfdump.xml} | 40 +++--
...shCoalescingOperatorTests_testZero_swfdump.xml} | 40 +++--
28 files changed, 978 insertions(+), 597 deletions(-)
create mode 100644 compiler/src/test/java/as/ASNullConditionalOperatorTests.java
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullConditionalOperatorTests_testEmptyString_swfdump.xml} (78%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullConditionalOperatorTests_testFalse_swfdump.xml} (80%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullConditionalOperatorTests_testNaN_swfdump.xml} (79%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml => as_ASNullConditionalOperatorTests_testNotNull_swfdump.xml} (75%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml => as_ASNullConditionalOperatorTests_testNullField_swfdump.xml} (75%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullConditionalOperatorTests_testNullNestedField_swfdump.xml} (65%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml => as_ASNullConditionalOperatorTests_testNull_swfdump.xml} (80%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullConditionalOperatorTests_testUndefinedField_swfdump.xml} (77%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullConditionalOperatorTests_testUndefinedNestedField_swfdump.xml} (66%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml => as_ASNullConditionalOperatorTests_testUndefined_swfdump.xml} (77%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullConditionalOperatorTests_testZero_swfdump.xml} (78%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml => as_ASNullishCoalescingOperatorTests_testEmptyString_swfdump.xml} (84%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullishCoalescingOperatorTests_testFalse_swfdump.xml} (84%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullishCoalescingOperatorTests_testNaN_swfdump.xml} (84%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml => as_ASNullishCoalescingOperatorTests_testUndefined_swfdump.xml} (83%)
copy compiler/src/test/resources/swfdumps/{as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml => as_ASNullishCoalescingOperatorTests_testZero_swfdump.xml} (83%)
[royale-compiler] 01/02: null conditional operator (references #219)
Posted by jo...@apache.org.
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 <jo...@apache.org>
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>
[royale-compiler] 02/02: Tests: more tests for nullish coalescing
Posted by jo...@apache.org.
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 0de1e9248dd3c30de7b66e18ee84f192a8184bae
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Nov 29 15:55:59 2022 -0800
Tests: more tests for nullish coalescing
---
.../java/as/ASNullishCoalescingOperatorTests.java | 83 ++++++++++++++++++++--
...scingOperatorTests_testEmptyString_swfdump.xml} | 35 +++++----
...hCoalescingOperatorTests_testFalse_swfdump.xml} | 36 +++++-----
...ishCoalescingOperatorTests_testNaN_swfdump.xml} | 38 +++++-----
...eratorTests_testNonNullMemberAccess_swfdump.xml | 72 +++++++++----------
...CoalescingOperatorTests_testNonNull_swfdump.xml | 18 ++---
...gOperatorTests_testNullMemberAccess_swfdump.xml | 72 +++++++++----------
...ishCoalescingOperatorTests_testNull_swfdump.xml | 48 ++++++-------
...lescingOperatorTests_testUndefined_swfdump.xml} | 40 +++++------
...shCoalescingOperatorTests_testZero_swfdump.xml} | 40 +++++------
10 files changed, 275 insertions(+), 207 deletions(-)
diff --git a/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java b/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java
index 5e593120d..ae5d6d862 100644
--- a/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java
+++ b/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java
@@ -33,7 +33,7 @@ public class ASNullishCoalescingOperatorTests extends ASFeatureTestsBase
{
"var s:String = 'foo';",
"var result:Object = s ?? 'bar';",
- "assertEqual('non-null nullish coalescing', result, 'foo');",
+ "assertEqual('nullish coalescing', result, 'foo');",
};
String source = getAS(new String[0], new String[0], testCode, new String[0]);
@@ -47,7 +47,82 @@ public class ASNullishCoalescingOperatorTests extends ASFeatureTestsBase
{
"var s:String = null;",
"var result:Object = s ?? 'bar';",
- "assertEqual('non-null nullish coalescing', result, 'bar');",
+ "assertEqual('nullish coalescing', result, 'bar');",
+ };
+ String source = getAS(new String[0], new String[0], testCode, new String[0]);
+
+ compileAndRun(source);
+ }
+
+ // undefined is considered nullish
+ @Test
+ public void testUndefined()
+ {
+ String[] testCode = new String[]
+ {
+ "var o:* = undefined;",
+ "var result:* = o ?? 'bar';",
+ "assertEqual('nullish coalescing', result, 'bar');",
+ };
+ 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 ?? 'bar';",
+ "assertEqual('nullish coalescing', result, 0);",
+ };
+ 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:String = (o ?? 'bar').toString();",
+ "assertEqual('nullish coalescing', result, 'NaN');",
+ };
+ 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 ?? 'bar';",
+ "assertEqual('nullish coalescing', result, false);",
+ };
+ 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 ?? 'bar';",
+ "assertEqual('nullish coalescing', result, '');",
};
String source = getAS(new String[0], new String[0], testCode, new String[0]);
@@ -61,7 +136,7 @@ public class ASNullishCoalescingOperatorTests extends ASFeatureTestsBase
{
"var o:Object = {field: 'foo'};",
"var result:Object = o.field ?? 'bar';",
- "assertEqual('non-null nullish coalescing', result, 'foo');",
+ "assertEqual('nullish coalescing', result, 'foo');",
};
String source = getAS(new String[0], new String[0], testCode, new String[0]);
@@ -75,7 +150,7 @@ public class ASNullishCoalescingOperatorTests extends ASFeatureTestsBase
{
"var o:Object = {field: null};",
"var result:Object = o.field ?? 'bar';",
- "assertEqual('non-null nullish coalescing', result, 'bar');",
+ "assertEqual('nullish coalescing', result, 'bar');",
};
String source = getAS(new String[0], new String[0], testCode, new String[0]);
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testEmptyString_swfdump.xml
similarity index 84%
copy from compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml
copy to compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testEmptyString_swfdump.xml
index 61cb64e35..8aec7685b 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testEmptyString_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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=845 -->
+ <!-- framecount=1 length=830 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -67,17 +67,17 @@ public class %0 extends Object
// max_regs 4
// scope_depth 0
// max_scope 1
- // code_length 33
+ // code_length 31
bb0
succs=[bb1,bb2]
- 0 getlocal0
- 1 pushscope
- 2 pushstring "foo"
- 3 coerce_s
- 4 setlocal2
- 5 getlocal2
- 6 pushnull
- 7 ifeq bb2
+ 0 getlocal0
+ 1 pushscope
+ 2 pushstring ""
+ 3 coerce_s
+ 4 setlocal2
+ 5 getlocal2
+ 6 pushnull
+ 7 ifeq bb2
bb1
succs=[bb3]
8 getlocal2
@@ -87,14 +87,13 @@ public class %0 extends Object
10 pushstring "bar"
bb3
succs=[]
- 11 coerce Object
- 12 setlocal3
- 13 findpropstrict assertEqual
- 14 pushstring "non-null nullish coalescing"
- 15 getlocal3
- 16 pushstring "foo"
- 17 callpropvoid
- 18 returnvoid
+ 11 setlocal3
+ 12 findpropstrict assertEqual
+ 13 pushstring "nullish coalescing"
+ 14 getlocal3
+ 15 pushstring ""
+ 16 callpropvoid
+ 17 returnvoid
}
private function assertEqual(String,*,*):void
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testFalse_swfdump.xml
similarity index 84%
copy from compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
copy to compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testFalse_swfdump.xml
index ddda76026..2bfcef8b3 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testFalse_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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 -->
+ <!-- framecount=1 length=829 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -67,34 +67,32 @@ public class %0 extends Object
// max_regs 4
// scope_depth 0
// max_scope 1
- // code_length 32
+ // code_length 28
bb0
succs=[bb1,bb2]
0 getlocal0
1 pushscope
- 2 pushnull
- 3 coerce_s
- 4 setlocal2
- 5 getlocal2
- 6 pushnull
- 7 ifeq bb2
+ 2 pushfalse
+ 3 setlocal2
+ 4 getlocal2
+ 5 pushnull
+ 6 ifeq bb2
bb1
succs=[bb3]
- 8 getlocal2
- 9 jump bb3
+ 7 getlocal2
+ 8 jump bb3
bb2
succs=[bb3]
- 10 pushstring "bar"
+ 9 pushstring "bar"
bb3
succs=[]
- 11 coerce Object
- 12 setlocal3
- 13 findpropstrict assertEqual
- 14 pushstring "non-null nullish coalescing"
- 15 getlocal3
- 16 pushstring "bar"
- 17 callpropvoid
- 18 returnvoid
+ 10 setlocal3
+ 11 findpropstrict assertEqual
+ 12 pushstring "nullish coalescing"
+ 13 getlocal3
+ 14 pushfalse
+ 15 callpropvoid
+ 16 returnvoid
}
private function assertEqual(String,*,*):void
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNaN_swfdump.xml
similarity index 84%
copy from compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
copy to compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNaN_swfdump.xml
index ddda76026..fe2a172f7 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNaN_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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 -->
+ <!-- framecount=1 length=972 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -67,34 +67,34 @@ public class %0 extends Object
// max_regs 4
// scope_depth 0
// max_scope 1
- // code_length 32
+ // code_length 33
bb0
succs=[bb1,bb2]
0 getlocal0
1 pushscope
- 2 pushnull
- 3 coerce_s
- 4 setlocal2
- 5 getlocal2
- 6 pushnull
- 7 ifeq bb2
+ 2 pushnan
+ 3 setlocal2
+ 4 getlocal2
+ 5 pushnull
+ 6 ifeq bb2
bb1
succs=[bb3]
- 8 getlocal2
- 9 jump bb3
+ 7 getlocal2
+ 8 jump bb3
bb2
succs=[bb3]
- 10 pushstring "bar"
+ 9 pushstring "bar"
bb3
succs=[]
- 11 coerce Object
- 12 setlocal3
- 13 findpropstrict assertEqual
- 14 pushstring "non-null nullish coalescing"
- 15 getlocal3
- 16 pushstring "bar"
- 17 callpropvoid
- 18 returnvoid
+ 10 callproperty
+ 11 coerce_s
+ 12 setlocal3
+ 13 findpropstrict assertEqual
+ 14 pushstring "nullish coalescing"
+ 15 getlocal3
+ 16 pushstring "NaN"
+ 17 callpropvoid
+ 18 returnvoid
}
private function assertEqual(String,*,*):void
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNullMemberAccess_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNullMemberAccess_swfdump.xml
index fd988c26e..df294073a 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNullMemberAccess_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNullMemberAccess_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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=987 -->
+ <!-- framecount=1 length=975 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -44,12 +44,12 @@ public class %0 extends Object
public function %0():*
{
// derivedName %0
- // method_info 3
- // max_stack 1
- // max_regs 1
- // scope_depth 0
- // max_scope 1
- // code_length 6
+ // method_info 3
+ // max_stack 1
+ // max_regs 1
+ // scope_depth 0
+ // max_scope 1
+ // code_length 6
bb0
succs=[]
0 getlocal0
@@ -70,35 +70,35 @@ public class %0 extends Object
// code_length 42
bb0
succs=[bb1,bb2]
- 0 getlocal0
- 1 pushscope
- 2 pushstring "field"
- 3 pushstring "foo"
- 4 newobject 1
- 5 coerce Object
- 6 setlocal2
- 7 getlocal2
+ 0 getlocal0
+ 1 pushscope
+ 2 pushstring "field"
+ 3 pushstring "foo"
+ 4 newobject 1
+ 5 coerce Object
+ 6 setlocal2
+ 7 getlocal2
8 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::field
- 9 pushnull
- 10 ifeq bb2
+ 9 pushnull
+ 10 ifeq bb2
bb1
succs=[bb3]
- 11 getlocal2
+ 11 getlocal2
12 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::field
- 13 jump bb3
+ 13 jump bb3
bb2
succs=[bb3]
14 pushstring "bar"
bb3
succs=[]
- 15 coerce Object
- 16 setlocal3
- 17 findpropstrict assertEqual
- 18 pushstring "non-null nullish coalescing"
- 19 getlocal3
- 20 pushstring "foo"
- 21 callpropvoid
- 22 returnvoid
+ 15 coerce Object
+ 16 setlocal3
+ 17 findpropstrict assertEqual
+ 18 pushstring "nullish coalescing"
+ 19 getlocal3
+ 20 pushstring "foo"
+ 21 callpropvoid
+ 22 returnvoid
}
private function assertEqual(String,*,*):void
@@ -141,16 +141,16 @@ function script0$init():*
// code_length 14
bb0
succs=[]
- 0 getlocal0
- 1 pushscope
- 2 getscopeobject 0
- 3 getlex Object
- 4 dup
- 5 pushscope
- 6 newclass
- 7 popscope
+ 0 getlocal0
+ 1 pushscope
+ 2 getscopeobject 0
+ 3 getlex Object
+ 4 dup
+ 5 pushscope
+ 6 newclass
+ 7 popscope
8 initproperty %0
- 9 returnvoid
+ 9 returnvoid
}
</DoABC>
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml
index 61cb64e35..ed487a820 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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=845 -->
+ <!-- framecount=1 length=836 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -87,14 +87,14 @@ public class %0 extends Object
10 pushstring "bar"
bb3
succs=[]
- 11 coerce Object
- 12 setlocal3
- 13 findpropstrict assertEqual
- 14 pushstring "non-null nullish coalescing"
- 15 getlocal3
- 16 pushstring "foo"
- 17 callpropvoid
- 18 returnvoid
+ 11 coerce Object
+ 12 setlocal3
+ 13 findpropstrict assertEqual
+ 14 pushstring "nullish coalescing"
+ 15 getlocal3
+ 16 pushstring "foo"
+ 17 callpropvoid
+ 18 returnvoid
}
private function assertEqual(String,*,*):void
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNullMemberAccess_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNullMemberAccess_swfdump.xml
index 77c07c277..43432ef85 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNullMemberAccess_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNullMemberAccess_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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=979 -->
+ <!-- framecount=1 length=973 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -44,12 +44,12 @@ public class %0 extends Object
public function %0():*
{
// derivedName %0
- // method_info 3
- // max_stack 1
- // max_regs 1
- // scope_depth 0
- // max_scope 1
- // code_length 6
+ // method_info 3
+ // max_stack 1
+ // max_regs 1
+ // scope_depth 0
+ // max_scope 1
+ // code_length 6
bb0
succs=[]
0 getlocal0
@@ -70,35 +70,35 @@ public class %0 extends Object
// code_length 41
bb0
succs=[bb1,bb2]
- 0 getlocal0
- 1 pushscope
- 2 pushstring "field"
- 3 pushnull
- 4 newobject 1
- 5 coerce Object
- 6 setlocal2
- 7 getlocal2
+ 0 getlocal0
+ 1 pushscope
+ 2 pushstring "field"
+ 3 pushnull
+ 4 newobject 1
+ 5 coerce Object
+ 6 setlocal2
+ 7 getlocal2
8 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::field
- 9 pushnull
- 10 ifeq bb2
+ 9 pushnull
+ 10 ifeq bb2
bb1
succs=[bb3]
- 11 getlocal2
+ 11 getlocal2
12 getproperty {private, %0, %0, Object, , , private, http://adobe.com/AS3/2006/builtin, }::field
- 13 jump bb3
+ 13 jump bb3
bb2
succs=[bb3]
14 pushstring "bar"
bb3
succs=[]
- 15 coerce Object
- 16 setlocal3
- 17 findpropstrict assertEqual
- 18 pushstring "non-null nullish coalescing"
- 19 getlocal3
- 20 pushstring "bar"
- 21 callpropvoid
- 22 returnvoid
+ 15 coerce Object
+ 16 setlocal3
+ 17 findpropstrict assertEqual
+ 18 pushstring "nullish coalescing"
+ 19 getlocal3
+ 20 pushstring "bar"
+ 21 callpropvoid
+ 22 returnvoid
}
private function assertEqual(String,*,*):void
@@ -141,16 +141,16 @@ function script0$init():*
// code_length 14
bb0
succs=[]
- 0 getlocal0
- 1 pushscope
- 2 getscopeobject 0
- 3 getlex Object
- 4 dup
- 5 pushscope
- 6 newclass
- 7 popscope
+ 0 getlocal0
+ 1 pushscope
+ 2 getscopeobject 0
+ 3 getlex Object
+ 4 dup
+ 5 pushscope
+ 6 newclass
+ 7 popscope
8 initproperty %0
- 9 returnvoid
+ 9 returnvoid
}
</DoABC>
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
index ddda76026..0f2b971d3 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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 -->
+ <!-- framecount=1 length=829 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -44,12 +44,12 @@ public class %0 extends Object
public function %0():*
{
// derivedName %0
- // method_info 3
- // max_stack 1
- // max_regs 1
- // scope_depth 0
- // max_scope 1
- // code_length 6
+ // method_info 3
+ // max_stack 1
+ // max_regs 1
+ // scope_depth 0
+ // max_scope 1
+ // code_length 6
bb0
succs=[]
0 getlocal0
@@ -87,14 +87,14 @@ public class %0 extends Object
10 pushstring "bar"
bb3
succs=[]
- 11 coerce Object
- 12 setlocal3
- 13 findpropstrict assertEqual
- 14 pushstring "non-null nullish coalescing"
- 15 getlocal3
- 16 pushstring "bar"
- 17 callpropvoid
- 18 returnvoid
+ 11 coerce Object
+ 12 setlocal3
+ 13 findpropstrict assertEqual
+ 14 pushstring "nullish coalescing"
+ 15 getlocal3
+ 16 pushstring "bar"
+ 17 callpropvoid
+ 18 returnvoid
}
private function assertEqual(String,*,*):void
@@ -137,16 +137,16 @@ function script0$init():*
// code_length 14
bb0
succs=[]
- 0 getlocal0
- 1 pushscope
- 2 getscopeobject 0
- 3 getlex Object
- 4 dup
- 5 pushscope
- 6 newclass
- 7 popscope
+ 0 getlocal0
+ 1 pushscope
+ 2 getscopeobject 0
+ 3 getlex Object
+ 4 dup
+ 5 pushscope
+ 6 newclass
+ 7 popscope
8 initproperty %0
- 9 returnvoid
+ 9 returnvoid
}
</DoABC>
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testUndefined_swfdump.xml
similarity index 83%
copy from compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
copy to compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testUndefined_swfdump.xml
index ddda76026..4503515e9 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNull_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testUndefined_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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 -->
+ <!-- framecount=1 length=830 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -67,34 +67,32 @@ public class %0 extends Object
// max_regs 4
// scope_depth 0
// max_scope 1
- // code_length 32
+ // code_length 29
bb0
succs=[bb1,bb2]
- 0 getlocal0
- 1 pushscope
- 2 pushnull
- 3 coerce_s
- 4 setlocal2
- 5 getlocal2
- 6 pushnull
- 7 ifeq bb2
+ 0 getlocal0
+ 1 pushscope
+ 2 pushundefined
+ 3 setlocal2
+ 4 getlocal2
+ 5 pushnull
+ 6 ifeq bb2
bb1
succs=[bb3]
- 8 getlocal2
- 9 jump bb3
+ 7 getlocal2
+ 8 jump bb3
bb2
succs=[bb3]
- 10 pushstring "bar"
+ 9 pushstring "bar"
bb3
succs=[]
- 11 coerce Object
- 12 setlocal3
- 13 findpropstrict assertEqual
- 14 pushstring "non-null nullish coalescing"
- 15 getlocal3
- 16 pushstring "bar"
- 17 callpropvoid
- 18 returnvoid
+ 10 setlocal3
+ 11 findpropstrict assertEqual
+ 12 pushstring "nullish coalescing"
+ 13 getlocal3
+ 14 pushstring "bar"
+ 15 callpropvoid
+ 16 returnvoid
}
private function assertEqual(String,*,*):void
diff --git a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testZero_swfdump.xml
similarity index 83%
copy from compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml
copy to compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testZero_swfdump.xml
index 61cb64e35..d99e2537e 100644
--- a/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testNonNull_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASNullishCoalescingOperatorTests_testZero_swfdump.xml
@@ -19,7 +19,7 @@
-->
<!-- 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=845 -->
+ <!-- framecount=1 length=837 -->
<FileAttributes useDirectBlit="false" useGPU="false" hasMetadata="true" actionScript3="true" suppressCrossDomainCaching="false" swfRelativeUrls="false" useNetwork="true"/>
<Metadata>
<![CDATA[<?xml version="1.0" ?>
@@ -67,34 +67,32 @@ public class %0 extends Object
// max_regs 4
// scope_depth 0
// max_scope 1
- // code_length 33
+ // code_length 30
bb0
succs=[bb1,bb2]
- 0 getlocal0
- 1 pushscope
- 2 pushstring "foo"
- 3 coerce_s
- 4 setlocal2
- 5 getlocal2
- 6 pushnull
- 7 ifeq bb2
+ 0 getlocal0
+ 1 pushscope
+ 2 pushdouble
+ 3 setlocal2
+ 4 getlocal2
+ 5 pushnull
+ 6 ifeq bb2
bb1
succs=[bb3]
- 8 getlocal2
- 9 jump bb3
+ 7 getlocal2
+ 8 jump bb3
bb2
succs=[bb3]
- 10 pushstring "bar"
+ 9 pushstring "bar"
bb3
succs=[]
- 11 coerce Object
- 12 setlocal3
- 13 findpropstrict assertEqual
- 14 pushstring "non-null nullish coalescing"
- 15 getlocal3
- 16 pushstring "foo"
- 17 callpropvoid
- 18 returnvoid
+ 10 setlocal3
+ 11 findpropstrict assertEqual
+ 12 pushstring "nullish coalescing"
+ 13 getlocal3
+ 14 pushbyte 0
+ 15 callpropvoid
+ 16 returnvoid
}
private function assertEqual(String,*,*):void