Package com.ibm.wala.shrike.shrikeCT
Class CodeWriter
- java.lang.Object
-
- com.ibm.wala.shrike.shrikeCT.ClassWriter.Element
-
- com.ibm.wala.shrike.shrikeCT.CodeWriter
-
public final class CodeWriter extends ClassWriter.Element
This class helps emit Code elements.After constructing a CodeWriter, at least the max stack, max locals and bytecode bytes must be set before it can be used.
-
-
Constructor Summary
Constructors Constructor Description CodeWriter(ClassWriter w)Build an empty serializable Code attribute.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcopyInto(byte[] buf, int offset)Copy the bytes into 'buf' at offset 'offset'.intgetCodeLength()intgetSize()voidsetAttributes(ClassWriter.Element[] attributes)Set the attributes of this Code.voidsetCode(byte[] code)Set the bytecodes for this Code attribute.voidsetMaxLocals(int maxLocals)Set the maximum number of local variable space used, in words, by this Code.voidsetMaxStack(int maxStack)Set the maximum stack size, in words, in this Code.voidsetRawHandlers(int[] exnHandlers)Set the raw handler data for this Code attribute.
-
-
-
Constructor Detail
-
CodeWriter
public CodeWriter(ClassWriter w)
Build an empty serializable Code attribute.- Throws:
java.lang.IllegalArgumentException- if w is null
-
-
Method Detail
-
getCodeLength
public int getCodeLength() throws java.lang.IllegalStateException- Throws:
java.lang.IllegalStateException
-
getSize
public int getSize() throws java.lang.IllegalArgumentException- Specified by:
getSizein classClassWriter.Element- Returns:
- the number of bytes that will be generated.
- Throws:
java.lang.IllegalArgumentException
-
copyInto
public int copyInto(byte[] buf, int offset) throws java.lang.IllegalArgumentExceptionDescription copied from class:ClassWriter.ElementCopy the bytes into 'buf' at offset 'offset'.- Specified by:
copyIntoin classClassWriter.Element- Returns:
- the number of bytes copies, which must be equal to getSize()
- Throws:
java.lang.IllegalArgumentException
-
setCode
public void setCode(byte[] code) throws java.lang.IllegalArgumentExceptionSet the bytecodes for this Code attribute.- Throws:
java.lang.IllegalArgumentException- if code is null
-
setRawHandlers
public void setRawHandlers(int[] exnHandlers)
Set the raw handler data for this Code attribute.- Parameters:
exnHandlers- a flattened sequence of (startPC, endPC, catchClassIndex, catchPC) tuples- Throws:
java.lang.IllegalArgumentException- if exnHandlers is null
-
setMaxLocals
public void setMaxLocals(int maxLocals)
Set the maximum number of local variable space used, in words, by this Code.
-
setMaxStack
public void setMaxStack(int maxStack)
Set the maximum stack size, in words, in this Code.
-
setAttributes
public void setAttributes(ClassWriter.Element[] attributes)
Set the attributes of this Code.
-
-