externc: fixed value of undefined (should not be 0), and added similar special treatment for NaN and Infinity
diff --git a/compiler-externc/src/main/java/org/apache/royale/compiler/internal/codegen/typedefs/reference/ConstantReference.java b/compiler-externc/src/main/java/org/apache/royale/compiler/internal/codegen/typedefs/reference/ConstantReference.java
index d103e36..265a842 100644
--- a/compiler-externc/src/main/java/org/apache/royale/compiler/internal/codegen/typedefs/reference/ConstantReference.java
+++ b/compiler-externc/src/main/java/org/apache/royale/compiler/internal/codegen/typedefs/reference/ConstantReference.java
@@ -74,7 +74,17 @@
if (getQualifiedName().equals("undefined"))
{
sb.append(indent);
- sb.append("public const undefined:* = 0;\n");
+ sb.append("public const undefined:* = void 0;\n");
+ }
+ else if (getQualifiedName().equals("NaN"))
+ {
+ sb.append(indent);
+ sb.append("public const NaN:Number = 0/0;\n");
+ }
+ else if (getQualifiedName().equals("Infinity"))
+ {
+ sb.append(indent);
+ sb.append("public const Infinity:Number = 1/0;\n");
}
else
{
diff --git a/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_AnyInitializeUndefined_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_AnyInitializeUndefined_swfdump.xml
index ec1d085..1bdb14a 100644
--- a/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_AnyInitializeUndefined_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_AnyInitializeUndefined_swfdump.xml
@@ -67,15 +67,15 @@
// max_regs 2
// scope_depth 0
// max_scope 1
- // code_length 14
+ // code_length 12
bb0
succs=[]
0 getlocal0
1 pushscope
2 findpropstrict assertEqual
3 pushstring "null"
- 4 pushbyte 0
- 5 pushbyte 0
+ 4 pushundefined
+ 5 pushundefined
6 callpropvoid
7 returnvoid
}
@@ -108,7 +108,7 @@
0 returnvoid
}
- public static const foo:* = 0
+ public static const foo:*
}
function script0$init():*
diff --git a/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_stringInitializeUndefined_swfdump.xml b/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_stringInitializeUndefined_swfdump.xml
index 88f1f0d..f39f57a 100644
--- a/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_stringInitializeUndefined_swfdump.xml
+++ b/compiler/src/test/resources/swfdumps/as_ASVariableTests_ASVariableTests_stringInitializeUndefined_swfdump.xml
@@ -74,7 +74,7 @@
1 pushscope
2 findpropstrict assertEqual
3 pushstring "null"
- 4 pushbyte 0
+ 4 getlex foo
5 pushnull
6 callpropvoid
7 returnvoid
@@ -108,7 +108,7 @@
0 returnvoid
}
- public static const foo:String = "0"
+ public static const foo:String
}
function script0$init():*