Class CodeGenerator
java.lang.Object
com.strobel.reflection.emit.CodeGenerator
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CodeStreamprivate __ExceptionInfo[]private intprivate intprivate __ExceptionInfo[]private intprivate __FixupData[]private intprivate int[]private intprivate intprivate intprivate intprivate Type<?>[](package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) int(package private) LocalBuilder[]private static final int(package private) final MethodBuilderprivate static final intprivate static final MethodInfoprivate static final MethodInfo(package private) ScopeTreeprivate static final MethodInfoprivate static final MethodInfo -
Constructor Summary
ConstructorsConstructorDescriptionCodeGenerator(MethodBuilder methodBuilder) CodeGenerator(MethodBuilder methodBuilder, int initialSize) -
Method Summary
Modifier and TypeMethodDescriptionprivate void(package private) final byte[]voidbeginCatchBlock(Type<?> caughtType) voidvoidcall(ConstructorInfo constructor) voidcall(OpCode opCode, MethodInfo method) voidcall(MethodInfo method) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////private static booleancanEmitBytecodeConstant(Type<?> type) static booleancanEmitConstant(Object value, Type<?> type) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////declareLocal(Type<?> localType) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////declareLocal(String name, Type<?> localType) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voiddup()/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidvoiddup2()voiddup2x1()voiddup2x2()void/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidvoidvoidvoidvoidvoidvoidemit(OpCode opCode, ConstructorInfo constructor) voidvoidvoidemit(OpCode opCode, MethodInfo method) voidvoidfinal voidemitArray(Type<?> elementType, int count, CodeGenerator.EmitArrayElementCallback emit) voidemitBoolean(boolean value) void/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////private voidemitBoxedToBoxedConversion(Type<?> sourceType, Type<?> targetType) private voidemitBoxedToReferenceConversion(Type<?> sourceType) private voidemitBoxedToUnboxedConversion(Type<?> sourceType, Type<?> targetType) private voidemitBoxedToUnboxedNumericConversion(Type<?> sourceType, Type<?> targetType) private voidemitBoxingConversion(Type<?> sourceType, Type<?> targetType) voidemitByte(byte value) (package private) final voidemitByteOperand(int value) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////private voidemitCastToType(Type<?> sourceType, Type<?> targetType) voidemitCharacter(char value) (package private) final voidemitCharOperand(char value) voidemitConstant(Object value) voidemitConstant(Object value, Type<?> type) voidemitConstantArray(Object array) voidemitConversion(Type<?> sourceType, Type<?> targetType) voidemitDefaultValue(Type<?> type) voidemitDouble(double value) (package private) final voidemitDoubleOperand(double value) voidemitFloat(float value) (package private) final voidemitFloatOperand(float value) void/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidemitInteger(int value) (package private) final voidemitIntOperand(int value) voidemitLoad(LocalBuilder local) protected voidvoidemitLoadArgument(int index) protected voidemitLoadConstant(int token) voidemitLoadElement(Type<?> elementType) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////protected voidemitLoadLongConstant(int token) voidemitLong(long value) (package private) final voidemitLongOperand(long value) voidemitMethod(MethodBase value) void/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidemitNewArray(Type<?> arrayType) voidemitNewArray(Type<?> arrayType, int dimensionsToInitialize) voidemitNull()private voidemitNumericConversion(Type<?> sourceType, Type<?> targetType) voidvoidemitReturn(Type<?> returnType) voidemitShort(short value) (package private) final voidemitShortOperand(int value) voidemitStore(LocalBuilder local) protected voidvoidemitStoreArgument(int index) voidemitStoreElement(Type<?> elementType) voidemitString(String value) private voidemitStringHashSwitch(String[] keys, StringSwitchCallback callback, SwitchOptions options) private voidemitStringTrieSwitch(String[] keys, StringSwitchCallback callback) voidemitSwitch(int[] keys, SwitchCallback callback) voidemitSwitch(int[] keys, SwitchCallback callback, SwitchOptions options) <E extends Enum<E>>
voidemitSwitch(E[] keys, EnumSwitchCallback<E> callback) <E extends Enum<E>>
voidemitSwitch(E[] keys, EnumSwitchCallback<E> callback, SwitchOptions options) voidemitSwitch(String[] keys, StringSwitchCallback callback) voidemitSwitch(String[] keys, StringSwitchCallback callback, SwitchOptions options) voidemitThis()voidvoidprivate voidemitUnboxedToBoxedConversion(Type<?> sourceType, Type<?> targetType) voidvoid(package private) static byte[]enlargeArray(byte[] incoming) (package private) static byte[]enlargeArray(byte[] incoming, int requiredSize) (package private) static int[]enlargeArray(int[] incoming) (package private) static <T> T[]enlargeArray(T[] incoming) (package private) final voidensureCapacity(int size) (package private) static bytegetByteOperand(byte[] codes, int index) (package private) static chargetCharOperand(byte[] codes, int index) (package private) static doublegetDoubleOperand(byte[] codes, int index) (package private) final __ExceptionInfo[]void/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////(package private) static floatgetFloatOperand(byte[] codes, int index) (package private) static intgetIntOperand(byte[] codes, int index) private intgetLabelPosition(Label label) private static OpCodegetLocalLoadOpCode(Type<?> type, int localIndex) private static OpCodegetLocalStoreOpCode(Type<?> type, int localIndex) (package private) static longgetLongOperand(byte[] codes, int index) (package private) final int(package private) static shortgetShortOperand(byte[] codes, int index) (package private) final Type<?>[]voidincrement(LocalBuilder local, int delta) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////(package private) voidinternalEmit(OpCode opCode) voidintoffset()voidpop()voidvoidpop2()(package private) static voidputByteOperand(byte[] codes, int index, byte value) (package private) static voidputCharOperand(byte[] codes, int index, char value) (package private) static voidputDoubleOperand(byte[] codes, int index, double value) void(package private) static voidputFloatOperand(byte[] codes, int index, float value) (package private) static voidputIntOperand(byte[] codes, int index, int value) (package private) static voidputLongOperand(byte[] codes, int index, long value) (package private) static voidputShortOperand(byte[] codes, int index, short value) private voidregisterCheckedExceptions(MethodBase method) private static SwitchOptionsresolveSwitchOptions(int[] keys, SwitchOptions options) private static voidsortExceptions(__ExceptionInfo[] exceptions) private static intprivate voidstringSwitchHelper(List<String> bucket, StringSwitchCallback callback, Label defaultLabel, Label breakTarget, int index) (package private) final inttranslateLocal(int localIndex) (package private) final inttranslateParameter(int localIndex) private booleantryEmitConstant(Object value, Type<?> type) (package private) final voidupdateStackSize(OpCode opCode, int stackChange)
-
Field Details
-
DefaultSize
static final int DefaultSize- See Also:
-
DefaultFixupArraySize
static final int DefaultFixupArraySize- See Also:
-
DefaultLabelArraySize
static final int DefaultLabelArraySize- See Also:
-
DefaultExceptionArraySize
static final int DefaultExceptionArraySize- See Also:
-
MIN_BYTE
private static final int MIN_BYTE- See Also:
-
MAX_BYTE
private static final int MAX_BYTE- See Also:
-
_codeStream
-
_labelList
private int[] _labelList -
_labelCount
private int _labelCount -
_fixupData
-
_fixupCount
private int _fixupCount -
_exceptionCount
private int _exceptionCount -
_currentExceptionStackCount
private int _currentExceptionStackCount -
_unhandledExceptionCount
private int _unhandledExceptionCount -
_exceptions
-
_currentExceptionStack
-
_unhandledExceptions
-
scopeTree
ScopeTree scopeTree -
methodBuilder
-
localCount
int localCount -
locals
LocalBuilder[] locals -
_maxStackSize
private int _maxStackSize -
_maxMidStack
private int _maxMidStack -
_maxMidStackCur
private int _maxMidStackCur -
StringCharAtMethod
-
StringLengthMethod
-
ObjectEqualsMethod
-
ObjectHashCodeMethod
-
-
Constructor Details
-
CodeGenerator
-
CodeGenerator
-
-
Method Details
-
offset
public int offset() -
beginExceptionBlock
-
endExceptionBlock
public void endExceptionBlock() -
endTryBlock
public void endTryBlock() -
beginCatchBlock
-
beginFinallyBlock
public void beginFinallyBlock() -
defineLabel
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
markLabel
-
declareLocal
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
declareLocal
-
dup
public void dup()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
dup2
public void dup2() -
dup2x1
public void dup2x1() -
dup2x2
public void dup2x2() -
dup
-
pop
public void pop() -
pop2
public void pop2() -
pop
-
emit
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
emit
-
emit
-
emit
-
emit
-
emit
-
emit
-
emit
-
emit
-
emit
-
stackSize
-
emit
-
emit
-
emit
-
call
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
call
-
call
-
emitGoto
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
emitReturn
public void emitReturn() -
emitReturn
-
emitNew
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
emitNewArray
-
emitNewArray
-
emitArray
public final void emitArray(Type<?> elementType, int count, CodeGenerator.EmitArrayElementCallback emit) -
increment
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
emitLoad
-
emitStore
-
emitThis
public void emitThis() -
emitLoadArgument
public void emitLoadArgument(int index) -
emitLoad
-
emitStoreArgument
public void emitStoreArgument(int index) -
emitStore
-
getLocalLoadOpCode
-
getLocalStoreOpCode
-
translateParameter
final int translateParameter(int localIndex) -
translateLocal
final int translateLocal(int localIndex) -
emitLoadElement
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
emitStoreElement
-
getField
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
putField
-
canEmitConstant
-
emitConstant
-
emitConstantArray
-
emitConstant
-
emitType
-
emitMethod
-
tryEmitConstant
-
emitNull
public void emitNull() -
emitDefaultValue
-
emitBoolean
public void emitBoolean(boolean value) -
emitByte
public void emitByte(byte value) -
emitCharacter
public void emitCharacter(char value) -
emitShort
public void emitShort(short value) -
emitInteger
public void emitInteger(int value) -
emitLong
public void emitLong(long value) -
emitFloat
public void emitFloat(float value) -
emitDouble
public void emitDouble(double value) -
emitString
-
emitLoadConstant
protected void emitLoadConstant(int token) -
emitLoadLongConstant
protected void emitLoadLongConstant(int token) -
canEmitBytecodeConstant
-
emitBox
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
emitUnbox
-
emitConversion
-
emitBoxingConversion
-
emitUnboxedToBoxedConversion
-
emitBoxedToUnboxedConversion
-
emitBoxedToReferenceConversion
-
emitBoxedToUnboxedNumericConversion
-
emitBoxedToBoxedConversion
-
emitCastToType
-
emitNumericConversion
-
emitSwitch
-
emitSwitch
-
resolveSwitchOptions
-
emitSwitch
-
emitSwitch
public <E extends Enum<E>> void emitSwitch(E[] keys, EnumSwitchCallback<E> callback, SwitchOptions options) -
emitSwitch
-
emitSwitch
-
getStringSwitchBuckets
-
emitStringTrieSwitch
- Throws:
Exception
-
stringSwitchHelper
private void stringSwitchHelper(List<String> bucket, StringSwitchCallback callback, Label defaultLabel, Label breakTarget, int index) -
emitStringHashSwitch
private void emitStringHashSwitch(String[] keys, StringSwitchCallback callback, SwitchOptions options) throws Exception - Throws:
Exception
-
emitByteOperand
final void emitByteOperand(int value) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
emitCharOperand
final void emitCharOperand(char value) -
emitShortOperand
final void emitShortOperand(int value) -
emitIntOperand
final void emitIntOperand(int value) -
emitLongOperand
final void emitLongOperand(long value) -
emitFloatOperand
final void emitFloatOperand(float value) -
emitDoubleOperand
final void emitDoubleOperand(double value) -
internalEmit
-
getByteOperand
static byte getByteOperand(byte[] codes, int index) -
getCharOperand
static char getCharOperand(byte[] codes, int index) -
getShortOperand
static short getShortOperand(byte[] codes, int index) -
getIntOperand
static int getIntOperand(byte[] codes, int index) -
getLongOperand
static long getLongOperand(byte[] codes, int index) -
getFloatOperand
static float getFloatOperand(byte[] codes, int index) -
getDoubleOperand
static double getDoubleOperand(byte[] codes, int index) -
putByteOperand
static void putByteOperand(byte[] codes, int index, byte value) -
putCharOperand
static void putCharOperand(byte[] codes, int index, char value) -
putShortOperand
static void putShortOperand(byte[] codes, int index, short value) -
putIntOperand
static void putIntOperand(byte[] codes, int index, int value) -
putLongOperand
static void putLongOperand(byte[] codes, int index, long value) -
putFloatOperand
static void putFloatOperand(byte[] codes, int index, float value) -
putDoubleOperand
static void putDoubleOperand(byte[] codes, int index, double value) -
addFixup
-
ensureCapacity
final void ensureCapacity(int size) -
updateStackSize
-
getLabelPosition
-
bakeByteArray
final byte[] bakeByteArray() -
enlargeArray
static int[] enlargeArray(int[] incoming) -
enlargeArray
static <T> T[] enlargeArray(T[] incoming) -
enlargeArray
static byte[] enlargeArray(byte[] incoming) -
enlargeArray
static byte[] enlargeArray(byte[] incoming, int requiredSize) -
getExceptions
-
getUnhandledCheckedExceptions
-
getMaxStackSize
final int getMaxStackSize() -
sortExceptions
-
registerCheckedExceptions
-