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/12/01 01:05:27 UTC

[1/2] git commit: [flex-falcon] [refs/heads/develop] - undo 65f73df30ba9cb03a42d22bf58d472720a667800 and implement handling static and instance methods with the same name

Repository: flex-falcon
Updated Branches:
  refs/heads/develop 65f73df30 -> 74fdfbfd5


undo 65f73df30ba9cb03a42d22bf58d472720a667800 and implement handling static and instance methods with the same name


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/e39393aa
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/e39393aa
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/e39393aa

Branch: refs/heads/develop
Commit: e39393aabdb37cde256e991cc111312d3eeb0e41
Parents: 65f73df
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 30 16:04:18 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Nov 30 16:04:18 2015 -0800

----------------------------------------------------------------------
 .../codegen/externals/TestConstructor.java      |  2 +-
 .../codegen/externals/TestExternChrome.java     |  4 +-
 .../codegen/externals/TestExternES3.java        | 16 ++++
 .../codegen/externals/TestExternJasmine.java    |  2 +-
 .../codegen/externals/TestTypeExternals.java    |  6 +-
 .../codegen/externals/TestTypeInheritence.java  |  2 +-
 .../externals/pass/CollectImportsPass.java      |  4 +-
 .../externals/reference/ClassReference.java     | 47 ++++++----
 .../externals/reference/MethodReference.java    |  8 +-
 .../codegen/externals/utils/FunctionUtils.java  | 25 ++++--
 externs/js/missing.js                           | 90 --------------------
 11 files changed, 82 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestConstructor.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestConstructor.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestConstructor.java
index e2c7001..d76eb15 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestConstructor.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestConstructor.java
@@ -41,7 +41,7 @@ public class TestConstructor extends ExternalsTestBase
         assertTrue(model.hasClass("FinalClass"));
         //assertTrue(model.getClassReference("FinalClass").isFinal());
         assertTrue(model.getClassReference("FinalClass").hasMethod("bar"));
-        assertTrue(model.getClassReference("FinalClass").getMethod("bar").isStatic());
+        assertTrue(model.getClassReference("FinalClass").getStaticMethod("bar").isStatic());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
index c435a03..1e6ffd9 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
@@ -101,9 +101,9 @@ public class TestExternChrome extends ExternalsTestBase
         assertTrue(chrome.hasStaticMethod("loadTimes"));
         assertTrue(chrome.hasStaticMethod("csi"));
         assertEquals("ChromeLoadTimes",
-                chrome.getMethod("loadTimes").toReturnTypeAnnotationString());
+                chrome.getStaticMethod("loadTimes").toReturnTypeAnnotationString());
         assertEquals("ChromeCsiInfo",
-                chrome.getMethod("csi").toReturnTypeAnnotationString());
+                chrome.getStaticMethod("csi").toReturnTypeAnnotationString());
 
         // chrome.app
         ClassReference chrome_app = model.getClassReference("chrome.app");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternES3.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternES3.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternES3.java
index 9b47e9f..0d8ef89 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternES3.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternES3.java
@@ -93,6 +93,22 @@ public class TestExternES3 extends ExternalsTestBase
         assertEquals("    public function Array(...var_args):Array {  return null; }\n", emit);
     }
 
