Class CodeWriter
java.lang.Object
com.ibm.wala.shrike.shrikeCT.ClassWriter.Element
com.ibm.wala.shrike.shrikeCT.CodeWriter
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
-
Method Summary
Modifier and TypeMethodDescriptionint
copyInto
(byte[] buf, int offset) Copy the bytes into 'buf' at offset 'offset'.int
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 Details
-
CodeWriter
Build an empty serializable Code attribute.- Throws:
IllegalArgumentException
- if w is null
-
-
Method Details
-
getCodeLength
- Throws:
IllegalStateException
-
getSize
- Specified by:
getSize
in classClassWriter.Element
- Returns:
- the number of bytes that will be generated.
- Throws:
IllegalArgumentException
-
copyInto
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
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
Set the attributes of this Code.
-