flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/7] git commit: [flex-falcon] [refs/heads/develop] - Fixed various problems handling static versus instance fields/methods
Date Wed, 06 Jan 2016 07:37:00 GMT
Fixed various problems handling static versus instance fields/methods


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

Branch: refs/heads/develop
Commit: a57ff6e17c852d92b8e938d0bb3c690140a37d92
Parents: 9c6437d
Author: Andy Dufilie <andrew.dufilie@iweave.com>
Authored: Tue Jan 5 13:10:40 2016 -0500
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Jan 5 23:31:55 2016 -0800

----------------------------------------------------------------------
 .../codegen/externals/pass/AddMemberPass.java   |  4 +-
 .../externals/pass/CollectImportsPass.java      |  5 +-
 .../externals/reference/ClassReference.java     | 59 ++++++++++----------
 .../externals/reference/FieldReference.java     |  2 +-
 .../as/codegen/ClassDirectiveProcessor.java     |  2 +-
 .../semantics/MethodBodySemanticChecker.java    |  4 +-
 6 files changed, 37 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a57ff6e1/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
index 4798ceb..8379af9 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
@@ -93,7 +93,7 @@ public class AddMemberPass extends AbstractCompilerPass
 
         if (n.getFirstChild().isGetProp())
         {
-            int protoType = qName.indexOf(".prototype");
+            int protoType = qName.indexOf(".prototype.");
             if (protoType != -1)
             {
                 String className = qName.substring(0, protoType);
@@ -126,7 +126,7 @@ public class AddMemberPass extends AbstractCompilerPass
 
         log("visitGetProp [" + qualifiedName + "]");
 
-        int protoType = qualifiedName.indexOf(".prototype");
+        int protoType = qualifiedName.indexOf(".prototype.");
         if (protoType != -1)
         {
             String className = qualifiedName.substring(0, protoType);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a57ff6e1/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 20381a6..d934610 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
@@ -20,7 +20,6 @@
 package org.apache.flex.compiler.internal.codegen.externals.pass;
 
 import java.util.List;
-import java.util.Map;
 
 import org.apache.flex.compiler.internal.codegen.externals.reference.*;
 
@@ -58,7 +57,7 @@ public class CollectImportsPass extends AbstractCompilerPass
         final List<ClassReference> superClasses = reference.getSuperClasses();
         final List<ClassReference> interfaces = reference.getInterfaces();
         final List<ClassReference> extendedInterfaces = reference.getExtendedInterfaces();
-        final Map<String, FieldReference> fields = reference.getFields();
+        final List<FieldReference> fields = reference.getAllFields();
         final List<MethodReference> methods = reference.getAllMethods();
 
         for (ClassReference superClass : superClasses)
@@ -85,7 +84,7 @@ public class CollectImportsPass extends AbstractCompilerPass
             }
         }
 
-        for (FieldReference field : fields.values())
+        for (FieldReference field : fields)
         {
             if (field.isExcluded() == null)
             {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a57ff6e1/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 183b70c..59c5859 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
@@ -48,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, FieldReference> instanceFields = new HashMap<String, FieldReference>();
+    private Map<String, FieldReference> staticFields = new HashMap<String, FieldReference>();
     private Map<String, MethodReference> instanceMethods = new HashMap<String, MethodReference>();
     private Map<String, MethodReference> staticMethods = new HashMap<String, MethodReference>();
 
@@ -86,22 +87,32 @@ public class ClassReference extends BaseReference
         return constructor;
     }
 
-    public Map<String, FieldReference> getFields()
+    public ArrayList<FieldReference> getAllFields()
     {
-        return fields;
+        ArrayList<FieldReference> allMethods = new ArrayList<FieldReference>();
+        if (!isInterface())
+        	allMethods.addAll(staticFields.values());
+        allMethods.addAll(instanceFields.values());
+        return allMethods;
     }
 
     public ArrayList<MethodReference> getAllMethods()
     {
     	ArrayList<MethodReference> allMethods = new ArrayList<MethodReference>();
-    	allMethods.addAll(staticMethods.values());
+    	if (!isInterface())
+    		allMethods.addAll(staticMethods.values());
     	allMethods.addAll(instanceMethods.values());
         return allMethods;
     }
 
-    public FieldReference getField(String name)
+    public FieldReference getStaticField(String name)
+    {
+    	return staticFields.get(name);
+    }
+    
+    public FieldReference getInstanceField(String name)
     {
-        return fields.get(name);
+        return instanceFields.get(name);
     }
 
     public MethodReference getStaticMethod(String name)
@@ -374,7 +385,7 @@ public class ClassReference extends BaseReference
         List<ClassReference> list = getSuperClasses();
         for (ClassReference reference : list)
         {
-            if (reference.hasField(fieldName))
+            if (reference.hasInstanceField(fieldName))
                 return true;
         }
         return false;
@@ -385,7 +396,7 @@ public class ClassReference extends BaseReference
         List<ClassReference> list = getSuperClasses();
         for (ClassReference reference : list)
         {
-            if (reference.hasMethod(methodName))
+            if (reference.hasInstanceMethod(methodName))
                 return true;
         }
         return false;
@@ -491,24 +502,14 @@ public class ClassReference extends BaseReference
         return result;
     }
 
-    public boolean hasField(String fieldName)
-    {
-        return fields.containsKey(fieldName);
-    }
-
     public boolean hasInstanceField(String fieldName)
     {
-        return fields.containsKey(fieldName) && !fields.get(fieldName).isStatic();
+        return instanceFields.containsKey(fieldName);
     }
 
     public boolean hasStaticField(String fieldName)
     {
-        return fields.containsKey(fieldName) && fields.get(fieldName).isStatic();
-    }
-
-    public boolean hasMethod(String methodName)
-    {
-        return instanceMethods.containsKey(methodName) || staticMethods.containsKey(methodName);
+        return staticFields.containsKey(fieldName);
     }
 
     public boolean hasInstanceMethod(String fieldName)
@@ -523,7 +524,7 @@ public class ClassReference extends BaseReference
 
     public FieldReference addField(Node node, String fieldName, JSDocInfo comment, boolean
isStatic)
     {
-        if (hasField(fieldName))
+        if (isStatic ? hasStaticField(fieldName) : hasInstanceField(fieldName))
         {
             // XXX Warning
             return null;
@@ -545,7 +546,10 @@ public class ClassReference extends BaseReference
 
         FieldReference field = new FieldReference(getModel(), this, node, fieldName, comment,
isStatic);
 
-        fields.put(fieldName, field);
+        if (isStatic)
+        	staticFields.put(fieldName, field);
+        else
+        	instanceFields.put(fieldName, field);
         return field;
     }
 
@@ -658,7 +662,7 @@ public class ClassReference extends BaseReference
                 System.err.println("isPropertyInterfaceImplementation() null");
                 continue;
             }
-            if (interfaceRef.hasFieldConflict(fieldName))
+            if (interfaceRef.hasInstanceField(fieldName))
                 return true;
         }
         return false;
