You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ms...@apache.org on 2013/01/10 23:42:10 UTC

svn commit: r1431713 - /flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java

Author: mschmalle
Date: Thu Jan 10 22:42:10 2013
New Revision: 1431713

URL: http://svn.apache.org/viewvc?rev=1431713&view=rev
Log:
Flex:FalconJx:
- Removed TraverseContext from ASBlockWalker

Modified:
    flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java

Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java?rev=1431713&r1=1431712&r2=1431713&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java Thu Jan 10 22:42:10 2013
@@ -21,7 +21,6 @@ package org.apache.flex.compiler.interna
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Stack;
 
 import org.apache.flex.compiler.as.codegen.IASEmitter;
 import org.apache.flex.compiler.definitions.IClassDefinition;
@@ -30,7 +29,6 @@ import org.apache.flex.compiler.definiti
 import org.apache.flex.compiler.internal.semantics.SemanticUtils;
 import org.apache.flex.compiler.internal.tree.as.BaseLiteralContainerNode;
 import org.apache.flex.compiler.internal.tree.as.ContainerNode;
-import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionObjectNode;
 import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
 import org.apache.flex.compiler.internal.tree.as.NamespaceAccessExpressionNode;
@@ -102,29 +100,6 @@ import org.apache.flex.compiler.visitor.
  */
 public class ASBlockWalker implements IASBlockVisitor, IASBlockWalker
 {
-    /**
-     * The context stack of the visitor.
-     * <p>
-     * The context can only contain what is beneath them, CLASS contains
-     * FUNCTION.
-     */
-    // TODO (mschmalle) definitely having second thoughts about TraverseContext
-    // now that I'm understanding the AST a bit more, this is just garbage overhead
-    public enum TraverseContext
-    {
-        ROOT,
-        FILE,
-        PACKAGE,
-        TYPE,
-        CONSTRUCTOR,
-        FIELD,
-        METHOD,
-        BLOCK,
-        FOR,
-        FUNCTION,
-        SUPER_ARGUMENTS
-    }
-
     private IASEmitter emitter;
 
     private final List<ICompilerProblem> errors;
@@ -135,29 +110,6 @@ public class ASBlockWalker implements IA
     }
 
     //----------------------------------
-    // context
-    //----------------------------------
-
-    private Stack<TraverseContext> contexts = new Stack<ASBlockWalker.TraverseContext>();
-
-    public void pushContext(TraverseContext value)
-    {
-        contexts.push(value);
-    }
-
-    public void popContext(TraverseContext lastContext)
-    {
-        TraverseContext popped = contexts.pop();
-        if (lastContext != popped)
-            throw new RuntimeException("Popped context not the same");
-    }
-
-    private boolean inContext(TraverseContext context)
-    {
-        return contexts.peek() == context;
-    }
-
-    //----------------------------------
     // strategy
     //----------------------------------
 
@@ -227,7 +179,6 @@ public class ASBlockWalker implements IA
         this.project = project;
         this.emitter = emitter;
         emitter.setWalker(this);
-        pushContext(TraverseContext.ROOT);
     }
 
     @Override
@@ -286,7 +237,7 @@ public class ASBlockWalker implements IA
     public void visitInterface(IInterfaceNode node)
     {
         debug("visitInterface()");
-        
+
         emitter.emitInterface(node);
     }
 
@@ -363,30 +314,13 @@ public class ASBlockWalker implements IA
 
         walk(node.getNameNode());
 
-        if (((FunctionCallNode) node).isSuperExpression())
-        {
-            pushContext(TraverseContext.SUPER_ARGUMENTS);
-        }
-
         emitter.write("(");
         walkArguments(node.getArgumentNodes());
         emitter.write(")");
-
-        if (((FunctionCallNode) node).isSuperExpression())
-        {
-            popContext(TraverseContext.SUPER_ARGUMENTS);
-        }
     }
 
     private void walkArguments(IExpressionNode[] nodes)
     {
-        if (inContext(TraverseContext.SUPER_ARGUMENTS))
-        {
-            //emitter.write("this");
-            //if (nodes.length > 0)
-            //    emitter.write(", ");
-        }
-
         int len = nodes.length;
         for (int i = 0; i < len; i++)
         {
@@ -508,7 +442,6 @@ public class ASBlockWalker implements IA
     {
         debug("visitForEach()");
         IContainerNode xnode = (IContainerNode) node.getChild(1);
-        pushContext(TraverseContext.FOR);
         emitter.write("for");
         emitter.write(" ");
         emitter.write("each");
@@ -522,7 +455,6 @@ public class ASBlockWalker implements IA
         if (!isImplicit(xnode))
             emitter.write(" ");
 
-        popContext(TraverseContext.FOR);
         walk(node.getStatementContentsNode());
     }
 
@@ -530,7 +462,7 @@ public class ASBlockWalker implements IA
     {
         debug("visitFor()");
         IContainerNode xnode = (IContainerNode) node.getChild(1);
-        pushContext(TraverseContext.FOR);
+
         emitter.write("for");
         emitter.write(" ");
         emitter.write("(");
@@ -549,7 +481,7 @@ public class ASBlockWalker implements IA
         emitter.write(")");
         if (!isImplicit(xnode))
             emitter.write(" ");
-        popContext(TraverseContext.FOR);
+
         walk(node.getStatementContentsNode());
     }
 
@@ -853,7 +785,7 @@ public class ASBlockWalker implements IA
     {
         debug("visitBinaryOperator(" + node.getOperator().getOperatorText()
                 + ")");
-        
+
         emitter.emitBinaryOperator(node);
     }