private void EmitDecimal() { var primitiveOperand = PrimitiveInstruction.Operand; var methodReference = primitiveOperand as MethodReference; var ctor = methodReference.GetActualMethod <ConstructorInfo>(); var types = ctor.GetParameters(); var instructions = InstructionsIndexer.GetPrevoiusRangeOfInstructions(PrimitiveInstruction, types.Length); instructions.ForEach((instruction, i) => { var mapped = OpCodesMapper.Map(instruction.OpCode); var operand = instruction.Operand; if (operand == null) { ILGenerator.Emit(mapped); } else { var typeCode = Type.GetTypeCode(operand.GetType()); ILGenerator.EmitPrimitiveByTypeCode(operand, typeCode); } }); ILGenerator.Emit(OpCodes.Newobj, ctor); }
private void EmitPrimitive(ILGenerator ILGenerator, Cil.Instruction instruction) { TypeCode typeCode; OpCode opCode = OpCodesMapper.Map(instruction.OpCode); if (instruction.Operand == null) { ILGenerator.Emit(opCode); return; } typeCode = opCode.OpCodeType == OpCodeType.Objmodel ? TypeCode.String : opCode.OpCodeType.GetTypeCode(); if (typeCode == TypeCode.Int32) { switch (opCode.StackBehaviourPush) { case StackBehaviour.Pushi8: typeCode = TypeCode.Int64; break; case StackBehaviour.Pushr4: typeCode = TypeCode.Single; break; case StackBehaviour.Pushr8: typeCode = TypeCode.Double; break; } } ILGenerator.EmitPrimitiveByTypeCode(instruction.Operand, typeCode); }