Package serp.bytecode
Class ClassConstantInstruction
- java.lang.Object
-
- serp.bytecode.ClassConstantInstruction
-
public class ClassConstantInstruction extends java.lang.Object
Pseudo-instruction used to placeClass
objects onto the stack. This logical instruction may actually involve a large chunk of code, and may even add static synthetic fields and methods to the owning class. Therefore, once the type of class being loaded is set, it cannot be changed. Also, this instruction is invalid as the target of any jump instruction or exception handler.
-
-
Constructor Summary
Constructors Constructor Description ClassConstantInstruction(BCClass bc, Code code, Instruction nop)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private BCField
addClassField(java.lang.String name)
Adds a static field to hold the loaded class constant.private BCMethod
addClassLoadMethod()
Adds the standardclass$
method used inernally by classes to load class constants for object types.
private static java.lang.Class
getWrapperClass(java.lang.String name)
Return the wrapper type for the given primitive class, or null if the given name is not a primitive type.Instruction
setClass(java.lang.Class type)
Set the type of class being loaded.Instruction
setClass(java.lang.String name)
Set the type of class being loaded.Instruction
setClass(BCClass type)
Set the type of class being loaded.private void
setClassName(java.lang.String name, java.lang.Class wrapper)
Set the name of the class to load.private void
setObject(java.lang.String name)
Adds fields and methods as necessary to load a class constant of an object type.
-
-
-
Field Detail
-
_params
private static final java.lang.Class[] _params
-
_wrappers
private static final java.util.Map _wrappers
-
_ins
private Instruction _ins
-
_code
private Code _code
-
_class
private BCClass _class
-
_invalid
private boolean _invalid
-
-
Constructor Detail
-
ClassConstantInstruction
ClassConstantInstruction(BCClass bc, Code code, Instruction nop)
-
-
Method Detail
-
setClass
public Instruction setClass(java.lang.String name)
Set the type of class being loaded.- Returns:
- the first Instruction of the block added by setting the type
- Throws:
java.lang.IllegalStateException
- if type has already been set
-
setClass
public Instruction setClass(java.lang.Class type)
Set the type of class being loaded.- Returns:
- the first Instruction of the block added by setting the type
- Throws:
java.lang.IllegalStateException
- if type has already been set
-
setClass
public Instruction setClass(BCClass type)
Set the type of class being loaded.- Returns:
- the first Instruction of the block added by setting the type
- Throws:
java.lang.IllegalStateException
- if type has already been set
-
setClassName
private void setClassName(java.lang.String name, java.lang.Class wrapper)
Set the name of the class to load.
-
setObject
private void setObject(java.lang.String name)
Adds fields and methods as necessary to load a class constant of an object type.
-
addClassField
private BCField addClassField(java.lang.String name)
Adds a static field to hold the loaded class constant.
-
addClassLoadMethod
private BCMethod addClassLoadMethod()
Adds the standardclass$
method used inernally by classes to load class constants for object types.
-
getWrapperClass
private static java.lang.Class getWrapperClass(java.lang.String name)
Return the wrapper type for the given primitive class, or null if the given name is not a primitive type. The given name should be in external form.
-
-