royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-compiler] branch develop updated: keep trying to decorate the right names
Date Tue, 30 Oct 2018 07:28:14 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


The following commit(s) were added to refs/heads/develop by this push:
     new 2f7260f  keep trying to decorate the right names
2f7260f is described below

commit 2f7260f561bb60215a4ad3f8ae6faf20c890f2a0
Author: Alex Harui <aharui@apache.org>
AuthorDate: Tue Oct 30 00:27:58 2018 -0700

    keep trying to decorate the right names
---
 .../compiler/internal/codegen/js/jx/AccessorEmitter.java    | 12 +++++++++---
 .../compiler/internal/codegen/js/jx/IdentifierEmitter.java  |  7 ++++---
 .../internal/codegen/mxml/royale/MXMLRoyaleEmitter.java     | 13 ++++++++++---
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
index a31ee90..ce3fd25 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
@@ -29,6 +29,7 @@ import org.apache.royale.compiler.common.IMetaInfo;
 import org.apache.royale.compiler.common.ModifiersSet;
 import org.apache.royale.compiler.definitions.IAccessorDefinition;
 import org.apache.royale.compiler.definitions.IClassDefinition;
+import org.apache.royale.compiler.definitions.IDefinition;
 import org.apache.royale.compiler.definitions.IFunctionDefinition;
 import org.apache.royale.compiler.definitions.INamespaceDefinition;
 import org.apache.royale.compiler.definitions.IParameterDefinition;
@@ -667,12 +668,15 @@ public class AccessorEmitter extends JSSubEmitter implements
         // TODO (mschmalle) will remove this cast as more things get abstracted
         JSRoyaleEmitter fjs = (JSRoyaleEmitter) getEmitter();
 
-        ModifiersSet modifierSet = node.getDefinition().getModifiers();
+        IDefinition def = node.getDefinition();
+        ModifiersSet modifierSet = def.getModifiers();
         boolean isStatic = (modifierSet != null && modifierSet
                 .hasModifier(ASModifier.STATIC));
         HashMap<String, PropertyNodes> map = isStatic ? getModel()
                 .getStaticPropertyMap() : getModel().getPropertyMap();
         String name = node.getName();
