Commits

Shashank Bharadwaj  committed 7b7ee09

formattting

  • Participants
  • Parent commits 88b93d8

Comments (0)

Files changed (1)

File fix-asm-via-cfg.patch

 new file mode 100644
 --- /dev/null
 +++ b/src/org/python/antlr/ast/WithExit.java
-@@ -0,0 +1,49 @@
-+/**
-+ * 
-+ */
+@@ -0,0 +1,46 @@
 +package org.python.antlr.ast;
 +
 +import org.python.antlr.base.expr;
 new file mode 100644
 --- /dev/null
 +++ b/src/org/python/antlr/ast/WithSpecialLoad.java
-@@ -0,0 +1,47 @@
-+/**
-+ * 
-+ */
+@@ -0,0 +1,43 @@
 +package org.python.antlr.ast;
 +
 +import org.python.antlr.base.expr;
-+import org.python.core.PyObject;
 +import org.python.core.PyType;
 +
 +/**
 new file mode 100644
 --- /dev/null
 +++ b/src/org/python/antlr/ast/YieldInput.java
-@@ -0,0 +1,22 @@
-+// Autogenerated AST node
+@@ -0,0 +1,25 @@
 +package org.python.antlr.ast;
 +
 +import org.python.antlr.base.expr;
 +import org.python.core.PyType;
 +
++/**
++ * A node to represent the work of loading of the input value of a
++ * <code>yield</code> expression (sent via <code>send</code>).
++ */
 +public class YieldInput extends expr {
 +    public static final PyType TYPE = PyType.fromClass(YieldInput.class);
 +
 new file mode 100644
 --- /dev/null
 +++ b/src/org/python/antlr/ast/YieldRestoreLocals.java
-@@ -0,0 +1,22 @@
-+// Autogenerated AST node
+@@ -0,0 +1,25 @@
 +package org.python.antlr.ast;
 +
 +import org.python.antlr.base.stmt;
 +import org.python.core.PyType;
 +
++/**
++ * A node representing the work of restoring the local variables when the
++ * generator resumes.
++ */
 +public class YieldRestoreLocals extends stmt {
 +    public static final PyType TYPE = PyType.fromClass(YieldRestoreLocals.class);
 +
 new file mode 100644
 --- /dev/null
 +++ b/src/org/python/antlr/ast/YieldReturn.java
-@@ -0,0 +1,43 @@
-+// Autogenerated AST node
+@@ -0,0 +1,45 @@
 +package org.python.antlr.ast;
 +
 +import org.python.antlr.base.expr;
 +import org.python.antlr.base.stmt;
 +import org.python.core.PyType;
 +
++/**
++ * A node representing the work in a generator of returning a yielded value.
++ */
 +public class YieldReturn extends stmt {
 +    public static final PyType TYPE = PyType.fromClass(YieldReturn.class);
 +
 +    public expr value;
-+    
++
 +    public YieldReturn(Yield yield) {
 +        this.value = yield.getInternalValue();
 +    }
          code.goto_(breakLabels.peek());
          return null;
      }
-@@ -640,23 +645,63 @@
+@@ -640,23 +645,23 @@
              throw new ParseException("'continue' not properly in loop", node);
          }
  
          code.goto_(continueLabels.peek());
          return Exit;
      }
- 
-+//    @Override
-+//    public Object visitYield(Yield node) throws Exception {
-+//        setline(node);
-+//        if (!fast_locals) {
-+//            throw new ParseException("'yield' outside function", node);
-+//        }
-+//
-+//        int stackState = saveStack();
-+//
-+//        if (node.getInternalValue() != null) {
-+//            visit(node.getInternalValue());
-+//        } else {
-+//            getNone();
-+//        }
-+//
-+//        setLastI(++yield_count);
-+//
-+//        saveLocals();
-+//        code.areturn();
-+//
-+//        Label restart = new Label();
-+//        yields.addElement(restart);
-+//        code.label(restart);
-+//        restoreLocals();
-+//        restoreStack(stackState);
-+//
-+//        loadFrame();
-+//        code.invokevirtual(p(PyFrame.class), "getGeneratorInput", sig(Object.class));
-+//        code.dup();
-+//        code.instanceof_(p(PyException.class));
-+//        Label done2 = new Label();
-+//        code.ifeq(done2);
-+//        code.checkcast(p(Throwable.class));
-+//        code.athrow();
-+//        code.label(done2);
-+//        code.checkcast(p(PyObject.class));
-+//
-+//        return null;
-+//    }
+-
 +    
 +    int stackState;
 +    
          } else {
              getNone();
          }
-@@ -665,11 +710,20 @@
+@@ -665,11 +670,20 @@
  
          saveLocals();
          code.areturn();
          restoreStack(stackState);
  
          loadFrame();