+    @Test
+    public void test_Array_indexOf() throws IOException
+    {
+        Result result = compile();
+        assertTrue(result.success);
+
+        ClassReference Array = model.getClassReference("Array");
+        assertNotNull(Array);
+
+        MethodReference indexOf = Array.getInstanceMethod("indexOf");
+        StringBuilder sb = new StringBuilder();
+        indexOf.emitCode(sb);
+        String emit = sb.toString();
+        assertEquals("    public function indexOf(obj:Object, opt_fromIndex:Number = 0):Number { return 0; }\n", emit);
+    }
+
     @Override
     protected void configure(ExternCConfiguration config) throws IOException
     {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java
index fdfd3ce..9e2c805 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestExternJasmine.java
@@ -62,7 +62,7 @@ public class TestExternJasmine extends ExternalsTestBase
         assertNotNull(jasmine);
 
         assertTrue(jasmine.hasStaticMethod("clock"));
-        assertEquals("jasmine.Clock", jasmine.getMethod("clock").toReturnTypeAnnotationString());
+        assertEquals("jasmine.Clock", jasmine.getStaticMethod("clock").toReturnTypeAnnotationString());
 
         assertTrue(jasmine.hasImport("jasmine.Clock"));
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeExternals.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeExternals.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeExternals.java
index 09fb8d1..e3709c5 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeExternals.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeExternals.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 
 import org.apache.flex.compiler.clients.ExternCConfiguration;
 import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.MethodReference;
 import org.junit.Test;
 
 import com.google.javascript.rhino.JSDocInfo;
@@ -124,7 +125,10 @@ public class TestTypeExternals extends ExternalsTestBase
 
     private JSType getJSType(String methodName, String paramName)
     {
-        JSDocInfo comment = model.getClassReference("Foo").getMethod(methodName).getComment();
+    	MethodReference method = model.getClassReference("Foo").getInstanceMethod(methodName);
+    	if (method == null)
+    		method = model.getClassReference("Foo").getStaticMethod(methodName);
+        JSDocInfo comment = method.getComment();
         JSTypeExpression parameterType = comment.getParameterType("arg1");
         JSType jsType = model.evaluate(parameterType);
         return jsType;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeInheritence.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeInheritence.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeInheritence.java
index 0f71102..0fb57bc 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeInheritence.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/TestTypeInheritence.java
@@ -69,7 +69,7 @@ public class TestTypeInheritence extends ExternalsTestBase
         // XXX Since Foo implements EventTarget BUT changes it's signature, we have to
         // use EventTargt.addEventListener()'s signature
         String result = client.getEmitter().emit(
-                Foo.getMethod("addEventListener"));
+                Foo.getInstanceMethod("addEventListener"));
         assertEquals(
                 "    /**\n     "
                         + "* @param opt_useCapture [(boolean|undefined)] \n     "

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectImportsPass.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectImportsPass.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectImportsPass.java
index 137f5f8..20381a6 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectImportsPass.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectImportsPass.java
@@ -59,7 +59,7 @@ public class CollectImportsPass extends AbstractCompilerPass
         final List<ClassReference> interfaces = reference.getInterfaces();
         final List<ClassReference> extendedInterfaces = reference.getExtendedInterfaces();
         final Map<String, FieldReference> fields = reference.getFields();
-        final Map<String, MethodReference> methods = reference.getMethods();
+        final List<MethodReference> methods = reference.getAllMethods();
 
         for (ClassReference superClass : superClasses)
         {
@@ -101,7 +101,7 @@ public class CollectImportsPass extends AbstractCompilerPass
             }
         }
 
-        for (MethodReference method : methods.values())
+        for (MethodReference method : methods)
         {
             if (method.isExcluded() == null)
             {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
index 756e37c..cdc7785 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
@@ -21,6 +21,7 @@ package org.apache.flex.compiler.internal.codegen.externals.reference;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -47,7 +48,8 @@ public class ClassReference extends BaseReference
     private Set<String> imports = new HashSet<String>();
     private MethodReference constructor;
     private Map<String, FieldReference> fields = new HashMap<String, FieldReference>();
-    private Map<String, MethodReference> methods = new HashMap<String, MethodReference>();
+    private Map<String, MethodReference> instanceMethods = new HashMap<String, MethodReference>();
+    private Map<String, MethodReference> staticMethods = new HashMap<String, MethodReference>();
 
     private Node nameNode;
 
@@ -88,9 +90,12 @@ public class ClassReference extends BaseReference
         return fields;
     }
 
-    public Map<String, MethodReference> getMethods()
+    public ArrayList<MethodReference> getAllMethods()
     {
-        return methods;
+    	ArrayList<MethodReference> allMethods = new ArrayList<MethodReference>();
+    	allMethods.addAll(staticMethods.values());
+    	allMethods.addAll(instanceMethods.values());
+        return allMethods;
     }
 
     public FieldReference getField(String name)
@@ -98,9 +103,14 @@ public class ClassReference extends BaseReference
         return fields.get(name);
     }
 
-    public MethodReference getMethod(String name)
+    public MethodReference getStaticMethod(String name)
     {
-        return methods.get(name);
+        return staticMethods.get(name);
+    }
+
+    public MethodReference getInstanceMethod(String name)
+    {
+        return instanceMethods.get(name);
     }
 
     public boolean isDynamic()
@@ -347,15 +357,15 @@ public class ClassReference extends BaseReference
         List<ClassReference> list = getSuperClasses();
         for (ClassReference reference : list)
         {
-            if (reference.hasMethod(methodName))
-                return reference.getMethod(methodName);
+            if (reference.hasInstanceMethod(methodName))
+                return reference.getInstanceMethod(methodName);
         }
 
         list = getAllImplInterfaces(); // return all our interfaces and all superclass
         for (ClassReference reference : list)
         {
-            if (reference.hasMethod(methodName))
-                return reference.getMethod(methodName);
+            if (reference.hasInstanceMethod(methodName))
+                return reference.getInstanceMethod(methodName);
         }
 
         return null;
@@ -459,17 +469,17 @@ public class ClassReference extends BaseReference
 
     public boolean hasMethod(String methodName)
     {
-        return methods.containsKey(methodName);
+        return instanceMethods.containsKey(methodName) || staticMethods.containsKey(methodName);
     }
 
     public boolean hasInstanceMethod(String fieldName)
     {
-        return methods.containsKey(fieldName) && !methods.get(fieldName).isStatic();
+        return instanceMethods.containsKey(fieldName);
     }
 
     public boolean hasStaticMethod(String fieldName)
     {
-        return methods.containsKey(fieldName) && methods.get(fieldName).isStatic();
+        return staticMethods.containsKey(fieldName);
     }
 
     public FieldReference addField(Node node, String fieldName, JSDocInfo comment, boolean isStatic)
@@ -514,7 +524,10 @@ public class ClassReference extends BaseReference
 
         MethodReference method = new MethodReference(getModel(), this, node, functionName, comment, isStatic);
 
-        methods.put(functionName, method);
+        if (isStatic)
+        	staticMethods.put(functionName, method);
+        else
+        	instanceMethods.put(functionName, method);
         return method;
     }
 
