tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1092828 - in /tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic: InstructionBuilderImpl.java SwitchBlockImpl.java TryCatchBlockImpl.java
Date Fri, 15 Apr 2011 22:18:03 GMT
Author: hlship
Date: Fri Apr 15 22:18:03 2011
New Revision: 1092828

URL: http://svn.apache.org/viewvc?rev=1092828&view=rev
Log:
TAP5-853: Use a single InstructionBuilderImpl instance for the entirety of changing a method
implementation

Modified:
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/InstructionBuilderImpl.java
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/SwitchBlockImpl.java
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/TryCatchBlockImpl.java

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/InstructionBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/InstructionBuilderImpl.java?rev=1092828&r1=1092827&r2=1092828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/InstructionBuilderImpl.java
(original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/InstructionBuilderImpl.java
Fri Apr 15 22:18:03 2011
@@ -106,15 +106,12 @@ public class InstructionBuilderImpl exte
 
     InstructionBuilderImpl(MethodDescription description, MethodVisitor visitor, NameCache
cache)
     {
-        this(new InstructionBuilderState(description, visitor, cache));
-    }
-
-    InstructionBuilderImpl(InstructionBuilderState state)
-    {
+        InstructionBuilderState state = new InstructionBuilderState(description, visitor,
cache);
         this.state = state;
 
         // These are conveniences for values stored inside the state. In fact,
         // these fields predate the InstructionBuilderState type.
+
         this.v = state.visitor;
         this.cache = state.nameCache;
     }
@@ -424,7 +421,7 @@ public class InstructionBuilderImpl exte
     {
         check();
 
-        new TryCatchBlockImpl(state).doCallback(callback);
+        new TryCatchBlockImpl(this, state).doCallback(callback);
 
         return this;
     }
@@ -587,7 +584,7 @@ public class InstructionBuilderImpl exte
 
         assert callback != null;
 
-        new SwitchBlockImpl(state, min, max).doCallback(callback);
+        new SwitchBlockImpl(this, state, min, max).doCallback(callback);
 
         return this;
     }
@@ -598,13 +595,13 @@ public class InstructionBuilderImpl exte
 
         final LocalVariable var = state.startVariable(type);
 
-        runSubBuilder(new InstructionBuilderCallback()
+        new InstructionBuilderCallback()
         {
             public void doBuild(InstructionBuilder builder)
             {
                 callback.doBuild(var, builder);
             }
-        });
+        }.doBuild(this);
 
         state.stopVariable(var);
 
@@ -663,25 +660,25 @@ public class InstructionBuilderImpl exte
 
         v.visitJumpInsn(conditionToOpcode.get(condition), ifFalseLabel);
 
-        runSubBuilder(new InstructionBuilderCallback()
+        new InstructionBuilderCallback()
         {
             public void doBuild(InstructionBuilder builder)
             {
                 callback.ifTrue(builder);
             }
-        });
+        }.doBuild(this);
 
         v.visitJumpInsn(GOTO, endIfLabel);
 
         v.visitLabel(ifFalseLabel);
 
-        runSubBuilder(new InstructionBuilderCallback()
+        new InstructionBuilderCallback()
         {
             public void doBuild(InstructionBuilder builder)
             {
                 callback.ifFalse(builder);
             }
-        });
+        }.doBuild(this);
 
         v.visitLabel(endIfLabel);
 
@@ -699,23 +696,23 @@ public class InstructionBuilderImpl exte
 
         Label exitLoop = new Label();
 
-        runSubBuilder(new InstructionBuilderCallback()
+        new InstructionBuilderCallback()
         {
             public void doBuild(InstructionBuilder builder)
             {
                 callback.buildTest(builder);
             }
-        });
+        }.doBuild(this);
 
         v.visitJumpInsn(conditionToOpcode.get(condition), exitLoop);
 
-        runSubBuilder(new InstructionBuilderCallback()
+        new InstructionBuilderCallback()
         {
             public void doBuild(InstructionBuilder builder)
             {
                 callback.buildBody(builder);
             }
-        });
+        }.doBuild(this);
 
         v.visitJumpInsn(GOTO, doCheck);
 