-@@ -783,26 +837,16 @@
-     /**
-      *  Close all the open exception handler ranges.  This should be paired
-      *  with restartExceptionHandlers to delimit internal code that
+@@ -754,8 +768,6 @@
+     }
+ 
+     private void restoreLocals() throws Exception {
+-        endExceptionHandlers();
+-
+         Vector<String> v = code.getActiveLocals();
+ 
+         loadFrame();
+@@ -776,33 +788,6 @@
+             code.astore(i);
+         }
+         code.freeLocal(locals);
+-
+-        restartExceptionHandlers();
+-    }
+-
+-    /**
+-     *  Close all the open exception handler ranges.  This should be paired
+-     *  with restartExceptionHandlers to delimit internal code that
 -     *  shouldn't be handled by user handlers.  This allows us to set 
-+     *  shouldn't be handled by user handlers.  This allows us to set
-      *  variables without the verifier thinking we might jump out of our
-      *  handling with an exception.
-      */
-     private void endExceptionHandlers() {
+-     *  variables without the verifier thinking we might jump out of our
+-     *  handling with an exception.
+-     */
+-    private void endExceptionHandlers() {
 -        Label end = new Label();
 -        code.label(end);
 -        for (int i = 0; i < exceptionHandlers.size(); ++i) {
 -            ExceptionHandler handler = exceptionHandlers.elementAt(i);
 -            handler.exceptionEnds.addElement(end);
 -        }
-+        // FIXME(shashank): move this functionality into IRBuilder
-     }
- 
-     private void restartExceptionHandlers() {
+-    }
+-
+-    private void restartExceptionHandlers() {
 -        Label start = new Label();
 -        code.label(start);
 -        for (int i = 0; i < exceptionHandlers.size(); ++i) {
 -            ExceptionHandler handler = exceptionHandlers.elementAt(i);
 -            handler.exceptionStarts.addElement(start);
 -        }
-+        // FIXME(shashank): move this functionality into IRBuilder
      }
  
      private void saveLocals() throws Exception {
-@@ -854,7 +898,6 @@
+@@ -854,7 +839,6 @@
              tmp = code.getReturnLocal();
              code.astore(tmp);
          }
  
          setLastI(-1);
  
-@@ -901,7 +944,7 @@
+@@ -901,7 +885,7 @@
      }
  
      /**
       */
      private void defaultImportLevel() {
      	// already prepared for a future change of DEFAULT_LEVEL
-@@ -909,9 +952,9 @@
+@@ -909,9 +893,9 @@
              code.iconst_0();
          } else {
              code.iconst_m1();
      @Override
      public Object visitImport(Import node) throws Exception {
          setline(node);
-@@ -1151,15 +1194,12 @@
+@@ -1151,15 +1135,12 @@
      public int beginLoop() {
          continueLabels.push(new Label());
          breakLabels.push(new Label());
      }
  
      @Override
-@@ -1240,6 +1280,8 @@
+@@ -1240,6 +1221,8 @@
          code.ifnonnull(start_loop);
  
          finishLoop(savebcf);
  
          if (node.getInternalOrelse() != null) {
              //Do else clause if provided
-@@ -1248,8 +1290,6 @@
+@@ -1248,8 +1231,6 @@
  
          code.label(break_loop);
  
  
          // Probably need to detect "guaranteed exits"
          return null;
-@@ -1258,7 +1298,11 @@
+@@ -1258,7 +1239,11 @@
      public void exceptionTest(int exc, Label end_of_exceptions,
              TryExcept node, int index)
              throws Exception {
              ExceptHandler handler = (ExceptHandler) node.getInternalHandlers().get(i);
  
              //setline(name);
-@@ -1282,6 +1326,11 @@
+@@ -1282,6 +1267,11 @@
                  code.aload(exc);
                  code.getfield(p(PyException.class), "value", ci(PyObject.class));
                  set(handler.getInternalName());
              }
  
              //do exception body
-@@ -1294,41 +1343,29 @@
+@@ -1294,41 +1284,29 @@
      }
  
      @Override
          code.astore(excLocal);
  
          code.aload(excLocal);
-@@ -1337,109 +1374,77 @@
+@@ -1337,109 +1315,77 @@
          code.invokestatic(p(Py.class), "addTraceback",
                  sig(Void.TYPE, Throwable.class, PyFrame.class));
  
          return null;
      }
  
-@@ -1449,13 +1454,14 @@
+@@ -1449,13 +1395,14 @@
      }
  
      public Object suite(java.util.List<stmt> stmts) throws Exception {
      }
  
      @Override
-@@ -2263,7 +2269,7 @@
+@@ -2263,7 +2210,7 @@
              super(tree, value);
          }
      }
      @Override
      public Object visitLambda(Lambda node) throws Exception {
          String name = "<lambda>";
-@@ -2560,19 +2566,31 @@
+@@ -2560,19 +2507,31 @@
          scope.setup_closure();
          scope.dump();
  
              if (i != 0) {
                  n = new For(comp, comp.getInternalTarget(), comp.getInternalIter(), bod,
                          new ArrayList<stmt>());
-@@ -2584,7 +2602,12 @@
+@@ -2584,7 +2543,12 @@
          }
  
          java.util.List<stmt> bod = new ArrayList<stmt>();
          module.codeConstant(new Suite(node, bod), "<genexpr>", true,
                  className, false, false,
                  node.getLine(), scope, cflags).get(code);
-@@ -2614,125 +2637,63 @@
+@@ -2614,125 +2578,63 @@
      }
  
      @Override
          return null;
      }
  
-@@ -2741,62 +2702,4 @@
+@@ -2741,62 +2643,4 @@
          throw new Exception("Unhandled node " + node);
      }