Repository: flex-falcon
Updated Branches:
  refs/heads/develop f8fa738fb -> 2f6f611b1


compiler-jx: Class class must be dynamic, added hasFunction() to ReferenceModel 
in externc, and added some tests for Class, int, uint, and trace()


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

Branch: refs/heads/develop
Commit: 2f6f611b124c0e267c60df4807dc1533abcfc730
Parents: f8fa738
Author: Josh Tynjala <joshtynj...@gmail.com>
Authored: Mon Aug 22 15:50:11 2016 -0700
Committer: Josh Tynjala <joshtynj...@gmail.com>
Committed: Mon Aug 22 15:54:41 2016 -0700

----------------------------------------------------------------------
 .../externals/reference/ReferenceModel.java     |  10 +-
 .../codegen/externals/TestExternJSMissing.java  | 108 +++++++++++++++++++
 2 files changed, 117 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2f6f611b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
----------------------------------------------------------------------
diff --git 
a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
 
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
index 15623ad..c50806d 100644
--- 
a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
+++ 
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
@@ -146,8 +146,11 @@ public class ReferenceModel
         ClassReference reference = new ClassReference(this, node, 
qualifiedName);
 
         // TODO (mschmalle) Figure out if gcc makes any decisions about what 
is final or dynamic
-        if (reference.getQualifiedName().equals("Object"))
+        if (reference.getQualifiedName().equals("Object")
+            || reference.getQualifiedName().equals("Class"))
+        {
             reference.setDynamic(true);
+        }
 
         classes.put(qualifiedName, reference);
     }
@@ -222,6 +225,11 @@ public class ReferenceModel
         functions.put(qualifiedName, reference);
     }
 
+    public boolean hasFunction(String functionName)
+    {
+        return functions.containsKey(functionName);
+    }
+
     public boolean hasClass(String className)
     {
         return classes.containsKey(className);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2f6f611b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternJSMissing.java
----------------------------------------------------------------------
diff --git 
a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternJSMissing.java
 
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternJSMissing.java
new file mode 100644
index 0000000..9d859ca
--- /dev/null
+++ 
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternJSMissing.java
@@ -0,0 +1,108 @@
+/*
+ *
+ *  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.codegen.externals;
+
+import java.io.IOException;
+
+import org.apache.flex.compiler.clients.ExternCConfiguration;
+import 
org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+
+import com.google.javascript.jscomp.Result;
+import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestExternJSMissing extends ExternalsTestBase
+{
+    @Test
+    public void test_classes() throws IOException
+    {
+        Result result = compile();
+        assertTrue(result.success);
+
+        String[] classes = {
+                "int",
+                "uint",
+                "Class" };
+
+        for (String className : classes)
+        {
+            assertTrue(model.hasClass(className));
+        }
+    }
+    @Test
+    public void test_functions() throws IOException
+    {
+        Result result = compile();
+        assertTrue(result.success);
+
+        String[] functions = {
+                "trace" };
+
+        for (String functionName : functions)
+        {
+            assertTrue(model.hasFunction(functionName));
+        }
+    }
+
+    @Test
+    public void test_Class() throws IOException
+    {
+        Result result = compile();
+        assertTrue(result.success);
+
+        ClassReference ClassClass = model.getClassReference("Class");
+        assertNotNull(ClassClass);
+        assertTrue(ClassClass.isDynamic());
+    }
+
+    @Test
+    public void test_int() throws IOException
+    {
+        Result result = compile();
+        assertTrue(result.success);
+
+        ClassReference intClass = model.getClassReference("int");
+        assertNotNull(intClass);
+        assertTrue(intClass.hasStaticField("MIN_VALUE"));
+        assertTrue(intClass.hasStaticField("MAX_VALUE"));
+    }
+
+    @Test
+    public void test_uint() throws IOException
+    {
+        Result result = compile();
+        assertTrue(result.success);
+
+        ClassReference uintClass = model.getClassReference("uint");
+        assertNotNull(uintClass);
+        assertTrue(uintClass.hasStaticField("MIN_VALUE"));
+        assertTrue(uintClass.hasStaticField("MAX_VALUE"));
+    }
+
+    @Override
+    protected void configure(ExternCConfiguration config) throws IOException
+    {
+        ExternalsTestUtils.init();
+        config.setASRoot(ExternalsTestUtils.AS_ROOT_DIR);
+
+        config.addExternal(ExternalsTestUtils.MISSING_JS_FILE);
+    }
+}

Reply via email to