public ExecutionTypeNode_I[] Build(ExecutionEnsureContext context, GenericInstanceType inputType, out Type[] underlyingTypes) { underlyingTypes = null; if (inputType.GenericArguments.Count <= 0) { return(new ExecutionTypeNode_I[0]); } var types = new ExecutionTypeNode_I[inputType.GenericArguments.Count]; underlyingTypes = new Type[inputType.GenericArguments.Count]; for (var i = 0; i < inputType.GenericArguments.Count; i++) { var genericArgument = inputType.GenericArguments[i]; types[i] = Execution.Types.Ensuring.Ensure(context, genericArgument, cloneContext: true); if (types[i].Type.SourceTypeReference == null) { throw new Exception("null type reference"); } underlyingTypes[i] = types[i].Type.UnderlyingType; } return(types); }
public ExecutionTypeNode_I Ensure(ExecutionEnsureContext context) { var pointerStemType = Execution.Types.Ensuring.Ensure(new ExecutionEnsureContext() { Conversion = context.Conversion, RuntimicSystem = context.RuntimicSystem, StructuralInputTypeNode = context.StructuralInputTypeNode.StemType }); if (pointerStemType.PointerType != null) { return(pointerStemType.PointerType); } var boundTypeDefinition = new BoundPointerTypeDefinition() { UnderlyingType = pointerStemType.Type.UnderlyingType.MakePointerType() }; pointerStemType.PointerType = new BoundTypeNode() { IsPointerType = true, StemType = pointerStemType, IsDerived = true, MetadataToken = context.StructuralInputTypeNode.MetadataToken, InputStructuralNode = context.StructuralInputTypeNode, Type = boundTypeDefinition }; return(pointerStemType.PointerType); }
public ExecutionEnsureContext CloneEnvironmentParameters(ExecutionEnsureContext context) { return(new ExecutionEnsureContext() { RuntimicSystem = context.RuntimicSystem, Conversion = context.Conversion }); }
public BoundTypeDefinitionMask_I EnsureBound(ExecutionEnsureContext context, TypeReference genericArgument, bool cloneContext) { if (cloneContext) { context = Execution.Types.Ensuring.CloneEnvironmentParameters(context); } context.TypeReference = genericArgument; return(EnsureBound(context)); }
public System.Type EnsureToType(RuntimicSystemModel model, TypeReference typeReference, System.Type underlyingType, out BoundTypeDefinitionMask_I boundType) { var context = new ExecutionEnsureContext() { RuntimicSystem = model, UnderlyingType = underlyingType, TypeReference = typeReference }; return(EnsureToType(context, out boundType)); }
public ExecutionTypeNode_I Ensure(ExecutionEnsureContext context, TypeReference genericArgument, bool cloneContext) { if (cloneContext) { context = Execution.Types.Ensuring.CloneEnvironmentParameters(context); } context.TypeReference = genericArgument; return(Ensure(context)); }
public BoundTypeDefinitionMask_I EnsureBound(ExecutionEnsureContext context) { var semanticMask = Ensure(context).Type; if (!(semanticMask is BoundTypeDefinitionMask_I bound)) { throw new Exception($"Expected the resolved semantic type of type '{semanticMask.GetType()}' to be a bound type definition."); } return(bound); }
public Type EnsureToType(ILConversion conversion, TypeReference typeReference, out BoundTypeDefinitionMask_I boundType) { var context = new ExecutionEnsureContext() { Conversion = conversion, RuntimicSystem = conversion.RuntimicSystem, TypeReference = typeReference }; return(EnsureToType(context, out boundType)); }
//public SemanticTypeDefinitionMask_I Ensure(BoundRuntimicModelMask_I boundModel, ExecutionEnsureContext context) //{ // // Make sure valid search criteria is set. // if (context.TypeReference == null && context.UnderlyingType == null) // { // throw new Exception( // "A bound or converted type entry cannot be ensured without either a 'metadata type definition/reference' " + // "or a 'runtime type' (System.Type)."); // } // // The entire ensure algorithm works on making sure a semantic type exists for a type reference. If a type reference is not passed in, // // then the only other arugument to ensure that the type is ensure is the runtime type. // if (context.TypeReference == null) // { // context.TypeReference = Infrastructure.Models.Semantic.Types.GetTypeReference(boundModel, context.UnderlyingType, out SemanticTypeDefinitionMask_I possibleSemanticType); // if (possibleSemanticType != null && possibleSemanticType is BoundTypeDefinitionMask_I bound1) // { // return bound1; // } // } // // Now that it known that the type reference Ensures an entry in the unified model. // var unifiedNode = Unified.Types.Ensure(boundModel, context.TypeReference); // // If the type reference is by reference node, an underlying pointer node, an array node or a generic parameter node, // // then it is a secondary node. The primary node will need to be looked up first, and the secondary node will need to be determined second. // // Only once the secondary node is resolved can a bound or converted execution type be associated with the unified model. // if (unifiedNode.IsPrimary) // { // // Check to see if this input is to be converted, or needs to be relegated to bound only. // if (Types.IsConverted(boundModel, context.TypeReference)) // The call does not belong to the conversion code because // { // var conversionModel = (ILConversionRuntimicModel)boundModel; // return Conversion.Metadata.Members.Types.Ensuring.Ensure(conversionModel.Conversion, context.TypeReference, (ConvertedTypeDefinition_I)context.DeclaringType); // } // else // { // return Bound.Metadata.Members.Types.Ensuring.Ensure(boundModel, context); // } // } // else // { // return EnsureSecondaryNode(boundModel, context); // } //} public ExecutionTypeNode_I Ensure(ILConversion conversion, TypeReference typeReference, ConvertedTypeDefinition_I declaringType) { var context = new ExecutionEnsureContext() { DeclaringType = declaringType, TypeReference = typeReference, Conversion = conversion, RuntimicSystem = conversion.RuntimicSystem }; return(Ensure(context)); }
public BoundTypeDefinitionMask_I EnsureBound(RuntimicSystemModel model, TypeReference typeReference, System.Type type) { // Done collecting arguments, now use context. var context = new ExecutionEnsureContext() { RuntimicSystem = model, UnderlyingType = type, TypeReference = typeReference }; return(EnsureBound(context)); }
public BoundTypeDefinitionMask_I EnsureBound(ILConversion conversion, TypeReference typeReference) { // Done collecting arguments, now use context. var context = new ExecutionEnsureContext() { RuntimicSystem = conversion.RuntimicSystem, Conversion = conversion, TypeReference = typeReference }; return(EnsureBound(context)); }
public ExecutionTypeDefinitionMask_I Ensure(RuntimicSystemModel runtimicModel, TypeReference typeReference, System.Type underlyingType, BoundTypeDefinitionMask_I declaringType) { var context = new ExecutionEnsureContext() { UnderlyingType = underlyingType, TypeReference = typeReference, DeclaringType = declaringType, RuntimicSystem = runtimicModel }; return(Ensure(context).Type); }
public ExecutionTypeDefinitionMask_I Ensure(ILConversion conversion, TypeReference typeReference, System.Type underlyingType, BoundTypeDefinitionMask_I declaringType) { var context = new ExecutionEnsureContext() { UnderlyingType = underlyingType, TypeReference = typeReference, DeclaringType = declaringType, RuntimicSystem = conversion.RuntimicSystem, Conversion = conversion }; return(Ensure(context).Type); }
private bool IsConverted(ExecutionEnsureContext context) { var isConverted = context.IsConverted; if (isConverted != null) { return(isConverted.Value); } if (context.Conversion == null) { return(false); } var result = IsConverted(context.Conversion, context.StructuralInputTypeNode); context.IsConverted = result; return(result); }
public ExecutionTypeNode_I Ensure(ExecutionEnsureContext context) { if (!context.IsConverted.HasValue) { throw new Exception("Expected conversion to be figured out."); } // It would be nice if all generic instance types could be traced back signatures, but the signature // of a generic instance is not always just stored in a type specification table. Sometimes it is // part of a method signature. Thus, since it is basically a series of type definitions / references // that make a generic instance, the blueprint and the arguments have to be used to look up the // particular instance that is required. var typeReference = (GenericInstanceType)context.TypeReference; // If not first, then a dependency is created by method calls needing the generic instance var blueprintNode = Execution.Types.Ensuring.Ensure(context, typeReference.ElementType, cloneContext: true); var blueprint = (BoundGenericTypeDefinitionMask_I)blueprintNode.Type; var typeArguments = Bound.Metadata.Members.TypeArguments.Building.Build(context, typeReference, out Type[] typeArgumentTypes); if (CheckForBranch(blueprintNode, typeArguments, out ExecutionGenericInstanceTypeNode ensure)) { return(ensure); } var structuralInputTypeNode = context.StructuralInputTypeNode; var conversionTypeNode = new ExecutionGenericInstanceTypeNode() { ByReferenceType = null, Id = 0, InputStructuralNode = structuralInputTypeNode, IsDerived = true, PointerType = null, }; SetNode(blueprintNode, conversionTypeNode); if (context.IsConverted.Value) { //var convertedModuleNode = Conversion.Metadata.Modules.Get(context.Conversion, structuralInputTypeNode.Module.VersionId); //conversionTypeNode.Module = convertedModuleNode; //conversionTypeNode.Assembly = convertedModuleNode.AssemblyNode; var conversion = context.Conversion; var underlyingType = Bound.MakeGenericType(blueprint, typeArgumentTypes); var converted = (ConvertedGenericTypeDefinition_I)Conversion.Metadata.Members.Types.Creation.Create(conversion.RuntimicSystem, typeReference); conversionTypeNode.Type = converted; converted.Blueprint = blueprint; converted.UnderlyingType = underlyingType; for (var j = 0; j < typeArguments.Length; j++) { var currentTypeArgument = typeArguments[j]; converted.TypeArguments.All.Add(currentTypeArgument.Type); } Conversion.Metadata.Members.Types.Building.UpdateBuildPhase(converted, BuildPhaseKind.TypeDefined); Conversion.Metadata.Members.Types.Building.IfPossibleBuildPhase2(conversion, converted); return(conversionTypeNode); } else { //var typeReference = (GenericInstanceType)context.TypeReference; // If not first, then a dependency is created by method calls needing the generic instance //var blueprint = (BoundGenericTypeDefinitionMask_I)Execution.Types.Ensuring.EnsureBound(context, typeReference.ElementType, cloneContext: true); //var typeArguments = Bound.Metadata.Members.TypeArguments.Building.Build(context, typeReference, out Type[] typeArgumentTypes); //var convertedModuleNode = Bound.Metadata.Modules.Getting.Get(context.RuntimicSystem, structuralInputTypeNode.Module.VersionId); //conversionTypeNode.Module = convertedModuleNode; //conversionTypeNode.Assembly = convertedModuleNode.AssemblyNode; var underlyingType = Bound.MakeGenericType(blueprint, typeArgumentTypes); var converted = (BoundGenericTypeDefinition_I)Bound.Metadata.Members.Types.Creation.Create(context.RuntimicSystem, typeReference, underlyingType); conversionTypeNode.Type = converted; converted.Blueprint = blueprint; converted.UnderlyingType = underlyingType; for (var j = 0; j < typeArguments.Length; j++) { var currentTypeArgument = typeArguments[j]; converted.TypeArguments.All.Add(currentTypeArgument.Type); } conversionTypeNode.Type = converted; if ( //hasGenericParameters && underlyingType.IsGenericTypeDefinition) { // Check to see if effectively is a generic type definition. // A) Do not try to get methods for types that are generic type definitions } else { Bound.Metadata.Members.Fields.Building.Generic.BuildFields(context.RuntimicSystem, converted); Bound.Metadata.Members.Constructors.Building.BuildConstructors(context.RuntimicSystem, converted); Bound.Metadata.Members.Methods.Building.BuildMethods(context.RuntimicSystem, converted); } return(conversionTypeNode); } }
public SemanticTypeDefinitionMask_I Ensure(RuntimicSystemModel boundModel, ExecutionEnsureContext context) { GenericParameter parameter = (GenericParameter)context.TypeReference; if (parameter.DeclaringType != null) { SemanticTypeMask_I semanticDeclaringType; if (context.DeclaringType != null) { semanticDeclaringType = context.DeclaringType; } else { var resolutionName = Types.Naming.GetResolutionName(parameter.DeclaringType); semanticDeclaringType = Models.Types.GetOrThrow(boundModel, resolutionName); } if (!(semanticDeclaringType is SemanticGenericTypeDefinitionMask_I genericDeclaringType)) { throw new Exception($"Expected the resolved semantic type to be a generic type of {typeof(SemanticGenericTypeDefinitionMask_I)}."); } if (genericDeclaringType.TypeParameters.ByName.TryGetValue(parameter.Name, out SemanticGenericParameterTypeDefinitionMask_I semanticTypeParameter)) { if (!semanticTypeParameter.IsBound()) { throw new Exception("Expected the generic parameter type to be a bound type."); } return((BoundTypeDefinitionMask_I)semanticTypeParameter); } var typeParameter = CreateGenericParameter(genericDeclaringType); typeParameter.Attributes = Cecil.Metadata.Members.GenericParameters.GetTypeParameterAttributes(parameter); typeParameter.Name = parameter.Name; typeParameter.FullName = parameter.FullName; typeParameter.Position = parameter.Position; typeParameter.TypeParameterKind = GetTypeParameterKind(parameter.Type); typeParameter.Definition = parameter; typeParameter.SourceTypeReference = parameter; //typeParameter.ResolutionName = Cecil.Types.Naming.GetResolutionName(parameter); return(typeParameter); } else { if (!(parameter.DeclaringMethod is MethodDefinition methodDefinition)) { throw new Exception("Expected a method definition"); } TypeReference declaringType; if (methodDefinition.DeclaringType != null) { declaringType = methodDefinition.DeclaringType; } else { if (context.MethodReference == null) { } declaringType = context.MethodReference.DeclaringType; } var resolutionName = Types.Naming.GetResolutionName(declaringType); var semanticType = Models.Types.GetOrThrow(boundModel, resolutionName); if (!(semanticType is BoundTypeDefinitionWithMethodsMask_I convertedTypeWithMethods)) { throw new Exception("Trying to add a method to a type that does not support methods."); } var method = Bound.Metadata.Members.Methods.Getting.FindMethodByDefinition(boundModel, convertedTypeWithMethods, methodDefinition); if (method.TypeParameters.ByName.TryGetValue(parameter.Name, out SemanticGenericParameterTypeDefinitionMask_I semanticTypeParameter)) { if (!semanticTypeParameter.IsBound()) { throw new Exception("Expected the generic parameter type to be a bound type."); } return((BoundTypeDefinitionMask_I)semanticTypeParameter); } var typeParameter = CreateGenericParameter(semanticType); typeParameter.Attributes = Cecil.Metadata.Members.GenericParameters.GetTypeParameterAttributes(parameter); typeParameter.Name = parameter.Name; typeParameter.FullName = parameter.FullName; typeParameter.Position = parameter.Position; typeParameter.TypeParameterKind = GetTypeParameterKind(parameter.Type); typeParameter.Definition = parameter; typeParameter.SourceTypeReference = parameter; typeParameter.DeclaringTypeDefinitionEntry = convertedTypeWithMethods; typeParameter.ResolutionName = Cecil.Types.Naming.GetResolutionName(parameter); //method.TypeParameters.ByName.Add(parameter.Name, typeParameter); return(typeParameter); } }
/// <summary> /// Ensures the execution type system has a type entry for the specified type reference, type, or structural input type node. /// </summary> /// <param name="context"></param> public ExecutionTypeNode_I Ensure(ExecutionEnsureContext context) { //if (inputType.InputStructuralNode.CecilTypeReference.Name != "<Module>") //{ // Execution.Types.Ensuring.Ensure(conversion.RuntimicSystem, inputType); //} if (context?.TypeReference?.FullName == "<PrivateImplementationDetails>" ) { } // Step 1 - Get Strcutral input type node if (context.StructuralInputTypeNode == null) { if (context.TypeReference != null) { context.StructuralInputTypeNode = Infrastructure.Structural.Types.Ensure(context.RuntimicSystem, context.TypeReference, null, context.MethodReference); } else if (context.UnderlyingType != null) { context.StructuralInputTypeNode = Infrastructure.Structural.Types.Ensure(context.RuntimicSystem, context.UnderlyingType); } else { throw new Exception("A bound or converted type entry cannot be ensured without either a 'metadata type definition/reference' " + "or a 'runtime type' (System.Type)."); } } if (context.TypeReference == null) { context.TypeReference = context.StructuralInputTypeNode.CecilTypeReference; } var metadataToken = context.StructuralInputTypeNode.MetadataToken; context.RowId = metadataToken & 0x00FFFFFF; // Step 3 - Build out the execution node if (context.StructuralInputTypeNode.IsByReferenceType) { return(ByReferences.Ensure(context)); } // Depends upon the underlying unified entry if (context.StructuralInputTypeNode.IsPointerType) { return(Pointers.Ensure(context)); } // Depends upon the underlying unified entry if (context.StructuralInputTypeNode.IsArrayType) { return(Arrays.Ensure(context)); } // Depends upon the underlying unified entry if (context.StructuralInputTypeNode.IsGenericParameter) { // You cannot create a generic parameter directly. It is created when its parent type creates it. return(GenericParameters.Ensure(context)); } context.IsConverted = IsConverted(context); if (context.StructuralInputTypeNode.IsGenericInstance) { // You cannot create a generic parameter directly. It is created when its parent type creates it. return(GenericInstanceTypes.Ensure(context)); } return(DefinitionTypes.Ensure(context)); }
public ExecutionTypeNode_I Ensure(ExecutionEnsureContext context) { GenericParameter parameter = (GenericParameter)context.TypeReference; if (parameter.DeclaringType != null) { SemanticTypeMask_I semanticDeclaringType; if (context.DeclaringType != null) { semanticDeclaringType = context.DeclaringType; } else { semanticDeclaringType = Execution.Types.Ensuring.EnsureBound(context, parameter.DeclaringType, cloneContext: true); } if (!(semanticDeclaringType is SemanticGenericTypeDefinitionMask_I genericDeclaringType)) { throw new Exception($"Expected the resolved semantic type to be a generic type of {typeof(SemanticGenericTypeDefinitionMask_I)}."); } var semanticTypeParameter = genericDeclaringType.TypeParameters.All[parameter.Position]; if (semanticTypeParameter != null) { if (!semanticTypeParameter.IsBound()) { throw new Exception("Expected the generic parameter type to be a bound type."); } return(new ExecutionTypeNode() { Type = (ExecutionTypeDefinitionMask_I)semanticTypeParameter }); } } else { if (!(parameter.DeclaringMethod is MethodDefinition methodDefinition)) { throw new Exception("Expected a method definition"); } TypeReference declaringType; if (methodDefinition.DeclaringType != null) { declaringType = methodDefinition.DeclaringType; } else { if (context.MethodReference == null) { } declaringType = context.MethodReference.DeclaringType; } var semanticType = Execution.Types.Ensuring.EnsureBound(context, declaringType, cloneContext: true); if (!(semanticType is BoundTypeDefinitionWithMethodsMask_I convertedTypeWithMethods)) { throw new Exception("Trying to add a method to a type that does not support methods."); } var method = Bound.Metadata.Members.Methods.Getting.FindMethodByDefinition(context.RuntimicSystem, convertedTypeWithMethods, methodDefinition); if (method.TypeParameters.ByName.TryGetValue(parameter.Name, out SemanticGenericParameterTypeDefinitionMask_I semanticTypeParameter)) { if (!semanticTypeParameter.IsBound()) { throw new Exception("Expected the generic parameter type to be a bound type."); } return(new ExecutionTypeNode() { Type = (ExecutionTypeDefinitionMask_I)semanticTypeParameter }); } } throw new Exception("Type parameter not found."); }
/// <summary> /// Ensures the type is part of the module. /// </summary> public SemanticTypeDefinitionMask_I Ensure(RuntimicSystemModel semanticModel, ExecutionEnsureContext context) { if (context.TypeReference.FullName == "Root.Code.Containers.E01D.Sorting.SortingContainer_I`1<TContainer>") { } if (context.TypeReference.IsGenericParameter) // DOES NOT USE UNDERLYING TYPE OR DECLARING TYPE { // You cannot create a generic parameter directly. It is created when its parent type creates it. return(GenericParameters.Ensure(semanticModel, context.TypeReference)); } if (context.TypeReference.IsGenericInstance) { return(GenericInstances.Ensure(semanticModel, (GenericInstanceType)context.TypeReference, context.DeclaringType)); } // Ultimately the conversion process needs type and member infos if (context.UnderlyingType == null) { context.UnderlyingType = Models.Types.GetUnderlyingType(semanticModel, context.TypeReference); } if (context.DeclaringType == null && context.UnderlyingType?.DeclaringType != null) { if (context.TypeReference.IsRequiredModifier) { // Call back to the execution's type system so it can determine where to make the type //context.DeclaringType = (BoundTypeDefinitionMask_I)Execution.Metadata.Members.Types.Ensuring.Ensure(semanticModel, context.TypeReference.GetElementType(), context.UnderlyingType.DeclaringType, null); throw new System.Exception("Fix"); } else { // Call back to the execution's type system so it can determine where to make the type //context.DeclaringType = (BoundTypeDefinitionMask_I)Execution.Metadata.Members.Types.Ensuring.Ensure(semanticModel, context.TypeReference.DeclaringType, context.UnderlyingType.DeclaringType, null); throw new System.Exception("Fix"); } } if (context.TypeReference.IsRequiredModifier) { return(RequiredModifiers.Ensure(semanticModel, context.TypeReference, context.DeclaringType, context.UnderlyingType)); } if (context.TypeReference.IsDefinition) { return(NonGenericInstances.Ensure(semanticModel, context.TypeReference, context.DeclaringType, context.UnderlyingType)); } throw new Exception("Should never have happened. External references are now handled prior to calling this method bye the execution ensuring mechanism."); // External //var internalTypReference = Models.Types.External.Resolve(semanticModel, context.TypeReference); //return Execution.Metadata.Members.Types.Ensuring.Ensure(semanticModel, internalTypReference, context.UnderlyingType, context.DeclaringType); }
public ExecutionTypeNode_I Ensure(ExecutionEnsureContext context) { if (!context.IsConverted.HasValue) { throw new Exception("Expected conversion to be figured out."); } if (context.StructuralInputTypeNode.CecilTypeReference.IsNested && context.DeclaringType == null) { context.DeclaringType = Execution.Types.Ensuring.EnsureBound(context, context.StructuralInputTypeNode.CecilTypeReference.DeclaringType, cloneContext: true); } if (context.IsConverted.Value) { var conversion = context.Conversion; var structuralInputTypeNode = context.StructuralInputTypeNode; var metadataToken = structuralInputTypeNode.MetadataToken; var structuralAssembly = Conversion.Metadata.Assemblies.EnsureNode(context.Conversion, structuralInputTypeNode.Module.Assembly); var convertedModuleNode = Conversion.Metadata.Modules.Ensure(context.Conversion, structuralAssembly, structuralInputTypeNode.Module); var tableId = (int)(metadataToken & 0xFF000000); if (!convertedModuleNode.Tables.TryGetValue(tableId, out ConvertedTypeTable table)) { table = new ConvertedTypeTable(); convertedModuleNode.Tables.Add(tableId, table); } if (table.ByRow.TryGetValue((uint)context.RowId, out ConversionTypeNode conversionTypeNode)) { return(conversionTypeNode); } var converted = Conversion.Metadata.Members.Types.Creation.Create(conversion.RuntimicSystem, structuralInputTypeNode.CecilTypeReference); converted.Module = convertedModuleNode.ConvertedModule; conversionTypeNode = new ConversionTypeNode() { Assembly = structuralAssembly, ByReferenceType = null, Id = 0, InputStructuralNode = structuralInputTypeNode, IsByReferenceType = false, IsDerived = false, IsPointerType = false, MetadataToken = metadataToken, Module = convertedModuleNode, PointerType = null, Type = converted }; table.ByRow.Add((uint)context.RowId, conversionTypeNode); var convertedDeclaringType = context.ConvertedDeclaringType; Converted_BuildPhase1(conversion, structuralInputTypeNode, converted, convertedDeclaringType); Conversion.Metadata.Members.Types.Building.IfPossibleBuildPhase2(conversion, converted); return(conversionTypeNode); } else { var structuralInputTypeNode = context.StructuralInputTypeNode; if (structuralInputTypeNode.FullName == "Root.Code.Containers.E01D.Sorting.SortingContainer_I`1") { } var metadataToken = structuralInputTypeNode.MetadataToken; var boundAssembly = Bound.Metadata.Assemblies.EnsureNode(context.RuntimicSystem, structuralInputTypeNode.Module.Assembly); var boundModuleNode = Bound.Metadata.Modules.Ensuring.EnsureNode(context.RuntimicSystem, boundAssembly, structuralInputTypeNode.Module); var tableId = (int)(metadataToken & 0xFF000000); if (!boundModuleNode.Tables.TryGetValue(tableId, out BoundTypeTable table)) { table = new BoundTypeTable(); boundModuleNode.Tables.Add(tableId, table); } if (table.ByRow.TryGetValue((uint)context.RowId, out BoundTypeNode boundTypeNode)) { return(boundTypeNode); } //--------------------------------- // Conversion is going to occur. //--------------------------------- if (context.UnderlyingType == null) { context.UnderlyingType = Cecil.GetUnderlyingType(structuralInputTypeNode.CecilTypeReference); if (context.UnderlyingType == null) { throw new Exception("Null type"); } } var bound = Bound.Metadata.Members.Types.Creation.Create(context.RuntimicSystem, context.StructuralInputTypeNode.CecilTypeReference, context.UnderlyingType); boundTypeNode = new BoundTypeNode() { Assembly = boundAssembly, ByReferenceType = null, Id = 0, InputStructuralNode = structuralInputTypeNode, IsByReferenceType = false, IsDerived = false, IsPointerType = false, MetadataToken = metadataToken, Module = boundModuleNode, PointerType = null, Type = bound }; bound.Module = boundModuleNode.BoundModule; //// Add the type instance to the model. Do not do any recursive calls till this methods is called. table.ByRow.Add((uint)context.RowId, boundTypeNode); //Types.Addition.Add(semanticModel, boundModule, bound); Bound.Metadata.Members.Types.Building.NonGenericInstances.Phase1Initial.Build(context.RuntimicSystem, bound, context.UnderlyingType, context.DeclaringType); return(boundTypeNode); } }
public System.Type EnsureToType(ExecutionEnsureContext context) { return(EnsureToType(context, out BoundTypeDefinitionMask_I boundType)); }
public ExecutionTypeNode_I Ensure(ExecutionEnsureContext context) { ArrayType arrayType = (ArrayType)context.TypeReference; var arrayStemType = Execution.Types.Ensuring.Ensure(new ExecutionEnsureContext() { Conversion = context.Conversion, RuntimicSystem = context.RuntimicSystem, StructuralInputTypeNode = context.StructuralInputTypeNode.StemType }); if (CheckForBranch(arrayStemType, arrayType, out ExecutionTypeNode_I ensure)) { return(ensure); } ExecutionArrayTypeDefinition_I bound; ExecutionTypeNode_I node; if (arrayStemType.Type.IsConverted()) { // Converted multi-dimemsinal arrays do have constructors that need to come from a different source // than bound multi-dimemsinal arrays bound = (ExecutionArrayTypeDefinition_I)Conversion.Metadata.Members.Types.Creation.Create(context.RuntimicSystem, context.TypeReference); Conversion.Metadata.Members.Types.Building.UpdateBuildPhase((ConvertedTypeDefinition_I)bound, BuildPhaseKind.TypeCreated); node = new ConversionTypeNode() { IsArrayType = true, StemType = arrayStemType, IsDerived = true, InputStructuralNode = context.StructuralInputTypeNode, Type = (ConvertedTypeDefinition_I)bound, Rank = arrayType.Rank }; } else { bound = (ExecutionArrayTypeDefinition_I)Bound.Metadata.Members.Types.Creation.Create(context.RuntimicSystem, context.TypeReference, null); bound.UnderlyingType = context.UnderlyingType; node = new BoundTypeNode() { IsArrayType = true, StemType = arrayStemType, IsDerived = true, InputStructuralNode = context.StructuralInputTypeNode, Type = (BoundTypeDefinition)bound, Rank = arrayType.Rank }; } bound.SourceTypeReference = context.TypeReference; // bound.BaseType = (BoundTypeDefinitionMask_I)Execution.Types.Ensuring.Ensure(semanticModel, typeof(System.Array)); bound.ElementType = arrayStemType.Type; if (bound.UnderlyingType == null) { var elementType = arrayStemType.Type; if (arrayType.Rank == 1) { // Makes a vector bound.UnderlyingType = elementType.UnderlyingType.MakeArrayType(); } else { // Makes an multi-dimensional array bound.UnderlyingType = elementType.UnderlyingType.MakeArrayType(arrayType.Rank); } } SetNode(arrayStemType, node); return(node); }
private SemanticTypeDefinitionMask_I EnsureSecondaryNode(RuntimicSystemModel boundModel, ExecutionEnsureContext context) { //// Depends upon the underlying unified entry // if (context.TypeReference.IsByReference) // { // return ByReferences.Ensure(boundModel, context.TypeReference, context.DeclaringType, context.UnderlyingType); // } // // Depends upon the underlying unified entry // if (context.TypeReference.IsPointer) // { // return Pointers.Ensure(boundModel, context.TypeReference, context.DeclaringType, context.UnderlyingType); // } // // Depends upon the underlying unified entry // if (context.TypeReference.IsArray) // { // return Arrays.Ensure(boundModel, context.TypeReference, context.DeclaringType, context.UnderlyingType); // } // // Depends upon the underlying unified entry // if (context.TypeReference.IsGenericParameter) // { // // You cannot create a generic parameter directly. It is created when its parent type creates it. // return GenericParameters.Ensure(boundModel, context); // } throw new Exception("The type reference is not configured to be associated with a secondary node."); }
public BoundTypeDefinitionMask_I EnsureBound(ExecutionEnsureContext newContext, TypeReference genericArgument) { newContext.TypeReference = genericArgument; return(EnsureBound(newContext)); }