/// <summary> /// Populates the <see cref="RuntimeAttribute"/> with the values in <paramref name="car"/>. /// </summary> /// <param name="moduleTypeSystem">The module type system.</param> /// <param name="car">The custom attribute row from metadata.</param> public RuntimeAttribute(IModuleTypeSystem moduleTypeSystem, CustomAttributeRow car) { attribute = null; attributeBlob = car.ValueBlobIdx; ctor = car.TypeIdx; this.moduleTypeSystem = moduleTypeSystem; }
/// <summary> /// Initializes a new instance of the <see cref="CilRuntimeType"/> class. /// </summary> /// <param name="moduleTypeSystem">The module type system.</param> /// <param name="token">The token.</param> /// <param name="typeDefRow">The type def row.</param> /// <param name="maxField">The max field.</param> /// <param name="maxMethod">The max method.</param> /// <param name="packing">The packing.</param> /// <param name="size">The size.</param> public CilRuntimeType(IModuleTypeSystem moduleTypeSystem, TokenTypes token, TypeDefRow typeDefRow, TokenTypes maxField, TokenTypes maxMethod, int packing, int size) : base(moduleTypeSystem, (int)token) { this.baseTypeToken = typeDefRow.Extends; this.nameIdx = typeDefRow.TypeNameIdx; this.namespaceIdx = typeDefRow.TypeNamespaceIdx; base.Attributes = typeDefRow.Flags; base.Pack = packing; base.Size = size; // Load all fields of the type int members = maxField - typeDefRow.FieldList; if (0 < members) { int i = (int)(typeDefRow.FieldList & TokenTypes.RowIndexMask) - 1; base.Fields = new ReadOnlyRuntimeFieldListView((IModuleTypeSystemInternalList)moduleTypeSystem, i, members); } else { base.Fields = ReadOnlyRuntimeFieldListView.Empty; } // Load all methods of the type members = maxMethod - typeDefRow.MethodList; if (0 < members) { int i = (int)(typeDefRow.MethodList & TokenTypes.RowIndexMask) - 1; base.Methods = new ReadOnlyRuntimeMethodListView((IModuleTypeSystemInternalList)moduleTypeSystem, i, members); } else { base.Methods = ReadOnlyRuntimeMethodListView.Empty; } }
/// <summary> /// Initializes a new instance of the <see cref="CilRuntimeField"/> class. /// </summary> /// <param name="moduleTypeSystem">The module type system.</param> /// <param name="field">The field.</param> /// <param name="offset">The offset.</param> /// <param name="rva">The rva.</param> /// <param name="declaringType">Type of the declaring.</param> public CilRuntimeField(IModuleTypeSystem moduleTypeSystem, FieldRow field, uint offset, uint rva, RuntimeType declaringType) : base(moduleTypeSystem, declaringType) { this.nameIdx = field.NameStringIdx; this.signatureBlobIdx = field.SignatureBlobIdx; base.Attributes = field.Flags; base.RVA = rva; //base.Offset = offset; ? }
public CilRuntimeField(IModuleTypeSystem moduleTypeSystem, RuntimeField genericField, FieldSignature signature) : base(moduleTypeSystem, genericField.DeclaringType) { this.Name = genericField.Name; this.Attributes = genericField.Attributes; this.RVA = genericField.RVA; this.Signature = signature; this.SetAttributes(genericField.CustomAttributes); }
/// <summary> /// Initializes a new instance of the <see cref="LinkerGeneratedMethod"/> class. /// </summary> /// <param name="typeSystem">The type system.</param> /// <param name="name">The name of the method.</param> /// <param name="declaringType">Type of the declaring.</param> public LinkerGeneratedMethod(IModuleTypeSystem typeSystem, string name, RuntimeType declaringType) : base(typeSystem, 0, declaringType) { if (name == null) throw new ArgumentNullException(@"name"); this.name = name; this.signature = new MethodSignature(new SigType(CilElementType.Void), new SigType[0]); this.Parameters = new List<RuntimeParameter>(); }
public CilGenericField(IModuleTypeSystem moduleTypeSystem, RuntimeField genericField, FieldSignature signature, CilGenericType declaringType) : base(moduleTypeSystem, declaringType) { this.Signature = signature; this.genericField = genericField; this.Attributes = genericField.Attributes; this.SetAttributes(genericField.CustomAttributes); return; }
public CilGenericMethod(IModuleTypeSystem moduleTypeSystem, CilRuntimeMethod method, MethodSignature signature, RuntimeType declaringType) : base(moduleTypeSystem, method.Token, declaringType) { this.genericMethod = method; this.Signature = signature; this.Attributes = method.Attributes; this.ImplAttributes = method.ImplAttributes; this.Rva = method.Rva; this.Parameters = method.Parameters; }
public CilGenericType(IModuleTypeSystem moduleTypeSystem, RuntimeType genericType, GenericInstSigType genericTypeInstanceSignature) : base(moduleTypeSystem, genericType.Token) { this.signature = genericTypeInstanceSignature; this.genericArguments = signature.GenericArguments; this.genericType = genericType; base.Attributes = genericType.Attributes; this.Methods = this.GetMethods(); this.Fields = this.GetFields(); }
/// <summary> /// Initializes a new instance of the <see cref="LinkerGeneratedType"/> class. /// </summary> /// <param name="moduleTypeSystem">The module type system.</param> /// <param name="nameSpace">The name space.</param> /// <param name="name">The name.</param> public LinkerGeneratedType(IModuleTypeSystem moduleTypeSystem, string nameSpace, string name) : base(moduleTypeSystem, 0) { if (nameSpace == null) throw new ArgumentNullException(@"namespace"); if (name == null) throw new ArgumentNullException(@"name"); this.methods = new List<RuntimeMethod>(); base.Namespace = nameSpace; base.Name = name; base.Methods = this.methods; base.Fields = new List<RuntimeField>(); }
/// <summary> /// Initializes a new instance of the <see cref="CilRuntimeMethod"/> class. /// </summary> /// <param name="moduleTypeSystem">The module type system.</param> /// <param name="token">The token.</param> /// <param name="method">The method.</param> /// <param name="maxParam">The max param.</param> /// <param name="declaringType">Type of the declaring.</param> public CilRuntimeMethod(IModuleTypeSystem moduleTypeSystem, int token, MethodDefRow method, TokenTypes maxParam, RuntimeType declaringType) : base(moduleTypeSystem, (int)token, declaringType) { this.nameIdx = method.NameStringIdx; this.signatureBlobIdx = method.SignatureBlobIdx; base.Attributes = method.Flags; base.ImplAttributes = method.ImplFlags; base.Rva = method.Rva; if (method.ParamList < maxParam) { int count = maxParam - method.ParamList; int start = (int)(method.ParamList & TokenTypes.RowIndexMask) - 1; base.Parameters = new ReadOnlyRuntimeParameterListView((IModuleTypeSystemInternalList)moduleTypeSystem, start, count); } else { base.Parameters = ReadOnlyRuntimeParameterListView.Empty; } }
/// <summary> /// Initializes a new instance of <see cref="RuntimeMember"/>. /// </summary> /// <param name="moduleTypeSystem">The module type system.</param> /// <param name="token">Holds the token of this runtime metadata.</param> /// <param name="declaringType">The declaring type of the member.</param> /// <param name="attributes">Holds the attributes of the member.</param> protected RuntimeMember(IModuleTypeSystem moduleTypeSystem, int token, RuntimeType declaringType, RuntimeAttribute[] attributes) : base(moduleTypeSystem, token) { this.declaringType = declaringType; this.attributes = attributes; }
/// <summary> /// Setups the specified compiler. /// </summary> /// <param name="compiler">The compiler.</param> public void Setup(IMethodCompiler compiler) { if (compiler == null) throw new ArgumentNullException(@"compiler"); methodCompiler = compiler; InstructionSet = compiler.InstructionSet; basicBlocks = compiler.BasicBlocks; architecture = compiler.Architecture; moduleTypeSystem = compiler.Method.ModuleTypeSystem; typeSystem = compiler.TypeSystem; typeLayout = compiler.TypeLayout; callingConvention = architecture.GetCallingConvention(typeLayout); architecture.GetTypeRequirements(BuiltInSigType.IntPtr, out nativePointerSize, out nativePointerAlignment); }
/// <summary> /// Initializes a new instance of <see cref="RuntimeObject"/>. /// </summary> /// <param name="token">The runtime token of this metadata.</param> protected RuntimeObject(IModuleTypeSystem moduleTypeSystem, int token) { this.token = token; this.moduleTypeSystem = moduleTypeSystem; }
/// <summary> /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class. /// </summary> /// <param name="linker">The _linker.</param> /// <param name="architecture">The target compilation Architecture.</param> /// <param name="type">The type, which owns the _method to compile.</param> /// <param name="method">The method to compile by this instance.</param> protected BaseMethodCompiler( IAssemblyLinker linker, IArchitecture architecture, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, ITypeSystem typeSystem, ITypeLayout typeLayout) { if (architecture == null) throw new ArgumentNullException(@"architecture"); if (linker == null) throw new ArgumentNullException(@"linker"); if (compilationScheduler == null) throw new ArgumentNullException(@"compilationScheduler"); this.linker = linker; this.architecture = architecture; this.method = method; this.type = type; parameters = new List<Operand>(new Operand[method.Parameters.Count]); nextStackSlot = 0; basicBlocks = new List<BasicBlock>(); instructionSet = null; // this will be set later pipeline = new CompilerPipeline(); this.compilationScheduler = compilationScheduler; this.moduleTypeSystem = method.ModuleTypeSystem; this.typeSystem = typeSystem; this.typeLayout = typeLayout; }