Esempio n. 1
0
        public BoundTypeDefinitionMask_I EnsureBound(BoundRuntimicModelMask_I semanticModel, System.Type type)
        {
            throw new Exception("Debug");
            //var typeReference = Cecil.Types.Getting.GetTypeReference(semanticModel, type);

            //return EnsureBound(semanticModel, typeReference, type);
        }
Esempio n. 2
0
        public SemanticTypeDefinitionMask_I Ensure(BoundRuntimicModelMask_I semanticModel, TypeReference input, BoundTypeDefinitionMask_I declaringType, System.Type underlyingType)
        {
            ArrayType arrayType = (ArrayType)input;

            SemanticTypeDefinitionMask_I elementType;


            if (underlyingType == null)
            {
                elementType = Execution.Types.Ensuring.Ensure(semanticModel, arrayType.ElementType, null, null);
            }
            else
            {
                elementType = Execution.Types.Ensuring.Ensure(semanticModel, arrayType.ElementType, underlyingType.GetElementType(), null);
            }

            if (IfAlreadyCreatedReturn(elementType, arrayType.Rank, out SemanticArrayTypeDefinitionMask_I existing))
            {
                return(existing);
            }

            var bound = Types.Creation.Create(semanticModel, input, null);

            bound.SourceTypeReference = input;

            var arrayDef = (BoundArrayTypeDefinition_I)bound;

            elementType.Arrays.Add(arrayType.Rank, arrayDef);

            arrayDef.ElementType = elementType;

            bound.BaseType = Execution.Types.Ensuring.Ensure(semanticModel, typeof(System.Array));

            if (!arrayDef.ElementType.IsBound())
            {
                throw new System.Exception("Expected the element type to be a bound type. Cannot create the undelrying array type without a runtime type.");
            }

            var arrayElementType = (BoundTypeDefinitionMask_I)arrayDef.ElementType;

            var arrayElementUndelryingType = arrayElementType.UnderlyingType;

            if (arrayType.Rank == 1)
            {
                // Makes a vector
                bound.UnderlyingType = arrayElementUndelryingType.MakeArrayType();
            }
            else
            {
                // Makes an multi-dimensional array
                bound.UnderlyingType = arrayElementUndelryingType.MakeArrayType(arrayType.Rank);
            }

            return(bound);
        }
Esempio n. 3
0
        public BoundTypeDefinitionMask_I EnsureBound(BoundRuntimicModelMask_I semanticModel, TypeReference typeReference, System.Type type)
        {
            var semanticMask = Ensure(semanticModel, typeReference, type, null);

            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);
        }
Esempio n. 4
0
        public SemanticTypeDefinitionMask_I Ensure(BoundRuntimicModelMask_I boundModel, TypeReference typeReference, System.Type underlyingType, BoundTypeDefinitionMask_I declaringType)
        {
            // Check to see if this input is to be converted, or needs to be relegated to bound only.
            if (Types.IsConverted(boundModel, typeReference))             // The call does not belong to the conversion code because
            {
                var conversionModel = (ILConversionRuntimicModel)boundModel;

                return(Conversion.Metadata.Members.Types.Ensuring.Ensure(conversionModel.Conversion, typeReference, (ConvertedTypeDefinition_I)declaringType));
            }
            else
            {
                return(Bound.Metadata.Members.Types.Ensuring.Ensure(boundModel, typeReference, underlyingType, declaringType));
            }
        }
Esempio n. 5
0
        public void Add(BoundRuntimicModelMask_I model, SemanticTypeDefinitionMask_I semantic, int arrayTypeRank)
        {
            throw new System.Exception("Debug");
            //var resolutionName = Cecil.Types.Naming.GetResolutionName(semantic.SourceTypeReference);

            //if (!model.Unified.Arrays.TryGetValue(resolutionName, out UnifiedArrayInstanceNodeSet set))
            //{
            //	set = new UnifiedArrayInstanceNodeSet();

            //	model.Unified.Arrays.Add(resolutionName, set);
            //}

            //         set.Instances.Add(new UnifiedArrayInstanceNode()
            //         {
            //          ElementResolutionName = resolutionName,
            //             Rank = arrayTypeRank,
            //	SemanticType = semantic
            //         });
        }
Esempio n. 6
0
        public UnifiedArrayInstanceNode Get(BoundRuntimicModelMask_I model, TypeReference arrayType, int rank)
        {
            throw new System.Exception("Debug");
            //var resolutionName = Cecil.Types.Naming.GetResolutionName(arrayType);

            //if (!model.Unified.Arrays.TryGetValue(resolutionName, out UnifiedArrayInstanceNodeSet set))
            //{
            //	return null;
            //}

            //for (int i = 0; i < set.Instances.Count; i++)
            //{
            //	var item = set.Instances[i];

            //	if (item.Rank != rank) continue;

            //	return item;
            //}

            //return null;
        }
Esempio n. 7
0
        public SemanticTypeDefinitionMask_I Ensure(BoundRuntimicModelMask_I semanticModel, TypeReference input, BoundTypeDefinitionMask_I declaringType, System.Type underlyingType)
        {
            string resolutionName = Cecil.Types.Naming.GetPointerElementName(input);

            var node = Unified.Types.Get(semanticModel, resolutionName);

            if (node.PointerType != null)
            {
                return(node.PointerType);
            }

            var bound = Types.Creation.Create(semanticModel, input, underlyingType);

            // Add the type instance to the model.  Do not do any recursive calls till this methods is called.
            node.PointerType = bound;


            if (bound.IsNestedType())
            {
                if (declaringType == null)
                {
                    throw new Exception("Declaring type is null.  Cannot create a nested type.");
                }

                var nestedType = (BoundTypeDefinitionWithDeclaringType_I)bound;

                nestedType.DeclaringType = declaringType;
            }


            bound.UnderlyingType = underlyingType;

            Members.TypeParameters.Building.EnsureTypeParametersIfAny(semanticModel, bound);

            return(bound);
        }
Esempio n. 8
0
        /// <summary>
        /// Ensures the type is part of the module.
        /// </summary>
        /// <param name="semanticModel"></param>
        /// <param name="semanticModule"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public SemanticTypeDefinitionMask_I Ensure(BoundRuntimicModelMask_I semanticModel, Type input)
        {
            var typeReference = Bound.Models.Types.GetTypeReference(semanticModel, input);

            return(Ensure(semanticModel, typeReference, input, null));
        }