flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [4/5] git commit: [flex-falcon] [refs/heads/develop] - add -compiler.allow-subclass-overrides option to build 'extern' swcs
Date Tue, 22 Mar 2016 04:01:57 GMT
add -compiler.allow-subclass-overrides option to build 'extern' swcs


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

Branch: refs/heads/develop
Commit: 69eb3d52e6d592b4763d9ded7f65c08f9abef0ea
Parents: 0d5b35f
Author: Alex Harui <aharui@apache.org>
Authored: Mon Mar 21 08:18:12 2016 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Mar 21 21:01:45 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSProject.java      | 18 ++++++++++++++++++
 .../codegen/js/jx/MemberAccessEmitter.java        |  5 -----
 .../compiler/internal/projects/FlexJSProject.java | 12 ------------
 .../src/org/apache/flex/compiler/clients/ASC.java |  9 ++++++++-
 .../flex/compiler/config/Configuration.java       | 18 ++++++++++++++++++
 .../compiler/internal/config/TargetSettings.java  |  6 ++++++
 .../compiler/internal/projects/FlexProject.java   | 13 +++++++++++++
 .../flex/compiler/targets/ITargetSettings.java    |  6 ++++++
 8 files changed, 69 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/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 feba941..7a739c1 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
@@ -28,7 +28,9 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.exceptions.ConfigurationException;
 import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogProject;
+import org.apache.flex.compiler.internal.config.TargetSettings;
 import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
 import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
@@ -132,6 +134,14 @@ public class TestFlexJSProject extends TestGoogProject
 
         String fileName = "Test";
 
+        try {
+			((FlexJSProject)project).config.setCompilerAllowSubclassOverrides(null, true);
+		} catch (ConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+        project.setTargetSettings(new TargetSettings(((FlexJSProject)project).config));
+        
         sourcePath = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
                 projectDirPath + "/overrides").getPath();
 
@@ -148,6 +158,14 @@ public class TestFlexJSProject extends TestGoogProject
 
         String fileName = "Test";
 
+        try {
+			((FlexJSProject)project).config.setCompilerAllowSubclassOverrides(null, true);
+		} catch (ConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+        project.setTargetSettings(new TargetSettings(((FlexJSProject)project).config));
+        
         sourcePath = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
                 projectDirPath + "/bad_overrides").getPath();
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
index 305b2e9..0421a5c 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
@@ -64,11 +64,6 @@ public class MemberAccessEmitter extends JSSubEmitter implements
         IASNode leftNode = node.getLeftOperandNode();
         IASNode rightNode = node.getRightOperandNode();
 
-        String leftName = "";
-        if (leftNode instanceof IdentifierNode)
-        {
-        	leftName = ((IdentifierNode)leftNode).getName();
-        }
     	JSFlexJSEmitter fjs = (JSFlexJSEmitter)getEmitter();
         IDefinition def = node.resolve(getProject());
         if (def == null)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/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 15cf7ab..a1098a7 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
@@ -26,7 +26,6 @@ import java.util.Set;
 
 import org.apache.flex.compiler.common.DependencyType;
 import org.apache.flex.compiler.definitions.IDefinition;
-import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitterTokens;
 import org.apache.flex.compiler.internal.css.codegen.CSSCompilationSession;
 import org.apache.flex.compiler.internal.definitions.InterfaceDefinition;
@@ -260,15 +259,4 @@ public class FlexJSProject extends FlexProject
 			e.printStackTrace();
 		}
     }
-
-    @Override
-    public boolean isCompatibleOverrideReturnType(ITypeDefinition overrideDefinition, ITypeDefinition
baseDefinition)
-    {
-        if (baseDefinition == overrideDefinition)
-        	return true;
-        if (overrideDefinition != null && baseDefinition != null &&
-        		overrideDefinition.isInstanceOf(baseDefinition.getQualifiedName(), this))
-        	return true;
-        return false;
-    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/compiler/src/org/apache/flex/compiler/clients/ASC.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/clients/ASC.java b/compiler/src/org/apache/flex/compiler/clients/ASC.java
index 3befd95..432a445 100644
--- a/compiler/src/org/apache/flex/compiler/clients/ASC.java
+++ b/compiler/src/org/apache/flex/compiler/clients/ASC.java
@@ -447,7 +447,14 @@ public class ASC
         @Override
         public boolean getMxmlChildrenAsData()
         {
-            // Not used because ASC does not create SWCs.
+            // Not used because ASC does handle MXML.
+            return false;
+        }    
+
+        @Override
+        public boolean getAllowSubclassOverrides()
+        {
+            // Not used because ASC is not used in cross-compiling.
             return false;
         }    
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/compiler/src/org/apache/flex/compiler/config/Configuration.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/config/Configuration.java b/compiler/src/org/apache/flex/compiler/config/Configuration.java
index ae20994..6516464 100644
--- a/compiler/src/org/apache/flex/compiler/config/Configuration.java
+++ b/compiler/src/org/apache/flex/compiler/config/Configuration.java
@@ -2324,6 +2324,24 @@ public class Configuration
     }
 
     //
