Package com.strobel.reflection.emit
Class CodeGenerator
java.lang.Object
com.strobel.reflection.emit.CodeGenerator
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CodeStream
private __ExceptionInfo[]
private int
private int
private __ExceptionInfo[]
private int
private __FixupData[]
private int
private int[]
private int
private int
private int
private int
private 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 MethodBuilder
private static final int
private static final MethodInfo
private static final MethodInfo
(package private) ScopeTree
private static final MethodInfo
private static final MethodInfo
-
Constructor Summary
ConstructorsConstructorDescriptionCodeGenerator
(MethodBuilder methodBuilder) CodeGenerator
(MethodBuilder methodBuilder, int initialSize) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
(package private) final byte[]
void
beginCatchBlock
(Type<?> caughtType) void
void
call
(ConstructorInfo constructor) void
call
(OpCode opCode, MethodInfo method) void
call
(MethodInfo method) private static boolean
canEmitBytecodeConstant
(Type<?> type) static boolean
canEmitConstant
(Object value, Type<?> type) declareLocal
(Type<?> localType) declareLocal
(String name, Type<?> localType) void
dup()
void
void
dup2()
void
dup2x1()
void
dup2x2()
void
void
void
void
void
void
void
void
emit
(OpCode opCode, ConstructorInfo constructor) void
void
void
emit
(OpCode opCode, MethodInfo method) void
void
final void
emitArray
(Type<?> elementType, int count, CodeGenerator.EmitArrayElementCallback emit) void
emitBoolean
(boolean value) void
private void
emitBoxedToBoxedConversion
(Type<?> sourceType, Type<?> targetType) private void
emitBoxedToReferenceConversion
(Type<?> sourceType) private void
emitBoxedToUnboxedConversion
(Type<?> sourceType, Type<?> targetType) private void
emitBoxedToUnboxedNumericConversion
(Type<?> sourceType, Type<?> targetType) private void
emitBoxingConversion
(Type<?> sourceType, Type<?> targetType) void
emitByte
(byte value) (package private) final void
emitByteOperand
(int value) private void
emitCastToType
(Type<?> sourceType, Type<?> targetType) void
emitCharacter
(char value) (package private) final void
emitCharOperand
(char value) void
emitConstant
(Object value) void
emitConstant
(Object value, Type<?> type) void
emitConstantArray
(Object array) void
emitConversion
(Type<?> sourceType, Type<?> targetType) void
emitDefaultValue
(Type<?> type) void
emitDouble
(double value) (package private) final void
emitDoubleOperand
(double value) void
emitFloat
(float value) (package private) final void
emitFloatOperand
(float value) void
void
emitInteger
(int value) (package private) final void
emitIntOperand
(int value) void
emitLoad
(LocalBuilder local) protected void
void
emitLoadArgument
(int index) protected void
emitLoadConstant
(int token) void
emitLoadElement
(Type<?> elementType) protected void
emitLoadLongConstant
(int token) void
emitLong
(long value) (package private) final void
emitLongOperand
(long value) void
emitMethod
(MethodBase value) void
void
emitNewArray
(Type<?> arrayType) void
emitNewArray
(Type<?> arrayType, int dimensionsToInitialize) void
emitNull()
private void
emitNumericConversion
(Type<?> sourceType, Type<?> targetType) void
void
emitReturn
(Type<?> returnType) void
emitShort
(short value) (package private) final void
emitShortOperand
(int value) void
emitStore
(LocalBuilder local) protected void
void
emitStoreArgument
(int index) void
emitStoreElement
(Type<?> elementType) void
emitString
(String value) private void
emitStringHashSwitch
(String[] keys, StringSwitchCallback callback, SwitchOptions options) private void
emitStringTrieSwitch
(String[] keys, StringSwitchCallback callback) void
emitSwitch
(int[] keys, SwitchCallback callback) void
emitSwitch
(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) void
emitSwitch
(String[] keys, StringSwitchCallback callback) void
emitSwitch
(String[] keys, StringSwitchCallback callback, SwitchOptions options) void
emitThis()
void
void
private void
emitUnboxedToBoxedConversion
(Type<?> sourceType, Type<?> targetType) void
void
(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 void
ensureCapacity
(int size) (package private) static byte
getByteOperand
(byte[] codes, int index) (package private) static char
getCharOperand
(byte[] codes, int index) (package private) static double
getDoubleOperand
(byte[] codes, int index) (package private) final __ExceptionInfo[]
void
(package private) static float
getFloatOperand
(byte[] codes, int index) (package private) static int
getIntOperand
(byte[] codes, int index) private int
getLabelPosition
(Label label) private static OpCode
getLocalLoadOpCode
(Type<?> type, int localIndex) private static OpCode
getLocalStoreOpCode
(Type<?> type, int localIndex) (package private) static long
getLongOperand
(byte[] codes, int index) (package private) final int
(package private) static short
getShortOperand
(byte[] codes, int index) (package private) final Type<?>[]
void
increment
(LocalBuilder local, int delta) (package private) void
internalEmit
(OpCode opCode) void
int
offset()
void
pop()
void
void
pop2()
(package private) static void
putByteOperand
(byte[] codes, int index, byte value) (package private) static void
putCharOperand
(byte[] codes, int index, char value) (package private) static void
putDoubleOperand
(byte[] codes, int index, double value) void
(package private) static void
putFloatOperand
(byte[] codes, int index, float value) (package private) static void
putIntOperand
(byte[] codes, int index, int value) (package private) static void
putLongOperand
(byte[] codes, int index, long value) (package private) static void
putShortOperand
(byte[] codes, int index, short value) private void
registerCheckedExceptions
(MethodBase method) private static SwitchOptions
resolveSwitchOptions
(int[] keys, SwitchOptions options) private static void
sortExceptions
(__ExceptionInfo[] exceptions) private static int
private void
stringSwitchHelper
(List<String> bucket, StringSwitchCallback callback, Label defaultLabel, Label breakTarget, int index) (package private) final int
translateLocal
(int localIndex) (package private) final int
translateParameter
(int localIndex) private boolean
tryEmitConstant
(Object value, Type<?> type) (package private) final void
updateStackSize
(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
-