You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/08/08 17:39:22 UTC

[royale-compiler] 02/03: allow substitutions in method visibility

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 c9f54f91a69829e9a2364e65c0965dec0200ec61
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Aug 7 21:54:36 2018 -0700

    allow substitutions in method visibility
---
 .../royale/compiler/internal/parsing/as/ASParser.g | 26 ++++++++++++++++++++++
 .../internal/parsing/as/ConfigProcessor.java       | 10 +++++++++
 2 files changed, 36 insertions(+)

diff --git a/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g b/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g
index 6a7ac9c..c9b1528 100644
--- a/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g
+++ b/compiler/src/main/antlr/org/apache/royale/compiler/internal/parsing/as/ASParser.g
@@ -222,6 +222,7 @@ attributedDefinition[ContainerNode c]
 attribute [List<ModifierNode> modifiers, List<INamespaceDecorationNode> namespaceAttributes] 
 {
     ExpressionNodeBase namespaceNode = null; 
+    ExpressionNodeBase configAsNamespaceNode = null; 
     ModifierNode modifierNode = null;
 }
     :   modifierNode=modifierAttribute
@@ -234,8 +235,33 @@ attribute [List<ModifierNode> modifiers, List<INamespaceDecorationNode> namespac
             if (namespaceNode instanceof INamespaceDecorationNode)
                 namespaceAttributes.add((INamespaceDecorationNode) namespaceNode); 
         }
+    |   configAsNamespaceNode=configConditionAsNamespaceModifier
+        {
+            if (configAsNamespaceNode instanceof INamespaceDecorationNode)
+                namespaceAttributes.add((INamespaceDecorationNode) configAsNamespaceNode); 
+        }
     ;
 	
+configConditionAsNamespaceModifier returns [ExpressionNodeBase n]
+{
+    n = null; 
+}
+    :   ns:TOKEN_NAMESPACE_NAME op:TOKEN_OPERATOR_NS_QUALIFIER id:TOKEN_NAMESPACE_ANNOTATION
+        { final NamespaceIdentifierNode nsNode = new NamespaceIdentifierNode((ASToken)ns); 
+          nsNode.setIsConfigNamespace(isConfigNamespace(nsNode));
+	  final IdentifierNode idNode = new IdentifierNode((ASToken)id);
+	  final IdentifierNode idNode2 = (IdentifierNode)transformToNSAccessExpression(nsNode, (ASToken) op, idNode);
+          n = new NamespaceIdentifierNode(idNode2.getName());
+          n = n.copyForInitializer(null);
+	  n.setSourcePath(nsNode.getSourcePath());
+	  n.setLine(nsNode.getLine());
+	  n.setColumn(nsNode.getColumn());
+	  n.setEndLine(idNode.getEndLine());
+	  n.setEndColumn(idNode.getEndColumn());
+	  n.setStart(nsNode.getStart());
+	  n.setEnd(idNode.getEnd());
+        }
+    ;
 	
 /**
  * Matches a definition of variable, function, namespace, class or interface.
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ConfigProcessor.java b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ConfigProcessor.java
index 2cef61d..5966459 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ConfigProcessor.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/as/ConfigProcessor.java
@@ -29,6 +29,7 @@ import java.util.List;
 import antlr.Token;
 
 import org.apache.royale.abc.ABCConstants;
+import org.apache.royale.abc.semantics.Namespace;
 import org.apache.royale.compiler.constants.IASLanguageConstants;
 import org.apache.royale.compiler.definitions.IDefinition;
 import org.apache.royale.compiler.internal.definitions.ConstantDefinition;
@@ -511,6 +512,15 @@ public class ConfigProcessor
         	IdentifierNode id = (IdentifierNode)result;
         	return id;
         }
+        else if (result instanceof Namespace)
+        {
+        	Namespace ns = (Namespace)result;
+        	String nsName = ns.getName();
+        	if (nsName.length() == 0)
+        		nsName = "public";
+        	
+        	return new IdentifierNode(nsName);
+        }
         return null;
     }