public static object ToObject(StackObject *esp, ILEnvironment env, FastList <object> mObjects) { switch (esp->ObjectType) { case StackObjectType.Object: return(mObjects[esp->Int32]); } throw new NotSupportedException(); }
private static void Test() { var env = new ILEnvironment(); env.LoadAssemblyFromFile(Constant.TestCaseDll); var type = env.GetType("TestCase.Test01"); var method = type.GetDeclaredMethod("Run3", null, new ILType[] { env.Int }, env.Int); Console.WriteLine(method.Invoke(null, 10)); //Console.WriteLine(typeof(object).GetConstructors()[0].Invoke(null)); }
public RuntimeArrayType(ILType elementType, ArrayType reference, ILEnvironment env) : base(elementType, reference, env) { rank = reference.Rank; if (rank == 1) { typeForCLR = elementType.TypeForCLR.MakeArrayType(); } else { typeForCLR = elementType.TypeForCLR.MakeArrayType(rank); } }
internal static RuntimeType Create(TypeDefinition definition, ILEnvironment env) { if (definition.IsGenericParameter) { return(new RuntimeGenericParameterType(definition, env)); } if (definition.HasGenericParameters) { return(new RuntimeGenericDefinitionType(definition, env)); } return(new RuntimeDirectType(definition, env)); }
internal static CLRType Create(Type type, ILEnvironment env) { if (type.IsPointer) { var elementType = env.GetType(type.GetElementType()); return(new CLRPointerType(elementType, type, env)); } if (type.IsByRef) { var elementType = env.GetType(type.GetElementType()); return(new CLRByRefType(elementType, type, env)); } if (type.IsArray) { var elementType = env.GetType(type.GetElementType()); return(new CLRArrayType(elementType, type, env)); } if (type.IsGenericParameter) { if (type.DeclaringType != null) { return(new CLRTypeGenericParameterType(type, env)); } } if (type.IsGenericType) { if (type.IsGenericTypeDefinition) { return(new CLRGenericDefinitionType(type, env)); } var clrGenericArguments = type.GetGenericArguments(); var genericArguments = new FastList <ILType>(clrGenericArguments.Length); foreach (var generic in clrGenericArguments) { genericArguments.Add(env.GetType(generic)); } var genericTypeDefinition = env.GetType(type.GetGenericTypeDefinition()); return(new CLRGenericSpecificationType(genericTypeDefinition, genericArguments, type, env)); } return(new CLRDirectType(type, env)); }
public CLRGenericDefinitionType(Type type, ILEnvironment env) : base(type, env) { }
public static void Before() { env = new ILEnvironment(); }
public static void After() { env = null; }
public CLRDirectType(Type type, ILEnvironment env) : base(type, env) { }
public CLRGenericSpecificationType(ILType genericTypeDefinition, FastList <ILType> genericArguments, Type type, ILEnvironment env) : base(type, env) { this.genericTypeDefinition = genericTypeDefinition; this.genericArguments = genericArguments; }
public CLRPointerType(ILType elementType, Type type, ILEnvironment env) : base(type, env) { this.elementType = elementType; }
public RuntimeByRefType(ILType elementType, ByReferenceType reference, ILEnvironment env) : base(elementType, reference, env) { typeForCLR = elementType.TypeForCLR.MakeByRefType(); }
public RuntimeInterpreter(ILEnvironment environment) { this.environment = environment; stack = new RuntimeStack(); clrArguments.Add(0, null); }
public RuntimeGenericDefinitionType(TypeDefinition definition, ILEnvironment env) : base(definition, env) { }
public static void Before() { env = new ILEnvironment(); env.LoadAssembly(new MemoryStream(bs)); }
internal CLRType(Type type, ILEnvironment env) : base(env) { typeForCLR = type; assemblyName = new AssemblyName(type.Assembly.GetName()); }
internal ILType(ILEnvironment env) { Id = IdConstant.NextTypeId(); Environment = env; }
public static Instruction Create(Code code, object operand, ILEnvironment env, Dictionary <Mono.Cecil.Cil.Instruction, int> address) { var instruction = new Instruction { Code = code, }; switch (code) { #region jump case Code.Leave: case Code.Leave_S: case Code.Br: case Code.Br_S: case Code.Brtrue: case Code.Brtrue_S: case Code.Brfalse: case Code.Brfalse_S: case Code.Beq: case Code.Beq_S: case Code.Bne_Un: case Code.Bne_Un_S: case Code.Bge: case Code.Bge_S: case Code.Bge_Un: case Code.Bge_Un_S: case Code.Bgt: case Code.Bgt_S: case Code.Bgt_Un: case Code.Bgt_Un_S: case Code.Ble: case Code.Ble_S: case Code.Ble_Un: case Code.Ble_Un_S: case Code.Blt: case Code.Blt_S: case Code.Blt_Un: case Code.Blt_Un_S: instruction.Int32 = address[(Mono.Cecil.Cil.Instruction)operand]; break; #endregion #region ldc case Code.Ldc_I4: instruction.Int32 = (int)operand; break; case Code.Ldc_I4_S: instruction.Int32 = (sbyte)operand; break; case Code.Ldc_I8: instruction.Int64 = (long)operand; break; case Code.Ldstr: StringPool.Put((string)operand, out instruction.High32, out instruction.Low32); break; #endregion #region call case Code.Newobj: case Code.Call: var methodReference = (MethodReference)operand; var type = env.GetType(methodReference.DeclaringType); var method = type.GetDeclaredMethod(methodReference); instruction.High32 = type.GetHashCode(); instruction.Low32 = method.GetHashCode(); break; #endregion } return(instruction); }
protected RuntimeDefinitonType(TypeDefinition definition, ILEnvironment env) : base(definition, env) { this.definition = definition; }
internal RuntimeType(TypeReference reference, ILEnvironment env) : base(env) { this.reference = reference; assemblyName = new AssemblyName(reference.Module.Assembly.FullName); }
public CLRArrayType(ILType elementType, Type type, ILEnvironment env) : base(type, env) { this.elementType = elementType; rank = type.GetArrayRank(); }
public CLRTypeGenericParameterType(Type type, ILEnvironment env) : base(type, env) { }
public RuntimePointerType(ILType elementType, PointerType reference, ILEnvironment env) : base(elementType, reference, env) { typeForCLR = elementType.TypeForCLR.MakePointerType(); }
protected RuntimeSpecificationType(ILType elementType, TypeReference reference, ILEnvironment env) : base(reference, env) { this.elementType = elementType; }
public RuntimeDirectType(TypeDefinition definition, ILEnvironment env) : base(definition, env) { }