Antlr4.StringTemplate.Compiler.BytecodeDisassembler.GetShort C# (CSharp) Метод

GetShort() статический приватный Метод

static private GetShort ( byte memory, int index ) : int
memory byte
index int
Результат int
        internal static int GetShort(byte[] memory, int index)
        {
            return BitConverter.ToInt16(memory, index);
        }

Usage Example

Пример #1
0
        public virtual void Insert(int addr, Bytecode opcode, string s)
        {
            //System.out.println("before insert of "+opcode+"("+s+"):"+ Arrays.toString(impl.instrs));
            EnsureCapacity(1 + Instruction.OperandSizeInBytes);
            int instrSize = 1 + Instruction.OperandSizeInBytes;

            // make room for opcode, opnd
            Array.Copy(impl.instrs, addr, impl.instrs, addr + instrSize, ip - addr);
            int save = ip;

            ip = addr;
            Emit1(null, opcode, s);
            ip = save + instrSize;
            //System.out.println("after  insert of "+opcode+"("+s+"):"+ Arrays.toString(impl.instrs));
            // adjust addresses for BR and BRF
            int a = addr + instrSize;

            while (a < ip)
            {
                Bytecode    op = (Bytecode)impl.instrs[a];
                Instruction I  = Instruction.instructions[(int)op];
                if (op == Bytecode.INSTR_BR || op == Bytecode.INSTR_BRF)
                {
                    int opnd = BytecodeDisassembler.GetShort(impl.instrs, a + 1);
                    WriteShort(impl.instrs, a + 1, (short)(opnd + instrSize));
                }
                a += I.nopnds * Instruction.OperandSizeInBytes + 1;
            }
            //System.out.println("after  insert of "+opcode+"("+s+"):"+ Arrays.toString(impl.instrs));
        }