Package com.ibm.wala.shrikeCT
Class CodeWriter
- java.lang.Object
-
- com.ibm.wala.shrikeCT.ClassWriter.Element
-
- com.ibm.wala.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 int
copyInto(byte[] buf, int offset)
Copy the bytes into 'buf' at offset 'offset'.int
getCodeLength()
int
getSize()
void
setAttributes(ClassWriter.Element[] attributes)
Set the attributes of this Code.void
setCode(byte[] code)
Set the bytecodes for this Code attribute.void
setMaxLocals(int maxLocals)
Set the maximum number of local variable space used, in words, by this Code.void
setMaxStack(int maxStack)
Set the maximum stack size, in words, in this Code.void
setRawHandlers(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:
IllegalArgumentException
- if w is null
-
-
Method Detail
-
getCodeLength
public int getCodeLength() throws IllegalStateException
- Throws:
IllegalStateException
-
getSize
public int getSize() throws IllegalArgumentException
- Specified by:
getSize
in classClassWriter.Element
- Returns:
- the number of bytes that will be generated.
- Throws:
IllegalArgumentException
-
copyInto
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException
Description copied from class:ClassWriter.Element
Copy the bytes into 'buf' at offset 'offset'.- Specified by:
copyInto
in classClassWriter.Element
- Returns:
- the number of bytes copies, which must be equal to getSize()
- Throws:
IllegalArgumentException
-
setCode
public void setCode(byte[] code) throws IllegalArgumentException
Set the bytecodes for this Code attribute.- Throws:
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:
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.
-
-