public abstract class MethodBuilder extends BindingMethod
| Modifier and Type | Field and Description |
|---|---|
static String |
EXCEPTION_CONSTRUCTOR_SIGNATURE1 |
static String |
EXCEPTION_CONSTRUCTOR_SIGNATURE2 |
static String |
FRAMEWORK_EXCEPTION_CLASS |
protected ArrayList |
m_exceptions
Exceptions needing to be handled in method (lazy create,
null if not used). |
protected org.apache.bcel.generic.MethodGen |
m_generator
Generator for constructing method.
|
protected int |
m_hashCode
Accumulated hash code from adding instructions.
|
protected InstructionBuilder |
m_instructionBuilder
Builder for class instructions.
|
protected ClassItem |
m_item
Method class item information.
|
protected org.apache.bcel.classfile.Method |
m_method
Actual generated method information.
|
protected BranchWrapper[] |
m_targetBranches
Branch to be aimed at next appended instruction.
|
protected HashMap |
m_valueMap
Map for initialized properties (lazy create,
null if not
used). |
protected static ArrayList |
s_argNameLists
Table of argument name lists (generated as needed).
|
static int |
SYNTHETIC_ACCESS_FLAG |
| Modifier | Constructor and Description |
|---|---|
protected |
MethodBuilder(String name,
org.apache.bcel.generic.Type ret,
org.apache.bcel.generic.Type[] args,
ClassFile cf,
int access)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addException(String name)
Add exception to those needing handling.
|
int |
addLocal(String name,
org.apache.bcel.generic.Type type)
Add local variable to method.
|
ClassItem |
addMethod()
Add constructed method to class.
|
void |
addMethodExceptions(ClassItem method)
Add exceptions thrown by called method to those needing handling.
|
void |
appendAASTORE()
Append an AASTORE to the instruction list.
|
void |
appendACONST_NULL()
Append an ACONST_NULL to the instruction list.
|
void |
appendALOAD(String type)
Append appropriate array load to the instruction list.
|
void |
appendARRAYLENGTH()
Append an ARRAYLENGTH to the instruction list.
|
void |
appendASTORE(String type)
Append the appropriate array store to the instruction list.
|
void |
appendCall(ClassItem item)
Create invoke instruction for static, member, or interface method and
append to method.
|
void |
appendCallInit(String name,
String signature)
Create invoke initializer instruction from signature and append to
method.
|
void |
appendCallInterface(String method,
String signature)
Create invoke interface method instruction from signature and append to
method.
|
void |
appendCallStatic(String method,
String signature)
Create invoke static method instruction from signature and append to
method.
|
void |
appendCallVirtual(String method,
String signature)
Create invoke virtual method instruction from signature and append to
method.
|
void |
appendCreateArray(String type)
Append instruction to create instance of array.
|
void |
appendCreateCast(String to)
Append check cast instruction from object (if needed).
|
void |
appendCreateCast(String from,
String to)
Append check cast instruction (if needed).
|
void |
appendCreateNew(String name)
Append instruction to create instance of class.
|
void |
appendDCMPG()
Append an DCMPG to the instruction list.
|
void |
appendDUP_X1()
Append a DUP_X1 to the instruction list.
|
void |
appendDUP()
Append a DUP to the instruction list.
|
void |
appendDUP2()
Append a DUP2 to the instruction list.
|
void |
appendFCMPG()
Append an FCMPG to the instruction list.
|
void |
appendGet(ClassItem item)
Create get instruction and append to method.
|
void |
appendGetField(ClassItem item)
Create getfield instruction and append to method.
|
void |
appendGetStatic(ClassItem item)
Create getstatic instruction and append to method.
|
void |
appendIASTORE()
Append an IASTORE to the instruction list.
|
void |
appendICONST_0()
Append an ICONST_0 to the instruction list.
|
void |
appendICONST_1()
Append an ICONST_1 to the instruction list.
|
BranchWrapper |
appendIF_ICMPNE(Object src)
Append IF_ICMPNE branch instruction to method.
|
BranchWrapper |
appendIFEQ(Object src)
Append IFEQ branch instruction to method.
|
BranchWrapper |
appendIFGE(Object src)
Append IFGE branch instruction to method.
|
BranchWrapper |
appendIFLT(Object src)
Append IFLT branch instruction to method.
|
BranchWrapper |
appendIFNE(Object src)
Append IFNE branch instruction to method.
|
BranchWrapper |
appendIFNONNULL(Object src)
Append IFNONNULL branch instruction to method.
|
BranchWrapper |
appendIFNULL(Object src)
Append IFNULL branch instruction to method.
|
void |
appendIncrementLocal(int inc,
int slot)
Append instruction to increment local integer variable.
|
void |
appendInstanceOf(String to)
Append instanceof check instruction.
|
void |
appendISUB()
Append an ISUB to the instruction list.
|
void |
appendIXOR()
Append an IXOR to the instruction list.
|
void |
appendLCMP()
Append an LCMP to the instruction list.
|
void |
appendLoadConstant(int value)
Create load constant instruction and append to method.
|
void |
appendLoadConstant(Object value)
Create load constant instruction and append to method.
|
void |
appendLoadConstant(String value)
Create load constant instruction and append to method.
|
void |
appendLoadLocal(int slot)
Append instruction to load local variable.
|
void |
appendPOP()
Append a POP to the instruction list.
|
void |
appendPOP2()
Append a POP2 to the instruction list.
|
void |
appendPut(ClassItem item)
Create put instruction and append to method.
|
void |
appendPutField(ClassItem item)
Create putfield instruction and append to method.
|
void |
appendPutStatic(ClassItem item)
Create putstatic instruction and append to method.
|
void |
appendReturn()
Append simple return.
|
void |
appendReturn(String type)
Append typed return.
|
void |
appendReturn(org.apache.bcel.generic.Type type)
Append typed return.
|
void |
appendStoreLocal(int slot)
Append instruction to store local variable.
|
void |
appendSWAP()
Append a SWAP to the instruction list.
|
void |
appendSWAP1For2()
Append instructions to exchange a single-word value on the top of the
stack with the double-word value below it on the stack.
|
BranchTarget |
appendTargetACONST_NULL()
Append an ACONST_NULL to the instruction list as a branch target.
|
BranchTarget |
appendTargetCreateNew(String name)
Append instruction to create instance of class as a branch target.
|
BranchTarget |
appendTargetLoadConstant(int value)
Append a load constant instruction as a branch target.
|
BranchTarget |
appendTargetLoadConstant(String value)
Append a load constant instruction as a branch target.
|
BranchTarget |
appendTargetNOP()
Append a NOP to the instruction list as a branch target.
|
void |
appendThrow()
Append exception throw.
|
BranchWrapper |
appendUnconditionalBranch(Object src)
Append unconditional branch instruction to method.
|
void |
codeComplete(boolean suffix)
Complete method construction.
|
protected org.apache.bcel.generic.LocalVariableGen |
createLocal(String name,
org.apache.bcel.generic.Type type)
Add local variable to method.
|
int |
getAccessFlags()
Get access flags.
|
protected org.apache.bcel.generic.InstructionHandle |
getFirstInstruction()
Get first instruction in method.
|
ClassItem |
getItem()
Get the method item.
|
Object |
getKeyValue(Object key)
Get local variable for object.
|
protected org.apache.bcel.generic.InstructionHandle |
getLastInstruction()
Get last instruction in method.
|
org.apache.bcel.classfile.Method |
getMethod()
Get the actual method.
|
String |
getName()
Get name of method being constructed.
|
String |
getSignature()
Get signature.
|
protected abstract void |
handleExceptions()
Process accumulated exceptions.
|
int |
hashCode()
Get hash code.
|
void |
initStackState(BranchWrapper branch)
Initialize stack state to match branch source.
|
void |
initStackState(BranchWrapper branch,
int pop)
Initialize stack state to partially match branch source.
|
protected void |
initStackState(String[] types)
Initialize stack state to array of value types.
|
protected org.apache.bcel.generic.InstructionHandle |
internalAppendCreateNew(String name)
Internal append instruction to create instance of class.
|
boolean |
isStackTopLong()
Check if top item on stack is a long value.
|
void |
setAccessFlags(int flags)
Set access flags.
|
Object |
setKeyValue(Object key,
Object value)
Add keyed value to method definition.
|
protected void |
setTarget(org.apache.bcel.generic.InstructionHandle inst)
Target branches if pending.
|
void |
targetNext(BranchWrapper branch)
Set branch target as next instruction added to method.
|
void |
targetNext(BranchWrapper[] branches)
Set branch targets as next instruction added to method.
|
computeMethodHash, equals, getClassFile, makeAccessiblepublic static final String FRAMEWORK_EXCEPTION_CLASS
public static final String EXCEPTION_CONSTRUCTOR_SIGNATURE1
public static final String EXCEPTION_CONSTRUCTOR_SIGNATURE2
public static final int SYNTHETIC_ACCESS_FLAG
protected static ArrayList s_argNameLists
protected InstructionBuilder m_instructionBuilder
protected org.apache.bcel.generic.MethodGen m_generator
protected org.apache.bcel.classfile.Method m_method
protected ClassItem m_item
protected ArrayList m_exceptions
null if not used).protected int m_hashCode
protected BranchWrapper[] m_targetBranches
protected HashMap m_valueMap
null if not
used).protected MethodBuilder(String name, org.apache.bcel.generic.Type ret, org.apache.bcel.generic.Type[] args, ClassFile cf, int access)
name - method name to be builtret - method return typeargs - types of argumentscf - owning class file informationaccess - flags for method accesspublic String getName()
getName in class BindingMethodpublic String getSignature()
getSignature in class BindingMethodpublic int getAccessFlags()
getAccessFlags in class BindingMethodpublic void setAccessFlags(int flags)
setAccessFlags in class BindingMethodflags - access type to be setpublic org.apache.bcel.classfile.Method getMethod()
codeComplete(boolean) method is called).getMethod in class BindingMethodpublic Object setKeyValue(Object key, Object value)
key - retrieval keyvalue - keyed valuepublic Object getKeyValue(Object key)
key - object key for local variablepublic void addException(String name)
name - fully qualified name of exception classpublic void addMethodExceptions(ClassItem method)
method - information for method to be handledprotected org.apache.bcel.generic.InstructionHandle getFirstInstruction()
protected org.apache.bcel.generic.InstructionHandle getLastInstruction()
protected final void setTarget(org.apache.bcel.generic.InstructionHandle inst)
targetNext(org.jibx.binding.classes.BranchWrapper) method.inst - handle for appended instructionpublic BranchWrapper appendIFEQ(Object src)
src - object responsible for generating branchpublic BranchWrapper appendIFGE(Object src)
src - object responsible for generating branchpublic BranchWrapper appendIFLT(Object src)
src - object responsible for generating branchpublic BranchWrapper appendIFNE(Object src)
src - object responsible for generating branchpublic BranchWrapper appendIFNONNULL(Object src)
src - object responsible for generating branchpublic BranchWrapper appendIFNULL(Object src)
src - object responsible for generating branchpublic BranchWrapper appendIF_ICMPNE(Object src)
src - object responsible for generating branchpublic BranchWrapper appendUnconditionalBranch(Object src)
src - object responsible for generating branchpublic void appendLoadConstant(int value)
value - constant value to be loadedpublic void appendLoadConstant(String value)
String reference from the constant pool.value - constant value to be loadedpublic void appendLoadConstant(Object value)
value - constant value to be loadedpublic void appendGetField(ClassItem item)
item - information for field to be gottonpublic void appendGetStatic(ClassItem item)
item - information for field to be setpublic void appendGet(ClassItem item)
item - information for field to be gottenpublic void appendPutField(ClassItem item)
item - information for field to be setpublic void appendPutStatic(ClassItem item)
item - information for field to be setpublic void appendPut(ClassItem item)
item - information for field to be gottenpublic void appendCall(ClassItem item)
item - information for method to be calledpublic void appendCallStatic(String method, String signature)
method - fully qualified class and method namesignature - method signature in standard formpublic void appendCallVirtual(String method, String signature)
method - fully qualified class and method namesignature - method signature in standard formpublic void appendCallInterface(String method, String signature)
method - fully qualified interface and method namesignature - method signature in standard formpublic void appendCreateNew(String name)
name - fully qualified class namepublic void appendCallInit(String name, String signature)
name - fully qualified class namesignature - method signature in standard formpublic void appendCreateArray(String type)
type - fully qualified type name of array elementspublic void appendCreateCast(String from, String to)
from - fully qualified name of current typeto - fully qualified name of desired typepublic void appendCreateCast(String to)
to - fully qualified name of desired typepublic void appendInstanceOf(String to)
to - fully qualified name of type to checkprotected org.apache.bcel.generic.LocalVariableGen createLocal(String name, org.apache.bcel.generic.Type type)
name - local variable name (may be null to use default)type - variable typepublic int addLocal(String name, org.apache.bcel.generic.Type type)
name - local variable nametype - variable typepublic void appendLoadLocal(int slot)
slot - local variable slot to loadpublic void appendStoreLocal(int slot)
slot - local variable slot to storepublic void appendIncrementLocal(int inc,
int slot)
inc - amount of incrmentslot - local variable slot to loadpublic void appendReturn()
public void appendReturn(org.apache.bcel.generic.Type type)
type - returned type (may be Type.VOID)public void appendReturn(String type)
type - returned type (may be void)public void appendThrow()
public void appendALOAD(String type)
type - array item type expectedpublic void appendAASTORE()
public void appendASTORE(String type)
type - array item type expectedpublic void appendACONST_NULL()
public void appendARRAYLENGTH()
public void appendDCMPG()
public void appendDUP()
public void appendDUP2()
public void appendDUP_X1()
public void appendFCMPG()
public void appendIASTORE()
public void appendICONST_0()
public void appendICONST_1()
public void appendISUB()
public void appendIXOR()
public void appendLCMP()
public void appendPOP()
public void appendPOP2()
public void appendSWAP()
public void appendSWAP1For2()
public BranchTarget appendTargetNOP()
public BranchTarget appendTargetACONST_NULL()
public BranchTarget appendTargetLoadConstant(int value)
value - constant value to be loadedpublic BranchTarget appendTargetLoadConstant(String value)
String reference from the constant pool.value - constant value to be loadedpublic BranchTarget appendTargetCreateNew(String name)
name - fully qualified class nameprotected org.apache.bcel.generic.InstructionHandle internalAppendCreateNew(String name)
name - fully qualified class namepublic boolean isStackTopLong()
true if long value, false if notpublic void initStackState(BranchWrapper branch)
branch - wrapper for branch to be for stack initializationpublic void initStackState(BranchWrapper branch, int pop)
branch - wrapper for branch to be for stack initializationpop - number of items to be removed from branch source stack stateprotected void initStackState(String[] types)
types - array of type names on stackpublic void targetNext(BranchWrapper branch)
branch - wrapper for branch to be aimed at next instruction (may be
null, in which case nothing is done)public void targetNext(BranchWrapper[] branches)
branches - wrappers for branches to be aimed at next instruction
(may be null, in which case nothing is done)protected abstract void handleExceptions()
public void codeComplete(boolean suffix)
suffix - add suffix to make method name uniquepublic ClassItem getItem()
getItem in class BindingMethodpublic int hashCode()
codeComplete(boolean) method is called.hashCode in class BindingMethodpublic ClassItem addMethod()
Copyright © 2005–2016 jibx.org. All rights reserved.