public TestCaseMethodCompiler(IAssemblyLinker linker, IArchitecture architecture, IMetadataModule module, RuntimeType type, RuntimeMethod method) : base(linker, architecture, module, type, method) { // Populate the pipeline this.Pipeline.AddRange(new IMethodCompilerStage[] { new DecodingStage(), new BasicBlockBuilderStage(), new OperandDeterminationStage(), new InstructionLogger(), //new ConstantFoldingStage(), new CILTransformationStage(), //new InstructionLogger(), //InstructionStatisticsStage.Instance, //new DominanceCalculationStage(), //new EnterSSA(), //new ConstantPropagationStage(), //new ConstantFoldingStage(), //new LeaveSSA(), new StackLayoutStage(), new PlatformStubStage(), new InstructionLogger(), //new BlockReductionStage(), new LoopAwareBlockOrderStage(), //new SimpleTraceBlockOrderStage(), //new ReverseBlockOrderStage(), // reverse all the basic blocks and see if it breaks anything //new BasicBlockOrderStage() new CodeGenerationStage(), //new InstructionLogger(), }); }
/// <summary> /// Initializes a new instance of the <see cref="CilGenericType"/> class. /// </summary> /// <param name="typeModule">The type module.</param> /// <param name="token">The token.</param> /// <param name="baseGenericType">Type of the base generic.</param> /// <param name="genericTypeInstanceSignature">The generic type instance signature.</param> public CilGenericType(ITypeModule typeModule, Token token, RuntimeType baseGenericType, GenericInstSigType genericTypeInstanceSignature) : base(baseGenericType.Module, token, baseGenericType.BaseType) { Debug.Assert(baseGenericType is CilRuntimeType); this.signature = genericTypeInstanceSignature; this.baseGenericType = baseGenericType as CilRuntimeType; this.InstantiationModule = typeModule; base.Attributes = baseGenericType.Attributes; base.Namespace = baseGenericType.Namespace; if (this.baseGenericType.IsNested) { // TODO: find generic type ; } // TODO: if this is a nested types, add enclosing type(s) into genericArguments first this.genericArguments = signature.GenericArguments; base.Name = GetName(typeModule); ResolveMethods(); ResolveFields(); this.containsOpenGenericArguments = CheckContainsOpenGenericParameters(); }
private static CloudRuntime CreateRuntimeInternal(RuntimeType runtimeType, string roleName, string rolePath) { CloudRuntime runtime; switch (runtimeType) { case RuntimeType.Null: runtime = new NullCloudRuntime(); break; case RuntimeType.Cache: runtime = new CacheCloudRuntime(); break; case RuntimeType.PHP: runtime = new PHPCloudRuntime(); break; case RuntimeType.IISNode: runtime = new IISNodeCloudRuntime(); break; case RuntimeType.Node: default: runtime = new NodeCloudRuntime(); break; } runtime.Runtime = runtimeType; runtime.RoleName = roleName; runtime.FilePath = rolePath; return runtime; }
/// <summary> /// Initializes a new instance of <see cref="RuntimeMember"/>. /// </summary> /// <param name="token">Holds the token of this runtime metadata.</param> /// <param name="module">The module.</param> /// <param name="declaringType">The declaring type of the member.</param> /// <param name="attributes">Holds the attributes of the member.</param> protected RuntimeMember(int token, IMetadataModule module, RuntimeType declaringType, RuntimeAttribute[] attributes) : base(token) { this.module = module; this.declaringType = declaringType; this.attributes = attributes; }
/// <summary> /// Builds the method table. /// </summary> /// <param name="type">The type.</param> public void BuildMethodTable(RuntimeType type) { IList<RuntimeMethod> methodTable = CreateMethodTable(type); // HINT: The method table is offset by a four pointers: // 1. interface dispatch table pointer // 2. type pointer - contains the type information pointer, used to realize object.GetType(). // 3. interface bitmap // 4. parent type (if any) List<string> headerlinks = new List<string>(); // 1. interface dispatch table pointer if (type.Interfaces.Count == 0) headerlinks.Add(null); else headerlinks.Add(type.FullName + @"$itable"); // 2. type pointer - contains the type information pointer, used to realize object.GetType(). headerlinks.Add(null); // TODO: GetType() // 3. interface bitmap if (type.Interfaces.Count == 0) headerlinks.Add(null); else headerlinks.Add(type.FullName + @"$ibitmap"); // 4. parent type (if any) if (type.BaseType == null) headerlinks.Add(null); else headerlinks.Add(type.BaseType + @"$mtable"); AskLinkerToCreateMethodTable(type.FullName + @"$mtable", methodTable, headerlinks); }
private static CloudRuntime CreateRuntimeInternal(RuntimeType runtimeType, string roleName, string rolePath) { CloudRuntime runtime; switch (runtimeType) { case RuntimeType.Null: runtime = new NullCloudRuntime(); break; case RuntimeType.Cache: //Scaffolding for cache is no longer supported throw new NotSupportedException(Resources.CacheScaffoldingIsNotSupport); case RuntimeType.PHP: runtime = new PHPCloudRuntime(); break; case RuntimeType.IISNode: runtime = new IISNodeCloudRuntime(); break; case RuntimeType.Node: default: runtime = new NodeCloudRuntime(); break; } runtime.Runtime = runtimeType; runtime.RoleName = roleName; runtime.FilePath = rolePath; return runtime; }
public SimpleJitMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, Stream codeStream, ITypeSystem typeSystem) : base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, typeSystem, compiler.Pipeline.FindFirst<ITypeLayout>()) { if (codeStream == null) throw new ArgumentNullException(@"codeStream"); this.codeStream = codeStream; }
internal RuntimeInspectionOnlyConstructedGenericType(RuntimeType genericTypeDefinition, RuntimeType[] genericTypeArguments) : base(new ConstructedGenericTypeKey(genericTypeDefinition, genericTypeArguments)) { // We know this is a nop since just passed the key to our base class. However, we do want this subclass to follow // the PrepareKey() protocol without relying on knowledge about the base class so we'll go by the book and call it // anyway so that our GetHashCode() method is justified in not calling it again. this.PrepareKey(); }
public MethodCompiler(IAssemblyLinker linker, IArchitecture architecture, IMetadataModule module, RuntimeType type, RuntimeMethod method, Stream codeStream) : base(linker, architecture, module, type, method) { if (null == codeStream) throw new ArgumentNullException(@"codeStream"); _codeStream = codeStream; }
/// <summary> /// Initializes a new instance of the <see cref="CompilerGeneratedMethod"/> class. /// </summary> /// <param name="module">The module.</param> /// <param name="name">The name of the method.</param> /// <param name="declaringType">Type of the declaring.</param> public CompilerGeneratedMethod(IMetadataModule module, string name, RuntimeType declaringType) : base(0, module, declaringType) { if (name == null) throw new ArgumentNullException(@"name"); this.name = name; this.Parameters = new List<RuntimeParameter>(); }
/// <summary> /// Initializes a new instance of the <see cref="CilRuntimeField"/> class. /// </summary> /// <param name="module">The module.</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(IMetadataModule module, ref FieldRow field, IntPtr offset, IntPtr rva, RuntimeType declaringType) : base(module, declaringType) { this.nameIdx = field.NameStringIdx; this.signature = field.SignatureBlobIdx; base.Attributes = field.Flags; base.RVA = rva; //base.Offset = offset; ? }
/// <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; ? }
/// <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 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 override Type GetType(string className, bool throwOnError, bool ignoreCase) { if (className == null) { throw new ArgumentNullException("className"); } System.RuntimeType o = null; GetType(this.GetNativeHandle(), className, throwOnError, ignoreCase, JitHelpers.GetObjectHandleOnStack <System.RuntimeType>(ref o)); return(o); }
public CilGenericField(RuntimeType declaringType, RuntimeField genericField, FieldSignature signature) : base(declaringType.Module, declaringType) { this.genericField = genericField; this.Signature = signature; // FIXME: RVA, Address of these? this.Attributes = genericField.Attributes; this.SetAttributes(genericField.CustomAttributes); }
public CilGenericType(RuntimeType type, IMetadataModule referencingModule, GenericInstSigType genericTypeInstanceSignature, ISignatureContext signatureContext) : base(type.Token, type.Module) { this.signature = genericTypeInstanceSignature; this.signatureContext = signatureContext; this.signatureModule = referencingModule; this.Methods = this.GetMethods(); this.Fields = this.GetFields(); }
public sealed override String InternalGetNameIfAvailable(ref RuntimeType rootCauseForFailure) { RuntimeType shadowNamedType = ShadowNamedTypeIfAvailable; if (shadowNamedType != null) return shadowNamedType.Name; if (RuntimeAugments.Callbacks.IsReflectionBlocked(_runtimeTypeHandle)) return BlockedRuntimeTypeNameGenerator.GetNameForBlockedRuntimeType(this); rootCauseForFailure = this; return null; }
internal QCallTypeHandle(ref System.RuntimeType type) { _ptr = Unsafe.AsPointer(ref type); if (type != null) { _handle = type.GetUnderlyingNativeHandle(); } else { _handle = IntPtr.Zero; } }
internal QCallTypeHandle(ref System.RuntimeType type) { _ptr = Unsafe.AsPointer(ref type); if (type != null) { _handle = type.m_handle; } else { _handle = IntPtr.Zero; } }
public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) { throw new ArgumentNullException("attributeType"); } System.RuntimeType underlyingSystemType = attributeType.UnderlyingSystemType as System.RuntimeType; if (underlyingSystemType == null) { throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "attributeType"); } return(CustomAttribute.GetCustomAttributes(this, underlyingSystemType)); }
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(); }
public virtual bool IsDefined(Type attributeType, bool inherit) { if (attributeType == null) { throw new ArgumentNullException("attributeType"); } System.RuntimeType underlyingSystemType = attributeType.UnderlyingSystemType as System.RuntimeType; if (underlyingSystemType == null) { throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "caType"); } return(CustomAttribute.IsDefined(this, underlyingSystemType)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> public override bool Equals(RuntimeType other) { CilGenericType crt = other as CilGenericType; if (crt == null) return false; return this.moduleTypeSystem == crt.moduleTypeSystem && genericType == crt.genericType && signature == crt.signature && SigType.Equals(this.genericArguments, crt.genericArguments) && base.Equals(other); }
public void ScheduleTypeForCompilation(RuntimeType type) { if (type == null) throw new ArgumentNullException(@"type"); if (type.IsCompiled == true) { return; } if (type.IsGeneric == false) { Console.WriteLine(@"Scheduling type {0} for compilation.", type.FullName); Console.WriteLine(String.Format(@"Scheduling type {0} for compilation.", type.FullName)); this.typeQueue.Enqueue(type); type.IsCompiled = true; } }
/// <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 the <see cref="CilRuntimeMethod"/> class. /// </summary> /// <param name="token">The token.</param> /// <param name="module">The module.</param> /// <param name="method">The method.</param> /// <param name="maxParam">The max param.</param> /// <param name="declaringType">Type of the declaring.</param> public CilRuntimeMethod(int token, IMetadataModule module, ref MethodDefRow method, TokenTypes maxParam, RuntimeType declaringType) : base((int)token, module, 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 p = (int)(method.ParamList & TokenTypes.RowIndexMask) - 1 + RuntimeBase.Instance.TypeLoader.GetModuleOffset(module).ParameterOffset; base.Parameters = new ReadOnlyRuntimeParameterListView(p, count); } else { base.Parameters = ReadOnlyRuntimeParameterListView.Empty; } }
public void ScheduleTypeForCompilation(RuntimeType type) { if (type == null) throw new ArgumentNullException(@"type"); if (type.IsCompiled) { return; } if (!type.IsGeneric) { Console.ForegroundColor = ConsoleColor.Blue; Console.Write(@"[Scheduling] "); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(type.FullName); Debug.WriteLine(String.Format(@"Scheduling {0}", type.FullName)); typeQueue.Enqueue(type); type.IsCompiled = true; } }
internal TypeInfo(RuntimeType typeOfObj) { this.ServerType = GetQualifiedTypeName(typeOfObj); RuntimeType baseType = (RuntimeType) typeOfObj.BaseType; int num = 0; while ((baseType != typeof(MarshalByRefObject)) && (baseType != null)) { baseType = (RuntimeType) baseType.BaseType; num++; } string[] strArray = null; if (num > 0) { strArray = new string[num]; baseType = (RuntimeType) typeOfObj.BaseType; for (int i = 0; i < num; i++) { strArray[i] = GetQualifiedTypeName(baseType); baseType = (RuntimeType) baseType.BaseType; } } this.ServerHierarchy = strArray; Type[] interfaces = typeOfObj.GetInterfaces(); string[] strArray2 = null; bool isInterface = typeOfObj.IsInterface; if ((interfaces.Length > 0) || isInterface) { strArray2 = new string[interfaces.Length + (isInterface ? 1 : 0)]; for (int j = 0; j < interfaces.Length; j++) { strArray2[j] = GetQualifiedTypeName((RuntimeType) interfaces[j]); } if (isInterface) { strArray2[strArray2.Length - 1] = GetQualifiedTypeName(typeOfObj); } } this.InterfacesImplemented = strArray2; }
public TestCaseMethodCompiler(TestCaseAssemblyCompiler compiler, IArchitecture architecture, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method) : base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), architecture, compilationScheduler, type, method, compiler.TypeSystem, compiler.Pipeline.FindFirst<ITypeLayout>()) { this.assemblyCompiler = compiler; // Populate the pipeline this.Pipeline.AddRange(new IMethodCompilerStage[] { new DecodingStage(), //new InstructionLogger(), new BasicBlockBuilderStage(), //new InstructionLogger(), new OperandDeterminationStage(), //new InstructionLogger(), new StaticAllocationResolutionStage(), //new InstructionLogger(), //new ConstantFoldingStage(), new CILTransformationStage(), //new InstructionLogger(), new CILLeakGuardStage() { MustThrowCompilationException = true }, //new InstructionLogger(), //InstructionStatisticsStage.Instance, //new DominanceCalculationStage(), //new EnterSSA(), //new ConstantPropagationStage(), //new ConstantFoldingStage(), //new LeaveSSA(), new StackLayoutStage(), new PlatformStubStage(), //new InstructionLogger(), //new BlockReductionStage(), new LoopAwareBlockOrderStage(), //new SimpleTraceBlockOrderStage(), //new ReverseBlockOrderStage(), // reverse all the basic blocks and see if it breaks anything //new BasicBlockOrderStage() new CodeGenerationStage(), //new InstructionLogger(), }); }
/// <summary> /// Initializes the specified tag name. /// </summary> /// <param name="tagName">Name of the tag.</param> /// <param name="markup">The markup.</param> /// <param name="tokens">The tokens.</param> public override void Initialize( string tagName, string markup, List<string> tokens ) { var parms = ParseMarkup( markup ); if ( parms.Any( p => p.Key == "type" ) ) { if (parms["type"].ToLower() == "class" ) { _runtimeType = RuntimeType.CLASS; } else { _runtimeType = RuntimeType.SCRIPT; } } if ( parms.Any( p => p.Key == "import" ) ) { _imports = parms["import"].Split( ',' ).ToList(); } base.Initialize( tagName, markup, tokens ); }
internal static extern CorElementType GetCorElementType(RuntimeType type);
internal static extern bool HasInstantiation(RuntimeType type);
internal static extern bool IsComObject(RuntimeType type);
internal static extern bool IsInstanceOfType(RuntimeType type, [NotNullWhen(true)] object?o);
internal static extern RuntimeModule GetModule(RuntimeType type);
internal static Type GetGenericTypeDefinition(RuntimeType type) { return(GetGenericTypeDefinition_impl(type)); }
internal static bool IsByRef(RuntimeType type) { CorElementType corElemType = GetCorElementType(type); return(corElemType == CorElementType.ELEMENT_TYPE_BYREF); }
internal static bool IsInterface(RuntimeType type) { return((type.Attributes & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface); }
internal static extern TypeAttributes GetAttributes(RuntimeType type);
internal static extern IntPtr GetGenericParameterInfo(RuntimeType type);
private static extern Type GetGenericTypeDefinition_impl(RuntimeType type);
/// <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; }
// reference to TypedReference is banned, so have to pass result as void pointer private unsafe extern void InternalGetNextArg(void * result, RuntimeType rt);
internal static extern bool IsGenericVariable(RuntimeType type);
internal static bool IsSzArray(RuntimeType type) { CorElementType corElemType = GetCorElementType(type); return(corElemType == CorElementType.ELEMENT_TYPE_SZARRAY); }
internal static bool IsPointer(RuntimeType type) { CorElementType corElemType = GetCorElementType(type); return(corElemType == CorElementType.ELEMENT_TYPE_PTR); }
internal static bool IsEquivalentTo(RuntimeType rtType1, RuntimeType rtType2) { // refence check is done earlier and we don't recognize anything else return(false); }
internal static bool IsContextful(RuntimeType type) { return(false); }
internal static bool IsComObject(RuntimeType type, bool isGenericCOM) { return(isGenericCOM ? false : IsComObject(type)); }
internal static extern RuntimeType GetBaseType(RuntimeType type);
private static extern int GetMetadataToken(RuntimeType type);
internal static bool CanCastTo(RuntimeType type, RuntimeType target) { return(type_is_assignable_from(target, type)); }
internal static extern bool IsGenericTypeDefinition(RuntimeType type);
internal static extern int GetArrayRank(RuntimeType type);
internal static int GetToken(RuntimeType type) { return(GetMetadataToken(type)); }
protected RuntimePointerType(RuntimeType runtimeTargetType) : base(runtimeTargetType) { }
internal static extern RuntimeAssembly GetAssembly(RuntimeType type);
protected RuntimeArrayType(RuntimeType runtimeElementType, bool multiDim, int rank) : base(runtimeElementType) { _multiDim = multiDim; Rank = rank; }
internal static extern RuntimeType GetElementType(RuntimeType type);