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/03/08 09:18:54 UTC
[royale-compiler] 02/03: refactor so we don't have to generate
instructionlists
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 179b777346ba90a1649575865875c9edcf810f6a
Author: Alex Harui <ah...@apache.org>
AuthorDate: Wed Mar 7 14:51:43 2018 -0800
refactor so we don't have to generate instructionlists
---
.../internal/as/codegen/ABCGeneratingReducer.java | 49 +-------------------
.../internal/as/codegen/DirectiveProcessor.java | 52 ++++++++++++++++++++++
2 files changed, 53 insertions(+), 48 deletions(-)
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java
index cbfba57..4204a9b 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java
@@ -6702,54 +6702,7 @@ public class ABCGeneratingReducer
public InstructionList transform_name_to_expression(IASNode iNode, Binding name)
{
- // hack to allow override as a separate keyword in a conditional compile block.
- // the AST thinks it is a property on the class named override.
- // This allows less coding when in SWF the base class has a method that needs
- // overriding but the JS base class does not. Instead of writing
- // COMPILE::SWF
- // override public function foo() {
- // method body
- // }
- // COMPILE::JS
- // public function foo() {
- // an exact copy of method body
- // }
- // we want to allow:
- // COMPILE::SWF { override }
- // public function foo() {
- // method body
- // }
- if (iNode.getNodeID() == ASTNodeID.IdentifierID)
- {
- IdentifierNode node = (IdentifierNode)iNode;
- if (node.getName().equals("override"))
- {
- IASNode parent = node.getParent();
- if (parent.getNodeID() == ASTNodeID.ConfigBlockID)
- {
- IASNode parentOfMethods = parent.getParent();
- int functionCount = parentOfMethods.getChildCount();
- for (int i = 0; i < functionCount; i++)
- {
- IASNode child = parentOfMethods.getChild(i);
- if (child == parent)
- {
- // examine the next node
- child = parentOfMethods.getChild(i + 1);
- if (child instanceof IFunctionNode)
- {
- // convince the compiler that this is now an override
- IFunctionNode fnode = (IFunctionNode)child;
- FunctionDefinition fdef = (FunctionDefinition)fnode.getDefinition();
- fdef.setOverride();
- // return no instructions
- return new InstructionList();
- }
- }
- }
- }
- }
- }
+
return generateAccess(name, determineAccessType(iNode));
}
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/DirectiveProcessor.java b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/DirectiveProcessor.java
index 22b6df9..d199a88 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/DirectiveProcessor.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/DirectiveProcessor.java
@@ -23,8 +23,11 @@ import java.util.Collection;
+import org.apache.royale.abc.instructionlist.InstructionList;
+import org.apache.royale.compiler.internal.definitions.FunctionDefinition;
import org.apache.royale.compiler.internal.tree.as.ClassNode;
import org.apache.royale.compiler.internal.tree.as.FunctionNode;
+import org.apache.royale.compiler.internal.tree.as.IdentifierNode;
import org.apache.royale.compiler.internal.tree.as.ImportNode;
import org.apache.royale.compiler.internal.tree.as.InterfaceNode;
import org.apache.royale.compiler.internal.tree.as.NamespaceIdentifierNode;
@@ -37,7 +40,9 @@ import static org.apache.royale.abc.ABCConstants.TRAIT_Setter;
import org.apache.royale.compiler.problems.BURMDiagnosticNotAllowedHereProblem;
import org.apache.royale.compiler.problems.ICompilerProblem;
+import org.apache.royale.compiler.tree.ASTNodeID;
import org.apache.royale.compiler.tree.as.IASNode;
+import org.apache.royale.compiler.tree.as.IFunctionNode;
import org.apache.royale.compiler.tree.mxml.IMXMLDocumentNode;
@@ -237,6 +242,53 @@ class DirectiveProcessor
processConfigBlock(n);
break;
default:
+ // hack to allow override as a separate keyword in a conditional compile block.
+ // the AST thinks it is a property on the class named override.
+ // This allows less coding when in SWF the base class has a method that needs
+ // overriding but the JS base class does not. Instead of writing
+ // COMPILE::SWF
+ // override public function foo() {
+ // method body
+ // }
+ // COMPILE::JS
+ // public function foo() {
+ // an exact copy of method body
+ // }
+ // we want to allow:
+ // COMPILE::SWF { override }
+ // public function foo() {
+ // method body
+ // }
+ if (n.getNodeID() == ASTNodeID.IdentifierID)
+ {
+ IdentifierNode node = (IdentifierNode)n;
+ if (node.getName().equals("override"))
+ {
+ IASNode parent = node.getParent();
+ if (parent.getNodeID() == ASTNodeID.ConfigBlockID)
+ {
+ IASNode parentOfMethods = parent.getParent();
+ int functionCount = parentOfMethods.getChildCount();
+ for (int i = 0; i < functionCount; i++)
+ {
+ IASNode child = parentOfMethods.getChild(i);
+ if (child == parent)
+ {
+ // examine the next node
+ child = parentOfMethods.getChild(i + 1);
+ if (child instanceof IFunctionNode)
+ {
+ // convince the compiler that this is now an override
+ IFunctionNode fnode = (IFunctionNode)child;
+ FunctionDefinition fdef = (FunctionDefinition)fnode.getDefinition();
+ fdef.setOverride();
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
processDirective(n);
}
}
--
To stop receiving notification emails like this one, please contact
aharui@apache.org.