Exemplo n.º 1
0
        /// <summary>
        /// Writes an <see cref="OperandType.InlineSwitch"/> operand
        /// </summary>
        /// <param name="writer">Instruction writer</param>
        /// <param name="instr">Instruction</param>
        protected virtual void WriteInlineSwitch(ref ArrayWriter writer, Instruction instr)
        {
            var targets = instr.Operand as IList <Instruction>;

            if (targets is null)
            {
                Error("switch operand is not a list of instructions");
                writer.WriteInt32(0);
            }
            else
            {
                uint offsetAfter = (uint)(ToInstructionOffset(ref writer) + 4 + targets.Count * 4);
                writer.WriteInt32(targets.Count);
                for (int i = 0; i < targets.Count; i++)
                {
                    var target = targets[i];
                    writer.WriteUInt32(GetOffset(target) - offsetAfter);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes an <see cref="OperandType.InlineBrTarget"/> operand
        /// </summary>
        /// <param name="writer">Instruction writer</param>
        /// <param name="instr">Instruction</param>
        protected virtual void WriteInlineBrTarget(ref ArrayWriter writer, Instruction instr)
        {
            uint displ = GetOffset(instr.Operand as Instruction) - (ToInstructionOffset(ref writer) + 4);

            writer.WriteUInt32(displ);
        }