Jurassic.Compiler.DynamicILGenerator.Emit2ByteOpCode C# (CSharp) Method

Emit2ByteOpCode() private method

Emits a two byte opcode.
private Emit2ByteOpCode ( byte opCode1, byte opCode2, int popCount, int pushCount ) : void
opCode1 byte The first byte of the opcode to emit.
opCode2 byte The second byte of the opcode to emit.
popCount int The number of items to pop from the stack.
pushCount int The number of items to push onto the stack.
return void
        private void Emit2ByteOpCode(byte opCode1, byte opCode2, int popCount, int pushCount)
        {
            // Enlarge the array if necessary.
            const int instructionSize = 2;
            if (this.offset + instructionSize >= this.bytes.Length)
                EnlargeArray(instructionSize);

            // Emit the instruction bytes.
            this.bytes[this.offset++] = opCode1;
            this.bytes[this.offset++] = opCode2;

            // The instruction pops two values and pushes a value to the stack.
            if (this.stackSize < popCount)
                throw new InvalidOperationException("Stack underflow");
            this.stackSize += pushCount - popCount;
            this.maxStackSize = Math.Max(this.stackSize, this.maxStackSize);
        }
DynamicILGenerator