Jurassic.Compiler.DynamicILGenerator.Switch C# (CSharp) 메소드

Switch() 공개 메소드

Creates a jump table. A value is popped from the stack - this value indicates the index of the label in the labels array to jump to.
public Switch ( ILLabel labels ) : void
labels ILLabel A array of labels.
리턴 void
        public override void Switch(ILLabel[] labels)
        {
            if (labels == null)
                throw new ArgumentNullException("labels");

            // Calculate the size of the instruction and the position of the start of the next instruction.
            int instructionSize = 1 + 4 + labels.Length * 4;
            int startOfNextInstruction = this.offset + instructionSize;

            // Enlarge the array if necessary.
            if (this.offset + instructionSize >= this.bytes.Length)
                EnlargeArray(instructionSize);

            // switch = 45
            Emit1ByteOpCode(0x45, 1, 0);

            // Emit the number of labels.
            EmitInt32(labels.Length);

            // Emit the labels.
            foreach (var label in labels)
                EmitLabel(label, startOfNextInstruction);
        }
DynamicILGenerator