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

FixLabels() private method

Patch any undefined labels.
private FixLabels ( ) : void
return void
        private void FixLabels()
        {
            foreach (var fix in this.fixups)
            {
                // Get the IL offset of the label.
                int jumpOffset = fix.Label.ILOffset;
                if (jumpOffset < 0)
                    throw new InvalidOperationException("Undefined label.");

                // Jump offsets are relative to the next instruction.
                jumpOffset -= fix.StartOfNextInstruction;

                // Patch the jump offset;
                var position = fix.Position;
                if (fix.Length != 4)
                    throw new NotImplementedException("Short jumps are not supported.");
                this.bytes[position++] = (byte)jumpOffset;
                this.bytes[position++] = (byte)(jumpOffset >> 8);
                this.bytes[position++] = (byte)(jumpOffset >> 16);
                this.bytes[position++] = (byte)(jumpOffset >> 24);
            }
            this.fixups.Clear();
        }
DynamicILGenerator