+    // 'compiler.allow-subclass-overrides' option
+    //
+    private Boolean allowSubclassOverrides = false;
+
+    public Boolean getCompilerAllowSubclassOverrides()
+    {
+        return allowSubclassOverrides;
+    }
+
+    @Config
+    @Mapping({ "compiler", "allow-subclass-override" })
+    @FlexOnly
+    public void setCompilerAllowSubclassOverrides(ConfigurationValue cv, Boolean allow) throws
ConfigurationException
+    {
+        allowSubclassOverrides = allow;
+    }
+
+    //
     // 'compiler.mxml.implicitImports' option
     //
     private String[] implicitImports;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/compiler/src/org/apache/flex/compiler/internal/config/TargetSettings.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/config/TargetSettings.java b/compiler/src/org/apache/flex/compiler/internal/config/TargetSettings.java
index 0d84e88..03ba470 100644
--- a/compiler/src/org/apache/flex/compiler/internal/config/TargetSettings.java
+++ b/compiler/src/org/apache/flex/compiler/internal/config/TargetSettings.java
@@ -569,6 +569,12 @@ public class TargetSettings implements ITargetSettings
     }
 
     @Override
+    public boolean getAllowSubclassOverrides()
+    {
+        return configuration.getCompilerMxmlChildrenAsData();
+    }
+
+    @Override
     public boolean getRemoveDeadCode()
     {
         return configuration.getRemoveDeadCode();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
index 9180fe1..6b44dd2 100644
--- a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
+++ b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
@@ -49,6 +49,7 @@ import org.apache.flex.compiler.definitions.INamespaceDefinition;
 import org.apache.flex.compiler.definitions.IScopedDefinition;
 import org.apache.flex.compiler.definitions.ISetterDefinition;
 import org.apache.flex.compiler.definitions.IStyleDefinition;
+import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.definitions.IVariableDefinition;
 import org.apache.flex.compiler.definitions.references.INamespaceReference;
 import org.apache.flex.compiler.definitions.references.IResolvedQualifiersReference;
@@ -2170,4 +2171,16 @@ public class FlexProject extends ASProject implements IFlexProject
     {
         return this.strictXML = strictXML;
     }
+    
+    @Override
+    public boolean isCompatibleOverrideReturnType(ITypeDefinition overrideDefinition, ITypeDefinition
baseDefinition)
+    {
+        if (baseDefinition == overrideDefinition)
+            return true;
+        if (targetSettings != null && targetSettings.getAllowSubclassOverrides()
&& overrideDefinition != null && baseDefinition != null &&
+                overrideDefinition.isInstanceOf(baseDefinition.getQualifiedName(), this))
+            return true;
+        return false;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/69eb3d52/compiler/src/org/apache/flex/compiler/targets/ITargetSettings.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/targets/ITargetSettings.java b/compiler/src/org/apache/flex/compiler/targets/ITargetSettings.java
index 7300b02..f223f50 100644
--- a/compiler/src/org/apache/flex/compiler/targets/ITargetSettings.java
+++ b/compiler/src/org/apache/flex/compiler/targets/ITargetSettings.java
@@ -465,6 +465,12 @@ public interface ITargetSettings
     boolean getMxmlChildrenAsData();
     
     /**
+     * @return true if the return type of an override can be a subclass instead
+     * of an exact match as the base class' return type
+     */
+    boolean getAllowSubclassOverrides();
+    
+    /**
      * @return true if the dead code filtering optimization step is enabled.
      */
     boolean getRemoveDeadCode();


Mime
View raw message