+    	if (!isStatic && def != null && def.isPrivate() && getProject().getAllowPrivateNameConflicts())
+    		name = fjs.formatPrivateName(def.getParent().getQualifiedName(), name);
         PropertyNodes p = map.get(name);
         if (p == null)
         {
@@ -693,12 +697,15 @@ public class AccessorEmitter extends JSSubEmitter implements
         JSRoyaleEmitter fjs = (JSRoyaleEmitter) getEmitter();
         JSRoyaleDocEmitter doc = (JSRoyaleDocEmitter) fjs.getDocEmitter();
 
-        ModifiersSet modifierSet = node.getDefinition().getModifiers();
+        IFunctionDefinition def = node.getDefinition();
+        ModifiersSet modifierSet = def.getModifiers();
         boolean isStatic = (modifierSet != null && modifierSet
                 .hasModifier(ASModifier.STATIC));
         HashMap<String, PropertyNodes> map = isStatic ? getModel()
                 .getStaticPropertyMap() : getModel().getPropertyMap();
         String name = node.getName();
+    	if (!isStatic && def != null && def.isPrivate() && getProject().getAllowPrivateNameConflicts())
+    		name = fjs.formatPrivateName(def.getParent().getQualifiedName(), name);
         PropertyNodes p = map.get(name);
         if (p == null)
         {
@@ -709,7 +716,6 @@ public class AccessorEmitter extends JSSubEmitter implements
         ICompilerProject project = (ICompilerProject)getWalker().getProject();
         if (project != null)
         {
-        	IFunctionDefinition def = node.getDefinition();
         	IParameterDefinition[] params = def.getParameters();
         	p.type = params[0].resolveType(project);
         }
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
index 1cdd74f..3874676 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
@@ -26,6 +26,7 @@ import org.apache.royale.compiler.definitions.IDefinition;
 import org.apache.royale.compiler.definitions.IFunctionDefinition;
 import org.apache.royale.compiler.definitions.IFunctionDefinition.FunctionClassification;
 import org.apache.royale.compiler.definitions.INamespaceDefinition;
+import org.apache.royale.compiler.definitions.IParameterDefinition;
 import org.apache.royale.compiler.definitions.IVariableDefinition;
 import org.apache.royale.compiler.definitions.IVariableDefinition.VariableClassification;
 import org.apache.royale.compiler.definitions.references.INamespaceResolvedReference;
@@ -244,7 +245,7 @@ public class IdentifierEmitter extends JSSubEmitter implements
                 else
                 {
             		String qname = node.getName();
-                	if (nodeDef != null && nodeDef.isPrivate() && getProject().getAllowPrivateNameConflicts())
+                	if (nodeDef != null && (!(nodeDef instanceof IParameterDefinition))
&& nodeDef.isPrivate() && getProject().getAllowPrivateNameConflicts())
                 		qname = getEmitter().formatPrivateName(nodeDef.getParent().getQualifiedName(),
qname);
             		write(qname);
                 }
@@ -318,7 +319,7 @@ public class IdentifierEmitter extends JSSubEmitter implements
                 	else
                 	{
                 		qname = node.getName();
-                    	if (nodeDef != null && nodeDef.isPrivate() && getProject().getAllowPrivateNameConflicts())
+                    	if (nodeDef != null && (!(nodeDef instanceof IParameterDefinition))
&& nodeDef.isPrivate() && getProject().getAllowPrivateNameConflicts())
                     		qname = getEmitter().formatPrivateName(nodeDef.getParent().getQualifiedName(),
qname);
                 		write(qname);
                 	}
@@ -338,7 +339,7 @@ public class IdentifierEmitter extends JSSubEmitter implements
                 }
                 else 
                 {
-                	if (nodeDef != null && nodeDef.isPrivate() && getProject().getAllowPrivateNameConflicts())
+                	if (nodeDef != null && (!(nodeDef instanceof IParameterDefinition))
&& nodeDef.isPrivate() && getProject().getAllowPrivateNameConflicts())
                 		qname = getEmitter().formatPrivateName(nodeDef.getParent().getQualifiedName(),
qname);
                     write(qname);
                 }
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
index 1fe07c1..0eef72f 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
@@ -2980,16 +2980,23 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements
 
                         if (vnode != null && (!EmitterUtils.isScalar(vnode)))
     			        {
+    	                    IDefinition varDef = varnode.getDefinition();
+    	                    if (varDef.isStatic())
+    	                    	continue;
     	                    writeNewline();
     	                    write(ASEmitterTokens.THIS);
     	                    write(ASEmitterTokens.MEMBER_ACCESS);
-    	                    write(varnode.getName());
+    	                    JSRoyaleEmitter fjs = (JSRoyaleEmitter) ((IMXMLBlockWalker) getMXMLWalker())
+    	                    .getASEmitter();
+    		    	        ICompilerProject project = getMXMLWalker().getProject();
+    	                    String qname = varnode.getName();
+    	                	if (varDef != null && varDef.isPrivate() && project.getAllowPrivateNameConflicts())
+    	                		qname = fjs.formatPrivateName(varDef.getParent().getQualifiedName(),
qname);
+    	                    write(qname);
     	                    if (schildID == ASTNodeID.BindableVariableID && !varnode.isConst())
     	                    	write("_"); // use backing variable
     	                    write(ASEmitterTokens.SPACE);
     	                    writeToken(ASEmitterTokens.EQUAL);
-    	                    JSRoyaleEmitter fjs = (JSRoyaleEmitter) ((IMXMLBlockWalker) getMXMLWalker())
-    	                    .getASEmitter();
     	                    fjs.getWalker().walk(vnode);
     	                    write(ASEmitterTokens.SEMICOLON);
 


Mime
View raw message