Class CodeGenerator


  • public class CodeGenerator
    extends java.lang.Object
    • Field Detail

      • _codeStream

        private final CodeStream _codeStream
      • _labelList

        private int[] _labelList
      • _labelCount

        private int _labelCount
      • _fixupCount

        private int _fixupCount
      • _exceptionCount

        private int _exceptionCount
      • _currentExceptionStackCount

        private int _currentExceptionStackCount
      • _unhandledExceptionCount

        private int _unhandledExceptionCount
      • _unhandledExceptions

        private Type<?>[] _unhandledExceptions
      • localCount

        int localCount
      • _maxStackSize

        private int _maxStackSize
      • _maxMidStack

        private int _maxMidStack
      • _maxMidStackCur

        private int _maxMidStackCur
      • StringCharAtMethod

        private static final MethodInfo StringCharAtMethod
      • StringLengthMethod

        private static final MethodInfo StringLengthMethod
      • ObjectEqualsMethod

        private static final MethodInfo ObjectEqualsMethod
      • ObjectHashCodeMethod

        private static final MethodInfo ObjectHashCodeMethod
    • Constructor Detail

      • CodeGenerator

        public CodeGenerator​(MethodBuilder methodBuilder)
      • CodeGenerator

        public CodeGenerator​(MethodBuilder methodBuilder,
                             int initialSize)
    • Method Detail

      • offset

        public int offset()
      • beginExceptionBlock

        public Label beginExceptionBlock()
      • endExceptionBlock

        public void endExceptionBlock()
      • endTryBlock

        public void endTryBlock()
      • beginCatchBlock

        public void beginCatchBlock​(Type<?> caughtType)
      • beginFinallyBlock

        public void beginFinallyBlock()
      • defineLabel

        public Label defineLabel()
      • markLabel

        public void markLabel​(Label label)
      • declareLocal

        public LocalBuilder declareLocal​(java.lang.String name,
                                         Type<?> localType)
      • dup

        public void dup()
      • dup2

        public void dup2()
      • dup2x1

        public void dup2x1()
      • dup2x2

        public void dup2x2()
      • dup

        public void dup​(Type<?> type)
      • pop

        public void pop()
      • pop2

        public void pop2()
      • pop

        public void pop​(Type<?> type)
      • emit

        public void emit​(OpCode opCode)
      • emit

        public void emit​(OpCode opCode,
                         byte arg)
      • emit

        public void emit​(OpCode opCode,
                         short arg)
      • emit

        public void emit​(OpCode opCode,
                         int arg)
      • emit

        public void emit​(OpCode opCode,
                         long arg)
      • emit

        public void emit​(OpCode opCode,
                         float arg)
      • emit

        public void emit​(OpCode opCode,
                         double arg)
      • emit

        public void emit​(OpCode opCode,
                         java.lang.String arg)
      • emit

        public void emit​(OpCode opCode,
                         Type<?> type)
      • stackSize

        private static int stackSize​(Type<?> type)
      • emit

        public void emit​(OpCode opCode,
                         Label label)
      • emitGoto

        public void emitGoto​(Label label)
      • emitReturn

        public void emitReturn()
      • emitReturn

        public void emitReturn​(Type<?> returnType)
      • emitNew

        public void emitNew​(Type<?> type)
      • emitNewArray

        public void emitNewArray​(Type<?> arrayType)
      • emitNewArray

        public void emitNewArray​(Type<?> arrayType,
                                 int dimensionsToInitialize)
      • increment

        public void increment​(LocalBuilder local,
                              int delta)
      • emitThis

        public void emitThis()
      • emitLoadArgument

        public void emitLoadArgument​(int index)
      • emitLoad

        protected void emitLoad​(Type<?> type,
                                int absoluteIndex)
      • emitStoreArgument

        public void emitStoreArgument​(int index)
      • emitStore

        protected void emitStore​(Type<?> type,
                                 int absoluteIndex)
      • getLocalLoadOpCode

        private static OpCode getLocalLoadOpCode​(Type<?> type,
                                                 int localIndex)
      • getLocalStoreOpCode

        private static OpCode getLocalStoreOpCode​(Type<?> type,
                                                  int localIndex)
      • translateParameter

        final int translateParameter​(int localIndex)
      • translateLocal

        final int translateLocal​(int localIndex)
      • emitLoadElement

        public void emitLoadElement​(Type<?> elementType)
      • emitStoreElement

        public void emitStoreElement​(Type<?> elementType)
      • getField

        public void getField​(FieldInfo field)
      • putField

        public void putField​(FieldInfo field)
      • canEmitConstant

        public static boolean canEmitConstant​(java.lang.Object value,
                                              Type<?> type)
      • emitConstant

        public void emitConstant​(java.lang.Object value)
      • emitConstantArray

        public void emitConstantArray​(java.lang.Object array)
      • emitConstant

        public void emitConstant​(java.lang.Object value,
                                 Type<?> type)
      • emitType

        public void emitType​(Type<?> value)
      • emitMethod

        public void emitMethod​(MethodBase value)
      • tryEmitConstant

        private boolean tryEmitConstant​(java.lang.Object value,
                                        Type<?> type)
      • emitNull

        public void emitNull()
      • emitDefaultValue

        public void emitDefaultValue​(Type<?> type)
      • 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

        public void emitString​(java.lang.String value)
      • emitLoadConstant

        protected void emitLoadConstant​(int token)
      • emitLoadLongConstant

        protected void emitLoadLongConstant​(int token)
      • canEmitBytecodeConstant

        private static boolean canEmitBytecodeConstant​(Type<?> type)
      • emitBox

        public void emitBox​(Type<?> type)
      • emitUnbox

        public void emitUnbox​(Type<?> type)
      • emitConversion

        public void emitConversion​(Type<?> sourceType,
                                   Type<?> targetType)
      • emitBoxingConversion

        private void emitBoxingConversion​(Type<?> sourceType,
                                          Type<?> targetType)
      • emitUnboxedToBoxedConversion

        private void emitUnboxedToBoxedConversion​(Type<?> sourceType,
                                                  Type<?> targetType)
      • emitBoxedToUnboxedConversion

        private void emitBoxedToUnboxedConversion​(Type<?> sourceType,
                                                  Type<?> targetType)
      • emitBoxedToReferenceConversion

        private void emitBoxedToReferenceConversion​(Type<?> sourceType)
      • emitBoxedToUnboxedNumericConversion

        private void emitBoxedToUnboxedNumericConversion​(Type<?> sourceType,
                                                         Type<?> targetType)
      • emitBoxedToBoxedConversion

        private void emitBoxedToBoxedConversion​(Type<?> sourceType,
                                                Type<?> targetType)
      • emitCastToType

        private void emitCastToType​(Type<?> sourceType,
                                    Type<?> targetType)
      • emitNumericConversion

        private void emitNumericConversion​(Type<?> sourceType,
                                           Type<?> targetType)
      • emitSwitch

        public void emitSwitch​(int[] keys,
                               SwitchCallback callback)
      • emitSwitch

        public <E extends java.lang.Enum<E>> void emitSwitch​(E[] keys,
                                                             EnumSwitchCallback<E> callback)
      • getStringSwitchBuckets

        private static java.util.Map<java.lang.Integer,​java.util.List<java.lang.String>> getStringSwitchBuckets​(java.util.List<java.lang.String> strings,
                                                                                                                      Func1<java.lang.String,​java.lang.Integer> keyCallback)
      • emitStringTrieSwitch

        private void emitStringTrieSwitch​(java.lang.String[] keys,
                                          StringSwitchCallback callback)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • stringSwitchHelper

        private void stringSwitchHelper​(java.util.List<java.lang.String> bucket,
                                        StringSwitchCallback callback,
                                        Label defaultLabel,
                                        Label breakTarget,
                                        int index)
      • emitStringHashSwitch

        private void emitStringHashSwitch​(java.lang.String[] keys,
                                          StringSwitchCallback callback,
                                          SwitchOptions options)
                                   throws java.lang.Exception
        Throws:
        java.lang.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

        void internalEmit​(OpCode opCode)
      • 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

        private void addFixup​(Label label,
                              int offsetOrigin,
                              int fixupPosition,
                              int operandSize)
      • ensureCapacity

        final void ensureCapacity​(int size)
      • updateStackSize

        final void updateStackSize​(OpCode opCode,
                                   int stackChange)
      • getLabelPosition

        private int getLabelPosition​(Label label)
      • 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)
      • getUnhandledCheckedExceptions

        final Type<?>[] getUnhandledCheckedExceptions()
      • getMaxStackSize

        final int getMaxStackSize()
      • sortExceptions

        private static void sortExceptions​(__ExceptionInfo[] exceptions)
      • registerCheckedExceptions

        private void registerCheckedExceptions​(MethodBase method)