示例#1
0
        void ICilWriter.Emit(System.Reflection.Emit.OpCode opCode, byte operand)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            var code = CecilTranslator.Translate(opCode);

            switch (code.OperandType)
            {
            case OperandType.ShortInlineVar:
                Append(_body.CilWorker.Create(code, _body.Variables[operand]));
                break;

            case OperandType.ShortInlineParam:
                Append(_body.CilWorker.Create(code, GetParameter(operand)));
                break;

            default:
                // work-around: for some reason Cecil doesn't like this particular op-code
                // so we'll use an equivalent one instead
                if (code == OpCodes.Ldc_I4_S)
                {
                    Append(_body.CilWorker.Create(OpCodes.Ldc_I4, (int)operand));
                }
                else
                {
                    Append(_body.CilWorker.Create(code, operand));
                }
                break;
            }
        }
示例#2
0
        void ICilWriter.Emit(System.Reflection.Emit.OpCode opCode)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            Append(_body.CilWorker.Create(CecilTranslator.Translate(opCode)));
        }
示例#3
0
        void ICilWriter.Emit(System.Reflection.Emit.OpCode opCode, ILabel operand)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            var label = (Label)operand;

            var instruction = _body.CilWorker.Create(CecilTranslator.Translate(opCode), label.TargetInstruction);

            label.Referencers.Add(instruction);
            _body.CilWorker.Append(instruction);
        }
示例#4
0
        void ICilWriter.Emit(System.Reflection.Emit.OpCode opCode, long operand)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            var code = CecilTranslator.Translate(opCode);

            if (code.OperandType == OperandType.InlineVar || code.OperandType == OperandType.InlineParam)
            {
                ((ICilWriter)this).Emit(opCode, checked ((int)operand));
            }

            Append(_body.CilWorker.Create(code, operand));
        }
示例#5
0
        void ICilWriter.Emit(System.Reflection.Emit.OpCode opCode, int operand)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            var code = CecilTranslator.Translate(opCode);

            switch (code.OperandType)
            {
            case OperandType.InlineVar:
                Append(_body.CilWorker.Create(code, _body.Variables[operand]));
                break;

            case OperandType.InlineParam:
                Append(_body.CilWorker.Create(code, GetParameter(operand)));
                break;

            default:
                Append(_body.CilWorker.Create(code, operand));
                break;
            }
        }
示例#6
0
 void ICilWriter.Emit(System.Reflection.Emit.OpCode opCode, FieldInfo operand)
 {
     Append(_body.CilWorker.Create(
                CecilTranslator.Translate(opCode),
                _module.Import(operand)));
 }