royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-compiler] 01/02: try a faster way of figuring out if something is a member of a particular class. fixes #36
Date Fri, 30 Mar 2018 07:08:09 GMT
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit dbbcee56ac0edaf8d077bb06d159c7a9b2ae057d
Author: Alex Harui <aharui@apache.org>
AuthorDate: Thu Mar 29 22:15:52 2018 -0700

    try a faster way of figuring out if something is a member of a particular class.  fixes
#36
---
 .../internal/codegen/js/utils/EmitterUtils.java    | 45 ++++------------------
 1 file changed, 7 insertions(+), 38 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/utils/EmitterUtils.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/utils/EmitterUtils.java
index 2729cab..b80e657 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/utils/EmitterUtils.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/utils/EmitterUtils.java
@@ -414,53 +414,22 @@ public class EmitterUtils
     public static boolean isClassMember(ICompilerProject project,
             IDefinition nodeDef, IClassNode classNode)
     {
-    	if (nodeDef.isInternal() && (!(nodeDef.getParent() instanceof ClassDefinition)))
+        IDefinition parentDef = nodeDef.getParent();
+    	if (nodeDef.isInternal() && (!(parentDef instanceof ClassDefinition)))
     		return false;
     	
-        TypeScope cscope = (TypeScope) classNode.getDefinition()
-                .getContainedScope();
-
-        Set<INamespaceDefinition> nsSet = cscope.getNamespaceSet(project);
-        Collection<IDefinition> defs = new HashSet<IDefinition>();
-
-        cscope.getAllPropertiesForMemberAccess((CompilerProject) project, defs,
-                nsSet);
-
-        Iterator<IDefinition> visiblePropertiesIterator = defs.iterator();
-        while (visiblePropertiesIterator.hasNext())
-        {
-            if (nodeDef.getQualifiedName().equals(
-                    visiblePropertiesIterator.next().getQualifiedName()))
-                return true;
-        }
-
-        return false;
+        IClassDefinition cdef = classNode.getDefinition();
+        return parentDef == cdef || (parentDef instanceof ClassDefinition && cdef.isInstanceOf((ClassDefinition)parentDef,
project));
     }
     
     public static boolean isClassMember(ICompilerProject project,
             IDefinition nodeDef, IClassDefinition classDef)
     {
-    	if (nodeDef.isInternal() && (!(nodeDef.getParent() instanceof ClassDefinition)))
+        IDefinition parentDef = nodeDef.getParent();
+    	if (nodeDef.isInternal() && (!(parentDef instanceof ClassDefinition)))
     		return false;
     	
-        TypeScope cscope = (TypeScope) classDef
-                .getContainedScope();
-
-        Set<INamespaceDefinition> nsSet = cscope.getNamespaceSet(project);
-        Collection<IDefinition> defs = new HashSet<IDefinition>();
-
-        cscope.getAllPropertiesForMemberAccess((CompilerProject) project, defs,
-                nsSet);
-
-        Iterator<IDefinition> visiblePropertiesIterator = defs.iterator();
-        while (visiblePropertiesIterator.hasNext())
-        {
-            if (nodeDef.getQualifiedName().equals(
-                    visiblePropertiesIterator.next().getQualifiedName()))
-                return true;
-        }
-
-        return false;
+        return parentDef == classDef || (parentDef instanceof ClassDefinition &&
((ClassDefinition)parentDef).isInstanceOf(classDef, project));
     }
     
     public static boolean isScalar(IExpressionNode node)

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

Mime
View raw message