@@ -669,11 +673,6 @@ public class ClassReference extends BaseReference
         return instanceMethods.containsKey(functionName) || staticMethods.containsKey(functionName);
     }
 
-    public boolean hasFieldConflict(String fieldName)
-    {
-        return fields.containsKey(fieldName);
-    }
-
     public void addImport(ClassReference reference)
     {
         if (reference != null)
@@ -836,9 +835,9 @@ public class ClassReference extends BaseReference
 
     private void emitFields(StringBuilder sb)
     {
-        for (Entry<String, FieldReference> fieldSet : getFields().entrySet())
+        for (FieldReference field : getAllFields())
         {
-            fieldSet.getValue().emit(sb);
+            field.emit(sb);
             sb.append("\n");
             nextEnumConstant();
         }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a57ff6e1/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
index 226cb19..d99a66d 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
@@ -120,7 +120,7 @@ public class FieldReference extends MemberReference
     {
         boolean isInterface = getClassReference().isInterface();
 
-        String staticValue = "";//(isStatic) ? "static " : "";
+        String staticValue = (isStatic) ? "static " : "";
         String isPublic = isInterface ? "" : "public ";
         String getBody = isInterface ? "" : "{ return null; }";
         String setBody = isInterface ? "" : "{}";

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a57ff6e1/compiler/src/org/apache/flex/compiler/internal/as/codegen/ClassDirectiveProcessor.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/as/codegen/ClassDirectiveProcessor.java
b/compiler/src/org/apache/flex/compiler/internal/as/codegen/ClassDirectiveProcessor.java
index 21afb92..d6ab0b1 100644
--- a/compiler/src/org/apache/flex/compiler/internal/as/codegen/ClassDirectiveProcessor.java
+++ b/compiler/src/org/apache/flex/compiler/internal/as/codegen/ClassDirectiveProcessor.java
@@ -1098,7 +1098,7 @@ class ClassDirectiveProcessor extends DirectiveProcessor
         }
         else
         {
-            checker.checkClassField(var, is_static);
+            checker.checkClassField(var);
             //  Massive kludge -- grovel over chained variable decls and add them one by
one
             for ( int i = 0; i < var.getChildCount(); i++ )
             {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a57ff6e1/compiler/src/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
b/compiler/src/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
index 67a934b..2d1f9f1 100644
--- a/compiler/src/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
+++ b/compiler/src/org/apache/flex/compiler/internal/semantics/MethodBodySemanticChecker.java
@@ -2467,7 +2467,7 @@ public class MethodBodySemanticChecker
     /**
      *  Check a class field declaration.
      */
-    public void checkClassField(VariableNode var, final boolean is_const)
+    public void checkClassField(VariableNode var)
     {
         checkVariableDeclaration(var);
 
@@ -2815,7 +2815,7 @@ public class MethodBodySemanticChecker
                 addProblem(problem);
         }
 
-        if (SemanticUtils.hasBaseClassDefinition(iNode, project) )
+        if (!varDef.isStatic() && SemanticUtils.hasBaseClassDefinition(iNode, project))
         {
             addProblem(new ConflictingInheritedNameInNamespaceProblem(iNode, varDef.getBaseName(),
getNamespaceStringFromDef(varDef) ));
         }


Mime
View raw message