@@ -554,7 +567,7 @@ public class ClassReference extends BaseReference
             for (ClassReference interfaceReference : interfaces)
             {
                 // check for the method on the interface
-                MethodReference method = interfaceReference.getMethod(reference.getBaseName());
+                MethodReference method = interfaceReference.getInstanceMethod(reference.getBaseName());
                 if (method != null)
                     return method;
             }
@@ -610,7 +623,7 @@ public class ClassReference extends BaseReference
 
     public boolean hasLocalMethodConflict(String functionName)
     {
-        return methods.containsKey(functionName);
+        return instanceMethods.containsKey(functionName) || staticMethods.containsKey(functionName);
     }
 
     public boolean hasFieldConflict(String fieldName)
@@ -751,9 +764,9 @@ public class ClassReference extends BaseReference
 
     private void emitMethods(StringBuilder sb)
     {
-        for (Entry<String, MethodReference> methodSet : getMethods().entrySet())
+        for (MethodReference method : getAllMethods())
         {
-            methodSet.getValue().emit(sb);
+            method.emit(sb);
             sb.append("\n");
         }
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
index 4770d41..aee165f 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
@@ -183,9 +183,13 @@ public class MethodReference extends MemberReference
         String braces = "";
         String returns = "";
 
-        if (!transformReturnString().equals("void"))
+        String returnString = transformReturnString();
+        if (!returnString.equals("void"))
         {
-            returns = " return null;";
+        	if (returnString.equals("Number"))
+        		returns = "return 0;";
+        	else
+        		returns = " return null;";
         }
 
         if (!getClassReference().isInterface())

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
index 46b3797..d683e64 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
@@ -41,7 +41,7 @@ public class FunctionUtils
     {
 
         String parameterType;
-        if (FunctionUtils.hasTemplate(reference))
+        if (FunctionUtils.hasTemplate(reference) && FunctionUtils.containsTemplate(reference, name))
         {
             parameterType = "Object";
         }
@@ -62,7 +62,9 @@ public class FunctionUtils
         if (hasTemplate(reference))
         {
             returnType = JSTypeUtils.toReturnTypeString(reference);
-            if (!returnType.equals("Array"))
+            if (containsTemplate(reference, returnType))
+            	returnType = "Object";
+            else if (returnType.equals("RESULT"))
             	returnType = "Object";
         }
         else
@@ -163,14 +165,11 @@ public class FunctionUtils
         }
         else
         {
-            if (hasTemplate(reference))
+            paramType = JSTypeUtils.toParamTypeString(reference, paramName);
+            if (hasTemplate(reference) && containsTemplate(reference, paramType))
             {
                 paramType = "Object";
             }
-            else
-            {
-                paramType = JSTypeUtils.toParamTypeString(reference, paramName);
-            }
 
             sb.append(paramName);
             sb.append(":");
@@ -203,5 +202,17 @@ public class FunctionUtils
     {
         return reference.getComment().getTemplateTypeNames().size() > 0;
     }
+    
+    public static boolean containsTemplate(BaseReference reference, String name)
+    {
+    	for (String template : reference.getComment().getTemplateTypeNames())
+    	{
+    		if (name.contains("<" + template + ">"))
+    			return true;
+    		if (name.equals(template))
+    			return true;
+    	}
+    	return false;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e39393aa/externs/js/missing.js
----------------------------------------------------------------------
diff --git a/externs/js/missing.js b/externs/js/missing.js
index d602419..499fec2 100644
--- a/externs/js/missing.js
+++ b/externs/js/missing.js
@@ -138,93 +138,3 @@ function Location() {}
  * @type {number}
  */
 XMLHttpRequest.prototype.timeout;
-
-
-/***** hack ****/
-/* below are copies from es3.js, which is:
-   Copyright 2008 The Closure Compiler Authors
-   
-   es3.js includes Mozilla-only static versions
-   of these methods which confuses the externs compiler.  The externs compiler
-   currently doesn't expect a class to have a static and instance method of the
-   same name.  Last definition found wins so by re-declaring here the instance
-   methods win out */
-/**
- * Available in ECMAScript 5, Mozilla 1.6+.
- * @param {T} obj
- * @param {number=} opt_fromIndex
- * @return {number}
- * @this {{length: number}|Array.<T>|string}
- * @nosideeffects
- * @template T
- * @see http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/indexOf
- */
-Array.prototype.indexOf = function(obj, opt_fromIndex) {};
-
-/**
- * Available in ECMAScript 5, Mozilla 1.6+.
- * @param {T} obj
- * @param {number=} opt_fromIndex
- * @return {number}
- * @this {{length: number}|Array.<T>|string}
- * @nosideeffects
- * @template T
- * @see http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/lastIndexOf
- */
-Array.prototype.lastIndexOf = function(obj, opt_fromIndex) {};
-
-/**
- * Available in ECMAScript 5, Mozilla 1.6+.
- * @param {?function(this:S, T, number, !Array.<T>): ?} callback
- * @param {S=} opt_thisobj
- * @return {boolean}
- * @this {{length: number}|Array.<T>|string}
- * @template T,S
- * @see http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/every
- */
-Array.prototype.every = function(callback, opt_thisobj) {};
-
-/**
- * Available in ECMAScript 5, Mozilla 1.6+.
- * @param {?function(this:S, T, number, !Array.<T>): ?} callback
- * @param {S=} opt_thisobj
- * @return {!Array.<T>}
- * @this {{length: number}|Array.<T>|string}
- * @template T,S
- * @see http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/filter
- */
-Array.prototype.filter = function(callback, opt_thisobj) {};
-
-/**
- * Available in ECMAScript 5, Mozilla 1.6+.
- * @param {?function(this:S, T, number, !Array.<T>): ?} callback
- * @param {S=} opt_thisobj
- * @this {{length: number}|Array.<T>|string}
- * @template T,S
- * @see http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/forEach
- */
-Array.prototype.forEach = function(callback, opt_thisobj) {};
-
-/**
- * Available in ECMAScript 5, Mozilla 1.6+.
- * @param {?function(this:S, T, number, !Array.<T>): R} callback
- * @param {S=} opt_thisobj
- * @return {!Array.<R>}
- * @this {{length: number}|Array.<T>|string}
- * @template T,S,R
- * @see http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/map
- */
-Array.prototype.map = function(callback, opt_thisobj) {};
-
-/**
- * Available in ECMAScript 5, Mozilla 1.6+.
- * @param {?function(this:S, T, number, !Array.<T>): ?} callback
- * @param {S=} opt_thisobj
- * @return {boolean}
- * @this {{length: number}|Array.<T>|string}
- * @template T,S
- * @see http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/some
- */
-Array.prototype.some = function(callback, opt_thisobj) {};
-
-/**** end hack **/
\ No newline at end of file


[2/2] git commit: [flex-falcon] [refs/heads/develop] - make sure we handle simple allowed circular references

Posted by ah...@apache.org.
make sure we handle simple allowed circular references


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/74fdfbfd
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/74fdfbfd
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/74fdfbfd

Branch: refs/heads/develop
Commit: 74fdfbfd5e7c64a742d9888b6572187ee49de59c
Parents: e39393a
Author: Alex Harui <ah...@apache.org>
Authored: Mon Nov 30 16:05:08 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Nov 30 16:05:08 2015 -0800

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSProject.java    | 15 +++++++
 .../test-files/flexjs/projects/circular/Base.as | 30 +++++++++++++
 .../flexjs/projects/circular/Base_result.js     | 43 ++++++++++++++++++
 .../flexjs/projects/circular/Super.as           | 27 +++++++++++
 .../flexjs/projects/circular/Super_result.js    | 47 ++++++++++++++++++++
 5 files changed, 162 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/74fdfbfd/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSProject.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSProject.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSProject.java
index faac533..dcc3c56 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSProject.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSProject.java
@@ -93,6 +93,21 @@ public class TestFlexJSProject extends TestGoogProject
     }
 
     @Test
+    public void test_IsItCircular()
+    {
+        String testDirPath = projectDirPath + "/circular";
+
+        String fileName = "Base";
+
+        sourcePath = "test-files"
+            + File.separator + projectDirPath + "/circular";
+        
+        List<String> compiledFileNames = compileProject(fileName, testDirPath);
+
+        assertProjectOut(compiledFileNames, testDirPath);
+    }
+
+    @Test
     public void test_PackageConflict_AmbiguousDefinition()
     {
         String testDirPath = projectDirPath + "/package_conflicts_ambiguous_definition";

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/74fdfbfd/compiler.jx.tests/test-files/flexjs/projects/circular/Base.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/projects/circular/Base.as b/compiler.jx.tests/test-files/flexjs/projects/circular/Base.as
new file mode 100644
index 0000000..64798d8
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/circular/Base.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+	import Super;
+
+  public class Base extends Super
+  {
+    public function Base() 
+    {
+      super();
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/74fdfbfd/compiler.jx.tests/test-files/flexjs/projects/circular/Base_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/projects/circular/Base_result.js b/compiler.jx.tests/test-files/flexjs/projects/circular/Base_result.js
new file mode 100644
index 0000000..fac69d9
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/circular/Base_result.js
@@ -0,0 +1,43 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * Base
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes|accessControls}
+ */
+
+goog.provide('Base');
+
+goog.require('Super');
+
+
+
+/**
+ * @constructor
+ * @extends {Super}
+ */
+Base = function() {
+  Base.base(this, 'constructor');
+};
+goog.inherits(Base, Super);
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+Base.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Base', qName: 'Base'}] };

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/74fdfbfd/compiler.jx.tests/test-files/flexjs/projects/circular/Super.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/projects/circular/Super.as b/compiler.jx.tests/test-files/flexjs/projects/circular/Super.as
new file mode 100644
index 0000000..d72a859
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/circular/Super.as
@@ -0,0 +1,27 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+  public class Super
+  {
+    public function Super() {}
+
+    private static var isItCircular:Base;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/74fdfbfd/compiler.jx.tests/test-files/flexjs/projects/circular/Super_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/projects/circular/Super_result.js b/compiler.jx.tests/test-files/flexjs/projects/circular/Super_result.js
new file mode 100644
index 0000000..64afaa2
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/circular/Super_result.js
@@ -0,0 +1,47 @@
+/**
+ * Licensed 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.
+ */
+/**
+ * Super
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes|accessControls}
+ */
+
+goog.provide('Super');
+
+goog.require('Base');
+
+
+
+/**
+ * @constructor
+ */
+Super = function() {
+};
+
+
+/**
+ * @private
+ * @type {Base}
+ */
+Super.isItCircular;
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+Super.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Super', qName: 'Super'}] };