/// <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); }
/// <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)); }