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 2019/08/07 15:48:22 UTC
[royale-compiler] branch develop updated: externc: fixed value of
undefined (should not be 0),
and added similar special treatment for NaN and Infinity
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
The following commit(s) were added to refs/heads/develop by this push:
new 94c12e7 externc: fixed value of undefined (should not be 0), and added similar special treatment for NaN and Infinity
94c12e7 is described below
commit 94c12e7d2642db405199a045e78756e3f670f9c2
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Wed Aug 7 08:48:15 2019 -0700
externc: fixed value of undefined (should not be 0), and added similar special treatment for NaN and Infinity
---
.../codegen/typedefs/reference/ConstantReference.java | 12 +++++++++++-
...eTests_ASVariableTests_AnyInitializeUndefined_swfdump.xml | 8 ++++----
...sts_ASVariableTests_stringInitializeUndefined_swfdump.xml | 4 ++--
3 files changed, 17 insertions(+), 7 deletions(-)
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 @@ public class ConstantReference extends BaseReference
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 @@ public class %0 extends Object
// 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 @@ public class %0 extends Object
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 @@ public class %0 extends Object
1 pushscope
2 findpropstrict assertEqual
3 pushstring "null"
- 4 pushbyte 0
+ 4 getlex foo
5 pushnull
6 callpropvoid
7 returnvoid
@@ -108,7 +108,7 @@ public class %0 extends Object
0 returnvoid
}
- public static const foo:String = "0"
+ public static const foo:String
}
function script0$init():*