diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2009-04-14 00:37:13 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2009-04-14 00:37:13 +0000 |
commit | 780069f8d4312a88ad580b16cc656b69ec3e23ba (patch) | |
tree | 14e2e939206b40647149f1f5696984e40b43453e | |
parent | e6ba542a6ee9bf5c0092406bbd5130abefcd90c8 (diff) | |
download | javassist-780069f8d4312a88ad580b16cc656b69ec3e23ba.tar.gz javassist-780069f8d4312a88ad580b16cc656b69ec3e23ba.zip |
improved the extensibility of CodeConverter
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@477 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r-- | src/main/javassist/CodeConverter.java | 15 | ||||
-rw-r--r-- | src/main/javassist/convert/Transformer.java | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/main/javassist/CodeConverter.java b/src/main/javassist/CodeConverter.java index 91f5657a..44881d5d 100644 --- a/src/main/javassist/CodeConverter.java +++ b/src/main/javassist/CodeConverter.java @@ -512,16 +512,25 @@ public class CodeConverter { } int locals = 0; + int stack = 0; for (t = transformers; t != null; t = t.getNext()) { int s = t.extraLocals(); if (s > locals) locals = s; + + s = t.extraStack(); + if (s > stack) + stack = s; } for (t = transformers; t != null; t = t.getNext()) t.clean(); - codeAttr.setMaxLocals(codeAttr.getMaxLocals() + locals); + if (locals > 0) + codeAttr.setMaxLocals(codeAttr.getMaxLocals() + locals); + + if (stack > 0) + codeAttr.setMaxStack(codeAttr.getMaxStack() + stack); } /** @@ -529,7 +538,7 @@ public class CodeConverter { * as array access replacements. * * @author <a href="kabir.khan@jboss.com">Kabir Khan</a> - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ */ public interface ArrayAccessReplacementMethodNames { @@ -638,7 +647,7 @@ public class CodeConverter { * accesses to array elements. * * @author <a href="kabir.khan@jboss.com">Kabir Khan</a> - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ */ public static class DefaultArrayAccessReplacementMethodNames implements ArrayAccessReplacementMethodNames diff --git a/src/main/javassist/convert/Transformer.java b/src/main/javassist/convert/Transformer.java index 1095cf5b..4dd38075 100644 --- a/src/main/javassist/convert/Transformer.java +++ b/src/main/javassist/convert/Transformer.java @@ -51,4 +51,6 @@ public abstract class Transformer implements Opcode { ConstPool cp) throws CannotCompileException, BadBytecode; public int extraLocals() { return 0; } + + public int extraStack() { return 0; } } |