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 2015/11/09 09:06:18 UTC
[1/2] git commit: [flex-falcon] [refs/heads/develop] - hack in a
simple global function Vector handling. More work needs to be done checking
arguments to Vector and Array
Repository: flex-falcon
Updated Branches:
refs/heads/develop e126ae18f -> 026cada63
hack in a simple global function Vector handling. More work needs to be done checking arguments to Vector and Array
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5478300d
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5478300d
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5478300d
Branch: refs/heads/develop
Commit: 5478300d2f7e7b924b123a7698ac6607e17637f7
Parents: 2ca0b27
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 9 00:04:49 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Nov 9 00:04:49 2015 -0800
----------------------------------------------------------------------
.../js/flexjs/TestFlexJSGlobalClasses.java | 91 ++++++++++++++++++++
.../js/flexjs/TestFlexJSGlobalFunctions.java | 83 +++++++++++++++++-
.../codegen/js/jx/FunctionCallEmitter.java | 7 ++
.../feature-tests/as/ASVariableTests.java | 22 +++++
4 files changed, 202 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5478300d/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
index 37529e9..cfec38e 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
@@ -47,6 +47,46 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
assertOut("FalconTest_A.prototype.a = function() {\n org.apache.flex.utils.Language.trace(arguments);\n}");
}
+ @Test
+ public void testArrayNoArgs()
+ {
+ IVariableNode node = getVariable("var a:Array = new Array();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array()");
+ }
+
+ @Test
+ public void testArrayStringArgs()
+ {
+ IVariableNode node = getVariable("var a:Array = new Array('Hello', 'World');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array('Hello', 'World')");
+ }
+
+ @Test
+ public void testArraySizeArg()
+ {
+ IVariableNode node = getVariable("var a:Array = new Array(30);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array(30)");
+ }
+
+ @Test
+ public void testArrayNumberArgs()
+ {
+ IVariableNode node = getVariable("var a:Array = new Array(30, 40);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array(30, 40)");
+ }
+
+ @Test
+ public void testArrayArrayArg()
+ {
+ IVariableNode node = getVariable("var a:Array = new Array(['Hello', 'World']);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array(['Hello', 'World'])");
+ }
+
@Override
@Test
public void testVector()
@@ -79,4 +119,55 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
asBlockWalker.visitVariable(node);
assertOut("var /** @type {Array} */ a = [\"one\", \"two\", \"three\"]");
}
+
+ @Test
+ public void testVectorNoArgs()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array()");
+ }
+
+ @Test
+ public void testVectorStringArgs()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>('Hello', 'World');");
+ asBlockWalker.visitVariable(node);
+ // expected error?
+ assertOut("var /** @type {Array} */ a = new Array('Hello', 'World')");
+ }
+
+ @Test
+ public void testVectorStringArgs3()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>('Hello', 'World', 'Three');");
+ asBlockWalker.visitVariable(node);
+ // expected error?
+ assertOut("var /** @type {Array} */ a = new Array('Hello', 'World', 'Three')");
+ }
+
+ @Test
+ public void testVectorSizeArg()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(30);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array(30)");
+ }
+
+ @Test
+ public void testVectorNumberArgs()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(30, 40);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array(30, 40)");
+ }
+
+ @Test
+ public void testVectorArrayArg()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(['Hello', 'World']);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array(['Hello', 'World'])");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5478300d/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
index 0ba898e..aaa9c92 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
@@ -49,6 +49,47 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
//
assertOut("var /** @type {Array} */ a = Array(1)");
}
+
+ @Test
+ public void testArrayNoArgs()
+ {
+ IVariableNode node = getVariable("var a:Array = Array();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array()");
+ }
+
+ @Test
+ public void testArrayStringArgs()
+ {
+ IVariableNode node = getVariable("var a:Array = Array('Hello', 'World');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array('Hello', 'World')");
+ }
+
+ @Test
+ public void testArraySizeArg()
+ {
+ IVariableNode node = getVariable("var a:Array = Array(30);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array(30)");
+ }
+
+ @Test
+ public void testArrayNumberArgs()
+ {
+ IVariableNode node = getVariable("var a:Array = Array(30, 40);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array(30, 40)");
+ }
+
+ @Test
+ public void testArrayArrayArg()
+ {
+ IVariableNode node = getVariable("var a:Array = Array(['Hello', 'World']);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array(['Hello', 'World'])");
+ }
+
@Override
@Test
@@ -84,7 +125,47 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
{
IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>(['Hello', 'World']);");
asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Array} */ a = Array(['Hello', 'World'])");
+ assertOut("var /** @type {Array} */ a = ['Hello', 'World'].slice()");
+ }
+
+ @Ignore
+ public void testVectorNoArgs()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array()");
+ }
+
+ @Ignore
+ public void testVectorStringArgs()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>('Hello', 'World');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array('Hello', 'World')");
+ }
+
+ @Ignore
+ public void testVectorSizeArg()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>(30);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array(30)");
+ }
+
+ @Ignore
+ public void testVectorNumberArgs()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>(30, 40);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = Array(30, 40)");
+ }
+
+ @Test
+ public void testVectorArrayArg()
+ {
+ IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>(['Hello', 'World']);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = ['Hello', 'World'].slice()");
}
@Ignore
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5478300d/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
index 9f616c0..5d14895 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
@@ -28,6 +28,7 @@ import org.apache.flex.compiler.internal.codegen.js.JSSessionModel;
import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+import org.apache.flex.compiler.internal.definitions.AppliedVectorDefinition;
import org.apache.flex.compiler.internal.definitions.ClassDefinition;
import org.apache.flex.compiler.internal.definitions.InterfaceDefinition;
import org.apache.flex.compiler.internal.projects.FlexJSProject;
@@ -126,6 +127,12 @@ public class FunctionCallEmitter extends JSSubEmitter implements ISubEmitter<IFu
if (isInt)
write(JSFlexJSEmitterTokens.UNDERSCORE);
}
+ else if (def instanceof AppliedVectorDefinition)
+ {
+ fjs.walkArguments(node.getArgumentNodes());
+ write(".slice()");
+ return;
+ }
}
getWalker().walk(node.getNameNode());
write(ASEmitterTokens.PAREN_OPEN);
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5478300d/compiler.tests/feature-tests/as/ASVariableTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/feature-tests/as/ASVariableTests.java b/compiler.tests/feature-tests/as/ASVariableTests.java
index 13e8b9c..10314d9 100644
--- a/compiler.tests/feature-tests/as/ASVariableTests.java
+++ b/compiler.tests/feature-tests/as/ASVariableTests.java
@@ -106,4 +106,26 @@ public class ASVariableTests extends ASFeatureTestsBase
compileAndRun(source);
}
+ /*
+ public void ASVariableTests_VectorInitializer()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public static var arr:Array = Array('foo', 'bar', 'baz');",
+ "public static var foo:Vector.<String> = new Vector.<String>('foo', 'bar', 'baz');",
+ "public static var bar:Vector.<String> = Vector.<String>('foo', 'bar', 'baz');",
+ };
+ String[] testCode = new String[]
+ {
+ "assertEqual('length', foo.length, 3, 4);",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+ */
}
[2/2] git commit: [flex-falcon] [refs/heads/develop] - hack in global
vector function support
Posted by ah...@apache.org.
hack in global vector function support
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/026cada6
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/026cada6
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/026cada6
Branch: refs/heads/develop
Commit: 026cada638a03b6e4100cd5c1fc4130b6007a8b3
Parents: e126ae1 5478300
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 9 00:06:03 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Nov 9 00:06:03 2015 -0800
----------------------------------------------------------------------
.../js/flexjs/TestFlexJSGlobalClasses.java | 91 ++++++++++++++++++++
.../js/flexjs/TestFlexJSGlobalFunctions.java | 83 +++++++++++++++++-
.../codegen/js/jx/FunctionCallEmitter.java | 7 ++
.../feature-tests/as/ASVariableTests.java | 22 +++++
4 files changed, 202 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/026cada6/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
----------------------------------------------------------------------