You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/10/13 22:22:24 UTC
git commit: [flex-falcon] [refs/heads/develop] - handle 'new int'
Repository: flex-falcon
Updated Branches:
refs/heads/develop 38ca9c957 -> 680c335c7
handle 'new int'
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/680c335c
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/680c335c
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/680c335c
Branch: refs/heads/develop
Commit: 680c335c7f6c9e8a1e2fa068c697c63be2958b89
Parents: 38ca9c9
Author: Alex Harui <ah...@apache.org>
Authored: Thu Oct 13 15:22:09 2016 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Oct 13 15:22:09 2016 -0700
----------------------------------------------------------------------
.../codegen/js/jx/FunctionCallEmitter.java | 30 ++++++++++++++++----
.../js/flexjs/TestFlexJSGlobalClasses.java | 17 +++++++++++
.../js/flexjs/TestFlexJSGlobalFunctions.java | 8 ++++++
3 files changed, 50 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/680c335c/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
index 0d34a3d..4b31159 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
@@ -67,6 +67,7 @@ public class FunctionCallEmitter extends JSSubEmitter implements ISubEmitter<IFu
if (id != ASTNodeID.SuperID)
{
IDefinition def = null;
+ def = node.getNameNode().resolve(getProject());
boolean isClassCast = false;
@@ -74,9 +75,12 @@ public class FunctionCallEmitter extends JSSubEmitter implements ISubEmitter<IFu
{
if (!(node.getChild(1) instanceof VectorLiteralNode))
{
- startMapping(node.getNewKeywordNode());
- writeToken(ASEmitterTokens.NEW);
- endMapping(node.getNewKeywordNode());
+ if (def == null || !(def.getBaseName().equals(IASGlobalFunctionConstants._int) || def.getBaseName().equals(IASGlobalFunctionConstants.uint)))
+ {
+ startMapping(node.getNewKeywordNode());
+ writeToken(ASEmitterTokens.NEW);
+ endMapping(node.getNewKeywordNode());
+ }
}
else
{
@@ -114,8 +118,24 @@ public class FunctionCallEmitter extends JSSubEmitter implements ISubEmitter<IFu
if (def instanceof ClassDefinition)
{
startMapping(nameNode);
- write(getEmitter().formatQualifiedName(def.getQualifiedName()));
- endMapping(nameNode);
+ boolean isInt = def.getBaseName().equals(IASGlobalFunctionConstants._int);
+ if (isInt || def.getBaseName().equals(IASGlobalFunctionConstants.uint))
+ {
+ ICompilerProject project = this.getProject();
+ if (project instanceof FlexJSProject)
+ ((FlexJSProject) project).needLanguage = true;
+ write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ if (isInt)
+ write(JSFlexJSEmitterTokens.UNDERSCORE);
+ write(def.getQualifiedName());
+ endMapping(nameNode);
+ }
+ else
+ {
+ write(getEmitter().formatQualifiedName(def.getQualifiedName()));
+ endMapping(nameNode);
+ }
}
else
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/680c335c/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
index 2527073..701fe1e 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
@@ -160,6 +160,23 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
}
@Test
+ public void testInt()
+ {
+ IVariableNode node = getVariable("var a:int = new int(\"123\");");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = org.apache.flex.utils.Language._int(\"123\")");
+ }
+
+ @Override
+ @Test
+ public void testUint()
+ {
+ IVariableNode node = getVariable("var a:uint = new uint(-100);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = org.apache.flex.utils.Language.uint(-100)");
+ }
+
+ @Test
public void testIntConstMaxValue()
{
IVariableNode node = getVariable("var a:Number = int.MAX_VALUE");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/680c335c/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
index 578ecfc..66397d8 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
@@ -126,6 +126,14 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
assertOut("var /** @type {number} */ a = org.apache.flex.utils.Language._int(1.8)");
}
+ @Test
+ public void testIntWithString()
+ {
+ IVariableNode node = getVariable("var a:int = int(\"123\");");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = org.apache.flex.utils.Language._int(\"123\")");
+ }
+
@Override
@Test
public void testTrace()