diff options
Diffstat (limited to 'src/main/javassist/bytecode/stackmap/TypedBlock.java')
-rw-r--r-- | src/main/javassist/bytecode/stackmap/TypedBlock.java | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/src/main/javassist/bytecode/stackmap/TypedBlock.java b/src/main/javassist/bytecode/stackmap/TypedBlock.java index 65dce97..14fa7f2 100644 --- a/src/main/javassist/bytecode/stackmap/TypedBlock.java +++ b/src/main/javassist/bytecode/stackmap/TypedBlock.java @@ -1,11 +1,12 @@ /* * Javassist, a Java-bytecode translator toolkit. - * Copyright (C) 1999-2007 Shigeru Chiba. All Rights Reserved. + * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved. * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. Alternatively, the contents of this file may be used under - * the terms of the GNU Lesser General Public License Version 2.1 or later. + * the terms of the GNU Lesser General Public License Version 2.1 or later, + * or the Apache License Version 2.0. * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License @@ -15,26 +16,24 @@ package javassist.bytecode.stackmap; -import javassist.bytecode.*; +import javassist.bytecode.AccessFlag; +import javassist.bytecode.BadBytecode; +import javassist.bytecode.CodeAttribute; +import javassist.bytecode.ConstPool; +import javassist.bytecode.MethodInfo; public class TypedBlock extends BasicBlock { public int stackTop, numLocals; - public TypeData[] stackTypes, localsTypes; - - // set by a Liveness object. - // inputs[i] is true if the i-th variable is used within this block. - public boolean[] inputs; - - // working area for Liveness class. - public boolean updating; - public int status; - public byte[] localsUsage; + // localsTypes is set to non-null when this block is first visited by a MapMaker. + // see alreadySet(). + public TypeData[] localsTypes; + public TypeData[] stackTypes; /** * Divides the method body into basic blocks. * The type information of the first block is initialized. * - * @param optmize if it is true and the method does not include + * @param optimize if it is true and the method does not include * branches, this method returns null. */ public static TypedBlock[] makeBlocks(MethodInfo minfo, CodeAttribute ca, @@ -51,29 +50,21 @@ public class TypedBlock extends BasicBlock { blocks[0].initFirstBlock(ca.getMaxStack(), ca.getMaxLocals(), pool.getClassName(), minfo.getDescriptor(), isStatic, minfo.isConstructor()); - new Liveness().compute(ca.iterator(), blocks, ca.getMaxLocals(), - blocks[0].localsTypes); return blocks; } protected TypedBlock(int pos) { super(pos); localsTypes = null; - inputs = null; - updating = false; } + @Override protected void toString2(StringBuffer sbuf) { super.toString2(sbuf); sbuf.append(",\n stack={"); printTypes(sbuf, stackTop, stackTypes); sbuf.append("}, locals={"); printTypes(sbuf, numLocals, localsTypes); - sbuf.append("}, inputs={"); - if (inputs != null) - for (int i = 0; i < inputs.length; i++) - sbuf.append(inputs[i] ? "1, " : "0, "); - sbuf.append('}'); } @@ -110,10 +101,9 @@ public class TypedBlock extends BasicBlock { public void resetNumLocals() { if (localsTypes != null) { int nl = localsTypes.length; - while (nl > 0 && localsTypes[nl - 1] == TypeTag.TOP) { + while (nl > 0 && localsTypes[nl - 1].isBasicType() == TypeTag.TOP) { if (nl > 1) { - TypeData td = localsTypes[nl - 2]; - if (td == TypeTag.LONG || td == TypeTag.DOUBLE) + if (localsTypes[nl - 2].is2WordType()) break; } @@ -125,10 +115,12 @@ public class TypedBlock extends BasicBlock { } public static class Maker extends BasicBlock.Maker { + @Override protected BasicBlock makeBlock(int pos) { return new TypedBlock(pos); } + @Override protected BasicBlock[] makeArray(int size) { return new TypedBlock[size]; } @@ -152,8 +144,8 @@ public class TypedBlock extends BasicBlock { throw new BadBytecode("no method descriptor: " + methodDesc); stackTop = 0; - stackTypes = new TypeData[maxStack]; - TypeData[] locals = new TypeData[maxLocals]; + stackTypes = TypeData.make(maxStack); + TypeData[] locals = TypeData.make(maxLocals); if (isConstructor) locals[0] = new TypeData.UninitThis(className); else if (!isStatic) |