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 2013/04/20 02:18:12 UTC
[1/6] git commit: [flex-falcon] - Add subclass of JSTarget to prepare
for CSS handling
Updated Branches:
refs/heads/develop 6fd38b4ad -> a82dbc12b
Add subclass of JSTarget to prepare for CSS handling
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/2e0b4235
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/2e0b4235
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/2e0b4235
Branch: refs/heads/develop
Commit: 2e0b4235d4363ec3a9b48f8248e1caae08c363c9
Parents: 6fd38b4
Author: Alex Harui <ah...@apache.org>
Authored: Fri Apr 19 09:41:53 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Apr 19 09:46:02 2013 -0700
----------------------------------------------------------------------
.../internal/driver/js/flexjs/FlexJSBackend.java | 13 ++++
.../compiler/internal/targets/FlexJSTarget.java | 57 +++++++++++++++
.../flex/compiler/internal/targets/JSTarget.java | 4 +-
3 files changed, 72 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2e0b4235/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
index 9a7d92e..1e06bcc 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/flexjs/FlexJSBackend.java
@@ -24,6 +24,11 @@ import java.io.FilterWriter;
import org.apache.flex.compiler.codegen.js.IJSEmitter;
import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.targets.FlexJSTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
/**
* @author Erik de Bruin
@@ -39,4 +44,12 @@ public class FlexJSBackend extends GoogBackend
return emitter;
}
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSTarget(project, settings, monitor);
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2e0b4235/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java b/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
new file mode 100644
index 0000000..adb0a44
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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 org.apache.flex.compiler.internal.targets;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.flex.compiler.driver.js.IJSApplication;
+import org.apache.flex.compiler.exceptions.BuildCanceledException;
+import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
+import org.apache.flex.compiler.internal.driver.js.JSApplication;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.IJSTarget;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetReport;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.units.ICompilationUnit;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+public class FlexJSTarget extends JSTarget implements IJSTarget
+{
+ /**
+ * Initialize a JS target with the owner project and root compilation units.
+ *
+ * @param project the owner project
+ */
+ public FlexJSTarget(IASProject project, ITargetSettings targetSettings,
+ ITargetProgressMonitor progressMonitor)
+ {
+ super(project, targetSettings, progressMonitor);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2e0b4235/compiler.jx/src/org/apache/flex/compiler/internal/targets/JSTarget.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/targets/JSTarget.java b/compiler.jx/src/org/apache/flex/compiler/internal/targets/JSTarget.java
index 084d552..adba905 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/targets/JSTarget.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/targets/JSTarget.java
@@ -43,8 +43,8 @@ import com.google.common.collect.Iterables;
public class JSTarget extends Target implements IJSTarget
{
- private ICompilationUnit mainCU;
- private RootedCompilationUnits rootedCompilationUnits;
+ protected ICompilationUnit mainCU;
+ protected RootedCompilationUnits rootedCompilationUnits;
/**
* Initialize a JS target with the owner project and root compilation units.
[6/6] git commit: [flex-falcon] - fix more bugs in compiler and add
more tests for them
Posted by ah...@apache.org.
fix more bugs in compiler and add more tests for them
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/a82dbc12
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/a82dbc12
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/a82dbc12
Branch: refs/heads/develop
Commit: a82dbc12b06e564fc28bbb4cdf5e73b68a4383ec
Parents: 123afb7
Author: Alex Harui <ah...@apache.org>
Authored: Fri Apr 19 17:17:38 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Apr 19 17:17:38 2013 -0700
----------------------------------------------------------------------
.../codegen/js/flexjs/TestFlexJSClass.java | 14 +++-
.../codegen/js/flexjs/TestFlexJSExpressions.java | 46 ++++++++++-
.../js/flexjs/TestFlexJSGlobalFunctions.java | 62 ++++++++++++++-
.../flexjs/files/FlexJSTest_again_result.js | 1 -
.../flexjs/files/MyInitialView_result.js | 4 -
.../flexjs/files/wildcard_import_result.js | 1 -
.../codegen/js/flexjs/JSFlexJSEmitter.java | 35 ++++++---
.../apache/flex/compiler/utils/NativeUtils.java | 49 +++++++++++-
8 files changed, 187 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
index 794d180..ca98a71 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
@@ -121,7 +121,19 @@ public class TestFlexJSClass extends TestGoogClass
+ "public function foo2():Object{function bar2(param1:Object):Object {return null;}; return bar2('foo');}"
+ "}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n\tfunction bar1() {\n\t\treturn null;\n\t};\n\treturn bar1();\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n\tfunction bar2(param1) {\n\t\treturn null;\n\t};\n\treturn bar2('foo');\n};");
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n\tfunction bar1() {\n\t\treturn null;\n\t};\n\treturn goog.bind(bar1, this)();\n};\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n\tfunction bar2(param1) {\n\t\treturn null;\n\t};\n\treturn goog.bind(bar2, this)('foo');\n};");
+ }
+
+ @Test
+ public void testMethodsWithLocalFunctions2()
+ {
+ IClassNode node = getClassNode("public class B {"
+ + "public var baz1:String;"
+ + "public function foo1():String{function bar1():String {return baz1;}; return bar1()}"
+ + "public function foo2():String{function bar2(param1:String):String {return param1 + baz1;}; return bar2('foo');}"
+ + "}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.baz1;\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n\tfunction bar1() {\n\t\treturn this.baz1;\n\t};\n\treturn goog.bind(bar1, this)();\n};\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n\tfunction bar2(param1) {\n\t\treturn param1 + this.baz1;\n\t};\n\treturn goog.bind(bar2, this)('foo');\n};");
}
@Test
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index 8e6bd86..33c5e99 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -470,7 +470,37 @@ public class TestFlexJSExpressions extends TestGoogExpressions
"public class B {public function b() { function c(f:Function):void {}; function d():void {}; c(d); }}",
IFunctionNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitFunction(node);
- assertOut("/**\n * @expose\n */\nB.prototype.b = function() {\n\tfunction c(f) {\n\t};\n\tfunction d() {\n\t};\n\tc(d);\n}");
+ assertOut("/**\n * @expose\n */\nB.prototype.b = function() {\n\tfunction c(f) {\n\t};\n\tfunction d() {\n\t};\n\tgoog.bind(c, this)(goog.bind(d, this));\n}");
+ }
+
+ @Test
+ public void testNamedFunctionAsArgument2()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "public class B {public function b() { function c(s:String, f:Function):void {}; function d():void {}; c('foo', d); }}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitFunction(node);
+ assertOut("/**\n * @expose\n */\nB.prototype.b = function() {\n\tfunction c(s, f) {\n\t};\n\tfunction d() {\n\t};\n\tgoog.bind(c, this)('foo', goog.bind(d, this));\n}");
+ }
+
+ @Test
+ public void testNamedFunctionAsArgument3()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "public class B {public function b() { c('foo', d); function c(s:String, f:Function):void {}; function d():void {};}}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitFunction(node);
+ assertOut("/**\n * @expose\n */\nB.prototype.b = function() {\n\tgoog.bind(c, this)('foo', goog.bind(d, this));\n\tfunction c(s, f) {\n\t};\n\tfunction d() {\n\t};\n}");
+ }
+
+ @Test
+ public void testNamedFunctionAsArgument4()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "public class B {public function b() { function d():void {}; c('foo', d); } public function c(s:String, f:Function):void {};}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitFunction(node);
+ assertOut("/**\n * @expose\n */\nB.prototype.b = function() {\n\tfunction d() {\n\t};\n\tthis.c('foo', goog.bind(d, this));\n}");
}
@Test
@@ -480,7 +510,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
"public class B {public function b() { function c(f:Function):void {}; c(b); }}",
IFunctionNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitFunction(node);
- assertOut("/**\n * @expose\n */\nB.prototype.b = function() {\n\tfunction c(f) {\n\t};\n\tc(goog.bind(this.b, this));\n}");
+ assertOut("/**\n * @expose\n */\nB.prototype.b = function() {\n\tfunction c(f) {\n\t};\n\tgoog.bind(c, this)(goog.bind(this.b, this));\n}");
}
@Test
@@ -490,7 +520,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
"public class B {static public function b() { function c(f:Function):void {}; c(b); }}",
IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
asBlockWalker.visitFunction(node);
- assertOut("/**\n * @expose\n */\nfoo.bar.B.b = function() {\n\tfunction c(f) {\n\t};\n\tc(foo.bar.B.b);\n}");
+ assertOut("/**\n * @expose\n */\nfoo.bar.B.b = function() {\n\tfunction c(f) {\n\t};\n\tgoog.bind(c, this)(foo.bar.B.b);\n}");
}
@Test
@@ -552,6 +582,16 @@ public class TestFlexJSExpressions extends TestGoogExpressions
assertOut("(is(a, b) ? a : null)");
}
+ @Test
+ public void testVisitAs2()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "public class B {public function b(o:Object):int { var a:B; a = o as B; }}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+ asBlockWalker.visitFunction(node);
+ assertOut("/**\n * @expose\n * @param {Object} o\n * @return {number}\n */\nfoo.bar.B.prototype.b = function(o) {\n\tvar /** @type {B} */ a;\n\ta = (is(o, foo.bar.B) ? o : null);\n}");
+ }
+
@Override
@Test
public void testVisitBinaryOperator_Is()
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/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 8d8bce5..a3f6207 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
@@ -24,6 +24,7 @@ import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogGlobalFunctions
import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -31,6 +32,37 @@ import org.junit.Test;
*/
public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
{
+ @Ignore
+ @Override
+ @Test
+ public void testArray()
+ {
+ IVariableNode node = getVariable("var a:Array = Array(1);");
+ asBlockWalker.visitVariable(node);
+ // TODO (aharui) claims this is not valid and someday needs to result in:
+ // a = new Array()
+ // I cannot find any reference to creating an array of a particular
+ // size in JS.
+ assertOut("var /** @type {Array} */ a = Array(1)");
+ }
+
+ @Override
+ @Test
+ public void testInt()
+ {
+ IVariableNode node = getVariable("var a:int = int(1.8);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = 1.8/** Cast to int */");
+ }
+
+ @Override
+ @Test
+ public void testObject()
+ {
+ IVariableNode node = getVariable("var a:Object = Object(\"1\");");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Object} */ a = \"1\"/** Cast to Object */");
+ }
@Override
@Test
@@ -50,6 +82,34 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
assertOut("var /** @type {Vector.<string>} */ a = Array(['Hello', 'World'])");
}
+ @Ignore
+ @Override
+ @Test
+ public void testXML()
+ {
+ IVariableNode node = getVariable("var a:XML = XML('@');");
+ asBlockWalker.visitVariable(node);
+ // TODO (aharui) claims this is not valid and someday needs to result in:
+ // <@/> or something like that?
+ // I cannot find any reference to creating an XML object via a
+ // global function
+ assertOut("var /** @type {XML} */ a = XML('@')");
+ }
+
+ @Ignore
+ @Override
+ @Test
+ public void testXMLList()
+ {
+ IVariableNode node = getVariable("var a:XMLList = XMLList('<!-- comment -->');");
+ asBlockWalker.visitVariable(node);
+ // TODO (aharui) claims this is not valid and someday needs to result in:
+ // <@/> or something like that?
+ // I cannot find any reference to creating an XML object via a
+ // global function
+ assertOut("var /** @type {XMLList} */ a = XMLList('<!-- comment -->')");
+ }
+
@Test
public void testGlobalFunctionInClass()
{
@@ -65,5 +125,5 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
{
return new FlexJSBackend();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js b/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
index 0e9dc85..f7e4e47 100644
--- a/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
+++ b/compiler.jx.tests/test-files/flexjs/files/FlexJSTest_again_result.js
@@ -9,7 +9,6 @@ goog.require('org.apache.flex.net.HTTPService');
goog.require('org.apache.flex.net.dataConverters.LazyCollection');
goog.require('org.apache.flex.net.JSONInputParser');
goog.require('StockDataJSONItemConverter');
-goog.require('org.apache.flex.events.Event');
/**
* @constructor
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js b/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
index a546188..5bcf47d 100644
--- a/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
+++ b/compiler.jx.tests/test-files/flexjs/files/MyInitialView_result.js
@@ -12,10 +12,6 @@ goog.require('org.apache.flex.html.staticControls.CheckBox');
goog.require('org.apache.flex.html.staticControls.RadioButton');
goog.require('org.apache.flex.html.staticControls.DropDownList');
goog.require('org.apache.flex.html.staticControls.ComboBox');
-goog.require('org.apache.flex.events.Event');
-goog.require('flash.events.Event');
-goog.require('org.apache.flex.utils.Timer');
-goog.require('org.apache.flex.events.CustomEvent');
/**
* @constructor
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js b/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
index 9c7c4c9..eb17f8a 100644
--- a/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
+++ b/compiler.jx.tests/test-files/flexjs/files/wildcard_import_result.js
@@ -1,7 +1,6 @@
goog.provide('wildcard_import');
goog.require('org.apache.flex.core.Application');
-goog.require('org.apache.flex.html.staticControls.Button');
/**
* @constructor
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index df36212..a60643e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -32,6 +32,7 @@ import org.apache.flex.compiler.common.ASModifier;
import org.apache.flex.compiler.common.ModifiersSet;
import org.apache.flex.compiler.definitions.IDefinition;
import org.apache.flex.compiler.definitions.IFunctionDefinition;
+import org.apache.flex.compiler.definitions.IFunctionDefinition.FunctionClassification;
import org.apache.flex.compiler.definitions.INamespaceDefinition;
import org.apache.flex.compiler.definitions.IPackageDefinition;
import org.apache.flex.compiler.definitions.ITypeDefinition;
@@ -209,7 +210,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
def = node.getNameNode().resolve(project);
isClassCast = def instanceof ClassDefinition
- && !(NativeUtils.isNative(def.getBaseName()));
+ && !(NativeUtils.isJSNative(def.getBaseName()));
}
if (node.isNewExpression())
@@ -288,7 +289,8 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
else if (parentNodeId == ASTNodeID.ContainerID
&& nodeDef instanceof FunctionDefinition)
{
- return true; // for 'goog.bind'
+ return ((FunctionDefinition) nodeDef)
+ .getFunctionClassification() == FunctionClassification.CLASS_MEMBER; // for 'goog.bind'
}
else
{
@@ -377,16 +379,26 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
boolean emitName = true;
- if (nodeDef != null && nodeDef.isStatic())
+ if (nodeDef != null
+ && (nodeDef.isStatic() || (nodeDef instanceof ClassDefinition && nodeDef
+ .getParent() != null)))
{
String sname = nodeDef.getParent().getQualifiedName();
- write(sname);
- write(ASEmitterTokens.MEMBER_ACCESS);
+ if (sname.length() > 0)
+ {
+ write(sname);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ }
}
- else if (!NativeUtils.isNative(node.getName()) && writeThis(node))
+ else if (!NativeUtils.isNative(node.getName()))
{
- boolean useGoogBind = parentNodeId == ASTNodeID.ContainerID
- && identifierIsPlainFunction;
+ // an instance method as a parameter or
+ // a local function
+ boolean useGoogBind = (parentNodeId == ASTNodeID.ContainerID
+ && identifierIsPlainFunction && ((FunctionDefinition) nodeDef)
+ .getFunctionClassification() == FunctionClassification.CLASS_MEMBER)
+ || (identifierIsPlainFunction && ((FunctionDefinition) nodeDef)
+ .getFunctionClassification() == FunctionClassification.LOCAL);
if (useGoogBind)
{
@@ -394,9 +406,12 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
write(ASEmitterTokens.PAREN_OPEN);
}
- write(ASEmitterTokens.THIS);
+ if (writeThis(node))
+ {
+ write(ASEmitterTokens.THIS);
- write(ASEmitterTokens.MEMBER_ACCESS);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ }
if (useGoogBind)
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a82dbc12/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
index c56812e..361f178 100644
--- a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
@@ -24,7 +24,7 @@ package org.apache.flex.compiler.utils;
*/
public class NativeUtils
{
- public enum NativeType
+ public enum NativeASType
{
Any("*"), // not JS but use full in the context of native
@@ -38,6 +38,7 @@ public class NativeUtils
Function("Function"),
Infinity("Infinity"),
Math("Math"),
+ JSON("JSON"),
NaN("NaN"),
Namespace("Namespace"),
Number("Number"),
@@ -66,13 +67,13 @@ public class NativeUtils
parseFloat("parseFloat"),
parseInt("parseInt"),
trace("trace"),
- unit("unit"),
+ uint("uint"),
undefined("undefined"),
unescape("unescape");
private final String value;
- NativeType(String value)
+ NativeASType(String value)
{
this.value = value;
}
@@ -83,9 +84,38 @@ public class NativeUtils
}
}
+ public enum NativeJSType
+ {
+ Boolean("Boolean"),
+ Number("Number"),
+ String("String"),
+ decodeURI("decodeURI"),
+ decodeURIComponent("decodeURIComponent"),
+ encodeURI("encodeURI"),
+ encodeURIComponent("encodeURIComponent"),
+ escape("escape"),
+ isFinite("isFinite"),
+ isNaN("isNaN"),
+ parseFloat("parseFloat"),
+ parseInt("parseInt"),
+ unescape("unescape");
+
+ private final String value;
+
+ NativeJSType(String value)
+ {
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+ }
+
public static boolean isNative(String type)
{
- for (NativeType test : NativeType.values())
+ for (NativeASType test : NativeASType.values())
{
if (test.getValue().equals(type))
return true;
@@ -94,4 +124,15 @@ public class NativeUtils
return true;
return false;
}
+
+ public static boolean isJSNative(String type)
+ {
+ for (NativeJSType test : NativeJSType.values())
+ {
+ if (test.getValue().equals(type))
+ return true;
+ }
+ return false;
+ }
+
}
[4/6] git commit: [flex-falcon] - another attempt at dependency
management. Assumes no important dependencies are found during emitting
Posted by ah...@apache.org.
another attempt at dependency management. Assumes no important dependencies are found during emitting
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/feb25bfc
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/feb25bfc
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/feb25bfc
Branch: refs/heads/develop
Commit: feb25bfc80158c5bf0fbcdb0d6cc0f4b5b6fa1a7
Parents: 32186ca
Author: Alex Harui <ah...@apache.org>
Authored: Fri Apr 19 09:45:39 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Apr 19 10:39:42 2013 -0700
----------------------------------------------------------------------
.../org/apache/flex/compiler/clients/MXMLJSC.java | 2 +-
.../codegen/mxml/flexjs/MXMLFlexJSEmitter.java | 1 +
.../compiler/internal/projects/FlexJSProject.java | 106 +++++++++++----
3 files changed, 78 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/feb25bfc/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
index 5ed4dca..35b539f 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -444,7 +444,7 @@ public class MXMLJSC
final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
String qname = config.getMainDefinition();
- ((FlexJSProject)project).alreadyRequired.put(qname, mainCU);
+ ((FlexJSProject)project).mainCU = mainCU;
final IJSApplication app = buildApplication(project,
config.getMainDefinition(), mainCU, problemsBuildingSWF);
problems.addAll(problemsBuildingSWF);
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/feb25bfc/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index aa2df2c..6e18b20 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -652,6 +652,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
writtenInstances.add(imp);
}
}
+
}
private void emitHeaderLine(String qname)
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/feb25bfc/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java b/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
index 4af001a..f4aa6a1 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
@@ -20,6 +20,8 @@ package org.apache.flex.compiler.internal.projects;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
import org.apache.flex.compiler.common.DependencyType;
import org.apache.flex.compiler.definitions.IDefinition;
@@ -28,6 +30,8 @@ import org.apache.flex.compiler.internal.scopes.ASProjectScope.DefinitionPromise
import org.apache.flex.compiler.internal.workspaces.Workspace;
import org.apache.flex.compiler.units.ICompilationUnit;
+import com.google.common.collect.ImmutableSet;
+
/**
* @author aharui
*
@@ -45,8 +49,9 @@ public class FlexJSProject extends FlexProject
super(workspace);
}
- private HashMap<ICompilationUnit, ArrayList<String>> requires = new HashMap<ICompilationUnit, ArrayList<String>>();
- public HashMap<String, ICompilationUnit> alreadyRequired = new HashMap<String, ICompilationUnit>();
+ private HashMap<ICompilationUnit, HashMap<String, DependencyType>> requires = new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
+
+ public ICompilationUnit mainCU;
@Override
public void addDependency(ICompilationUnit from, ICompilationUnit to, DependencyType dt, String qname)
@@ -54,43 +59,84 @@ public class FlexJSProject extends FlexProject
IDefinition def = to.getDefinitionPromises().get(0);
IDefinition actualDef = ((DefinitionPromise) def).getActualDefinition();
boolean isInterface = actualDef instanceof InterfaceDefinition;
- if (isInterface)
- {
- //System.out.println("Interface: " + qname);
- }
- else
+ if (!isInterface)
{
-
- ArrayList<String> reqs;
- if (requires.containsKey(from))
- reqs = requires.get(from);
- else
- {
- reqs = new ArrayList<String>();
- requires.put(from, reqs);
- }
- // if the class is already required by some other class
- // don't add it. Otherwise we can get circular
- // dependencies.
- boolean circular = (from == to);
- if (requires.containsKey(to))
- {
- if (alreadyRequired.containsKey(qname))
- circular = true;
- }
- if (!circular || dt == DependencyType.INHERITANCE)
+ if (from != to)
{
- reqs.add(qname);
- alreadyRequired.put(qname, from);
+ HashMap<String, DependencyType> reqs;
+ if (requires.containsKey(from))
+ reqs = requires.get(from);
+ else
+ {
+ reqs = new HashMap<String, DependencyType>();
+ requires.put(from, reqs);
+ }
+ if (reqs.containsKey(qname))
+ {
+ // inheritance is important so remember it
+ if (reqs.get(qname) != DependencyType.INHERITANCE)
+ {
+ reqs.put(qname, dt);
+ }
+ }
+ else
+ reqs.put(qname, dt);
}
}
super.addDependency(from, to, dt, qname);
}
+
+ private boolean needToDetermineRequires = true;
+
+ // this set is computed from the requires list . we have to strip out any circularities starting from the mainCU
+ private HashMap<ICompilationUnit, ArrayList<String>> googrequires = new HashMap<ICompilationUnit, ArrayList<String>>();
+
+ private void determineRequires()
+ {
+ if (mainCU == null)
+ return;
+
+ needToDetermineRequires = false;
+ List<ICompilationUnit> reachableCompilationUnits =
+ getReachableCompilationUnitsInSWFOrder(ImmutableSet
+ .of(mainCU));
+
+ HashMap<String, String> already = new HashMap<String, String>();
+
+ for (ICompilationUnit cu: reachableCompilationUnits)
+ {
+ if (requires.containsKey(cu))
+ {
+ HashMap<String, DependencyType> reqs = requires.get(cu);
+ Set<String> it = reqs.keySet();
+ ArrayList<String> newreqs = new ArrayList<String>();
+ for (String req : it)
+ {
+ DependencyType dt = reqs.get(req);
+ if (dt == DependencyType.INHERITANCE)
+ newreqs.add(req);
+ else
+ {
+ if (!already.containsKey(req))
+ {
+ newreqs.add(req);
+ already.put(req, req);
+ }
+ }
+ }
+ googrequires.put(cu, newreqs);
+ }
+ }
+ }
public ArrayList<String> getRequires(ICompilationUnit from)
{
- if (requires.containsKey(from))
- return requires.get(from);
+ if (needToDetermineRequires)
+ determineRequires();
+
+ if (googrequires.containsKey(from))
+ return googrequires.get(from);
return null;
}
+
}
[3/6] git commit: [flex-falcon] - Handle 'not ternary'
Posted by ah...@apache.org.
Handle 'not ternary'
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/32186ca1
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/32186ca1
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/32186ca1
Branch: refs/heads/develop
Commit: 32186ca1bca69ea57d1be56c19199701a6164344
Parents: c30116a
Author: Alex Harui <ah...@apache.org>
Authored: Fri Apr 19 09:44:57 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Apr 19 10:37:01 2013 -0700
----------------------------------------------------------------------
.../compiler/internal/codegen/as/ASEmitter.java | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/32186ca1/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
index 19955e3..621105e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
@@ -42,6 +42,8 @@ import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
import org.apache.flex.compiler.internal.tree.as.ContainerNode;
import org.apache.flex.compiler.internal.tree.as.FunctionNode;
import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
+import org.apache.flex.compiler.internal.tree.as.NamespaceAccessExpressionNode;
+import org.apache.flex.compiler.internal.tree.as.TernaryOperatorNode;
import org.apache.flex.compiler.problems.ICompilerProblem;
import org.apache.flex.compiler.tree.ASTNodeID;
import org.apache.flex.compiler.tree.as.IASNode;
@@ -1379,7 +1381,17 @@ public class ASEmitter implements IASEmitter, IEmitter
|| node.getNodeID() == ASTNodeID.Op_AddID)
{
write(node.getOperator().getOperatorText());
- getWalker().walk(node.getOperandNode());
+ IExpressionNode opNode = node.getOperandNode();
+ if (opNode instanceof TernaryOperatorNode)
+ {
+ write(ASEmitterTokens.PAREN_OPEN);
+ getWalker().walk(node.getOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ }
+ else
+ {
+ getWalker().walk(node.getOperandNode());
+ }
}
else if (node.getNodeID() == ASTNodeID.Op_PostIncrID
[2/6] git commit: [flex-falcon] - Handle Vector.length
Posted by ah...@apache.org.
Handle Vector.length
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/c30116a2
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/c30116a2
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/c30116a2
Branch: refs/heads/develop
Commit: c30116a26fd990be8785d1f112ddc15a3ffd05a9
Parents: 2e0b423
Author: Alex Harui <ah...@apache.org>
Authored: Fri Apr 19 09:43:50 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Apr 19 09:46:05 2013 -0700
----------------------------------------------------------------------
.../codegen/js/flexjs/TestFlexJSExpressions.java | 19 +++++++++++++++
.../apache/flex/compiler/utils/NativeUtils.java | 2 +
2 files changed, 21 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c30116a2/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index da344c0..56d0aef 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -504,6 +504,17 @@ public class TestFlexJSExpressions extends TestGoogExpressions
assertOut("/**\n * @expose\n * @return {number}\n */\nfoo.bar.B.prototype.b = function() {\n\tvar /** @type {string} */ s;\n\treturn s.length;\n}");
}
+ @Test
+ public void testNativeVectorGetter()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "public class B {public function b():int { var a:Vector.<String>; return a.length; }}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+ asBlockWalker.visitFunction(node);
+ // String.length is a getter but is a property in JS, so don't generate set_length() call.
+ assertOut("/**\n * @expose\n * @return {number}\n */\nfoo.bar.B.prototype.b = function() {\n\tvar self = this;\n\tvar /** @type {Vector.<string>} */ a;\n\treturn a.length;\n}");
+ }
+
//----------------------------------
// Other
//----------------------------------
@@ -524,6 +535,14 @@ public class TestFlexJSExpressions extends TestGoogExpressions
assertOut("FalconTest_A.prototype.foo = function() {\n\tbar(b).text = '';\n}");
}
+ @Test
+ public void testComplexBooleanExpression()
+ {
+ IFunctionNode node = getMethod("function foo(b:Boolean):Boolean {var c:String; var d:String; if (!(b ? c : d)) { return b;}");
+ asBlockWalker.visitFunction(node);
+ assertOut("/**\n * @param {boolean} b\n * @return {boolean}\n */\nFalconTest_A.prototype.foo = function(b) {\n\tvar self = this;\n\tvar /** @type {string} */ c;\n\tvar /** @type {string} */ d;\n\tif (!(b ? c : d)) {\n\t\treturn b;\n\t}\n}");
+ }
+
@Override
@Test
public void testVisitAs()
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c30116a2/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
index 554a231..c56812e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/utils/NativeUtils.java
@@ -90,6 +90,8 @@ public class NativeUtils
if (test.getValue().equals(type))
return true;
}
+ if (type.startsWith("Vector.<"))
+ return true;
return false;
}
}
[5/6] git commit: [flex-falcon] - fix a few issues after merging
Erik's changes
Posted by ah...@apache.org.
fix a few issues after merging Erik's changes
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/123afb75
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/123afb75
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/123afb75
Branch: refs/heads/develop
Commit: 123afb7587d1de2bf32af275bd584c995bf9390b
Parents: feb25bf
Author: Alex Harui <ah...@apache.org>
Authored: Fri Apr 19 12:27:43 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Apr 19 12:27:43 2013 -0700
----------------------------------------------------------------------
.../codegen/js/flexjs/TestFlexJSExpressions.java | 4 +-
.../codegen/mxml/flexjs/MXMLFlexJSEmitter.java | 40 ++++++++-------
2 files changed, 23 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/123afb75/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index 56d0aef..8e6bd86 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -512,7 +512,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
asBlockWalker.visitFunction(node);
// String.length is a getter but is a property in JS, so don't generate set_length() call.
- assertOut("/**\n * @expose\n * @return {number}\n */\nfoo.bar.B.prototype.b = function() {\n\tvar self = this;\n\tvar /** @type {Vector.<string>} */ a;\n\treturn a.length;\n}");
+ assertOut("/**\n * @expose\n * @return {number}\n */\nfoo.bar.B.prototype.b = function() {\n\tvar /** @type {Vector.<string>} */ a;\n\treturn a.length;\n}");
}
//----------------------------------
@@ -540,7 +540,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
{
IFunctionNode node = getMethod("function foo(b:Boolean):Boolean {var c:String; var d:String; if (!(b ? c : d)) { return b;}");
asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {boolean} b\n * @return {boolean}\n */\nFalconTest_A.prototype.foo = function(b) {\n\tvar self = this;\n\tvar /** @type {string} */ c;\n\tvar /** @type {string} */ d;\n\tif (!(b ? c : d)) {\n\t\treturn b;\n\t}\n}");
+ assertOut("/**\n * @param {boolean} b\n * @return {boolean}\n */\nFalconTest_A.prototype.foo = function(b) {\n\tvar /** @type {string} */ c;\n\tvar /** @type {string} */ d;\n\tif (!(b ? c : d)) {\n\t\treturn b;\n\t}\n}");
}
@Override
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/123afb75/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index 6e18b20..0f10cd8 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -630,29 +630,31 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
.getCompilationUnitForDefinition(cdef);
ArrayList<String> deps = project.getRequires(cu);
- for (String imp : deps)
+ if (deps != null)
{
- if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
- continue;
-
- if (imp.equals(cname))
- continue;
-
- if (imp.equals("mx.events.PropertyChangeEvent"))
- continue;
- if (imp.equals("mx.events.PropertyChangeEventKind"))
- continue;
-
- if (NativeUtils.isNative(imp))
- continue;
-
- if (writtenInstances.indexOf(imp) == -1)
+ for (String imp : deps)
{
- emitHeaderLine(imp);
- writtenInstances.add(imp);
+ if (imp.indexOf(JSGoogEmitterTokens.AS3.getToken()) != -1)
+ continue;
+
+ if (imp.equals(cname))
+ continue;
+
+ if (imp.equals("mx.events.PropertyChangeEvent"))
+ continue;
+ if (imp.equals("mx.events.PropertyChangeEventKind"))
+ continue;
+
+ if (NativeUtils.isNative(imp))
+ continue;
+
+ if (writtenInstances.indexOf(imp) == -1)
+ {
+ emitHeaderLine(imp);
+ writtenInstances.add(imp);
+ }
}
}
-
}
private void emitHeaderLine(String qname)