@@ -807,11 +804,6 @@ public class InstructionBuilderImpl exte
         return this;
     }
 
-    private void runSubBuilder(InstructionBuilderCallback callback)
-    {
-        new InstructionBuilderImpl(state).doCallback(callback);
-    }
-
     void doCallback(InstructionBuilderCallback callback)
     {
         check();

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/SwitchBlockImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/SwitchBlockImpl.java?rev=1092828&r1=1092827&r2=1092828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/SwitchBlockImpl.java
(original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/SwitchBlockImpl.java
Fri Apr 15 22:18:03 2011
@@ -23,6 +23,8 @@ import org.apache.tapestry5.plastic.Swit
 
 public class SwitchBlockImpl extends Lockable implements SwitchBlock, Opcodes
 {
+    private final InstructionBuilder builder;
+
     private final InstructionBuilderState state;
 
     private final int min, max;
@@ -33,10 +35,11 @@ public class SwitchBlockImpl extends Loc
 
     private boolean defaultAdded = false;
 
-    SwitchBlockImpl(InstructionBuilderState state, int min, int max)
+    SwitchBlockImpl(InstructionBuilder builder, InstructionBuilderState state, int min, int
max)
     {
         assert min <= max;
 
+        this.builder = builder;
         this.state = state;
         this.min = min;
         this.max = max;
@@ -89,7 +92,7 @@ public class SwitchBlockImpl extends Loc
 
         state.visitor.visitLabel(caseLabels[caseValue - min]);
 
-        new InstructionBuilderImpl(state).doCallback(callback);
+        callback.doBuild(builder);
 
         if (jumpToEnd)
             state.visitor.visitJumpInsn(GOTO, endSwitchLabel);
@@ -102,7 +105,7 @@ public class SwitchBlockImpl extends Loc
 
         state.visitor.visitLabel(defaultLabel);
 
-        new InstructionBuilderImpl(state).doCallback(callback);
+        callback.doBuild(builder);
 
         defaultAdded = true;
     }

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/TryCatchBlockImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/TryCatchBlockImpl.java?rev=1092828&r1=1092827&r2=1092828&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/TryCatchBlockImpl.java
(original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/TryCatchBlockImpl.java
Fri Apr 15 22:18:03 2011
@@ -15,19 +15,24 @@
 package org.apache.tapestry5.internal.plastic;
 
 import org.apache.tapestry5.internal.plastic.asm.Label;
+import org.apache.tapestry5.plastic.InstructionBuilder;
 import org.apache.tapestry5.plastic.InstructionBuilderCallback;
 import org.apache.tapestry5.plastic.TryCatchBlock;
 import org.apache.tapestry5.plastic.TryCatchCallback;
 
 public class TryCatchBlockImpl extends Lockable implements TryCatchBlock
 {
+    private final InstructionBuilder builder;
+
     private final InstructionBuilderState state;
 
     private final Label startLabel, endLabel;
 
-    TryCatchBlockImpl(InstructionBuilderState state)
+    TryCatchBlockImpl(InstructionBuilder builder, InstructionBuilderState state)
     {
+        this.builder = builder;
         this.state = state;
+
         this.startLabel = new Label();
         this.endLabel = new Label();
     }
@@ -36,7 +41,7 @@ public class TryCatchBlockImpl extends L
     {
         state.visitor.visitLabel(startLabel);
 
-        new InstructionBuilderImpl(state).doCallback(callback);
+        callback.doBuild(builder);
 
         state.visitor.visitLabel(endLabel);
     }
@@ -54,7 +59,7 @@ public class TryCatchBlockImpl extends L
 
         Label handler = state.newLabel();
 
-        new InstructionBuilderImpl(state).doCallback(callback);
+        callback.doBuild(builder);
 
         state.visitor.visitTryCatchBlock(startLabel, endLabel, handler, exceptionInternalName);
     }



Mime
View raw message