public void EmitReturn(Type returnType) { if (returnType == typeof(void)) { for (int i = stackCount; i > 0; i--) { Emit(OpCodes.Pop); } ilSize += InstructionSize.Get(OpCodes.Ret); AdjustStack(OpCodes.Ret, 0); } else { for (int i = stackCount - 1; i > 0; i--) { Emit(OpCodes.Pop); } if (stackCount == 0) { Emit(OpCodes.Ldc_I4_0); } ilSize += InstructionSize.Get(OpCodes.Ret); AdjustStack(OpCodes.Ret, 1); } commands.Add(new ILCommand { opCode = OpCodes.Ret, args = $"<type>{returnType}" }); }
public void Emit(OpCode opCode, string arg) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode); commands.Add(new ILCommand { opCode = opCode, args = arg }); }
public void Emit(OpCode opCode, double arg) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode); commands.Add(new ILCommand { opCode = opCode, args = arg.ToString("E", CultureInfo.InvariantCulture) }); }
public void EmitCall(OpCode opCode, MethodInfo methodInfo, int argumentCount) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode, argumentCount, methodInfo.ReturnType != typeof(void) ? 1 : 0); commands.Add(new ILCommand { opCode = opCode, args = $"<method>{methodInfo.Name}" }); }
public void EmitPtr(OpCode opCode, MethodInfo methodInfo) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode); commands.Add(new ILCommand { opCode = opCode, args = $"<method>{methodInfo}" }); }
public void Emit(OpCode opCode, Type type, int?argumentCount = null, int?resultCount = null) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode, argumentCount, resultCount); commands.Add(new ILCommand { opCode = opCode, args = $"<type>{type}" }); }
public void Emit(OpCode opCode, FieldInfo field) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode); commands.Add(new ILCommand { opCode = opCode, args = $"<field>{field.Name}" }); }
public void Emit(OpCode opCode, LabelRef labelRef) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode); commands.Add(new ILCommand { opCode = opCode, args = $"<label>{labelRef.label.GetHashCode()}" }); }
public void Emit(OpCode opCode, ILocalRef localBuilder) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode); commands.Add(new ILCommand { opCode = opCode, args = $"<local>{localBuilder.LocalIndex}" }); }
public void Emit(OpCode opCode, IEnumerable <LabelRef> labels) { var labelRefs = labels.ToList(); ilSize += InstructionSize.Get(opCode, labelRefs.Count()); AdjustStack(opCode); commands.Add(new ILCommand { opCode = opCode, args = String.Join(", ", labelRefs.Select(label => $"<label>{label.label.GetHashCode()}")) }); }
public void EmitNew(OpCode opCode, ConstructorInfo constructor, int?argumentCount = null, int?resultCount = null) { ilSize += InstructionSize.Get(opCode); AdjustStack(opCode, argumentCount ?? constructor.GetParameters().Length, resultCount); }