コード例 #1
0
        public BoundTypeDefinition Build(RuntimicSystemModel semanticModel, BoundTypeDefinition bound, Type underlyingType, BoundTypeDefinitionMask_I declaringType)
        {
            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;

            if (underlyingType == null)
            {
                return(bound);
            }

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

            Fields.Building.NonGeneric.BuildFields(semanticModel, bound);

            Constructors.Building.BuildConstructors(semanticModel, bound);

            Methods.Building.BuildMethods(semanticModel, bound);

            return(bound);
        }
コード例 #2
0
ファイル: BuildingApi.cs プロジェクト: Evobolics/EvoAssembly
        public void EnsureTypeParametersIfAny(RuntimicSystemModel model, BoundTypeDefinition converted)
        {
            TypeReference inputType = converted.SourceTypeReference;

            if (!inputType.HasGenericParameters)
            {
                return;
            }

            var parameters = inputType.GenericParameters;

            var generic = (BoundGenericTypeDefinition_I)converted;

            Type[] typeArguments = converted.UnderlyingType.GetGenericArguments();

            for (var i = 0; i < parameters.Count; i++)
            {
                var parameter = parameters[i];

                var typeParameter = new BoundGenericParameterTypeDefinition()
                {
                    Attributes          = Cecil.Metadata.Members.GenericParameters.GetTypeParameterAttributes(parameter),
                    Name                = parameter.Name,
                    FullName            = parameter.FullName,
                    Position            = parameter.Position,
                    TypeParameterKind   = Cecil.Metadata.Members.GenericParameters.GetTypeParameterKind(parameter.Type),
                    Definition          = parameter,
                    SourceTypeReference = parameter
                };

                typeParameter.UnderlyingType = FindMatchingType(typeArguments, typeParameter.SourceTypeReference);

                //var typeParameter = CreateTypeParameter(model, typeArguments, inputType, parameters[i]);

                Members.TypeParameters.Add(model, generic.TypeParameters, typeParameter);
            }

            // DO THIS SEPERATELY, as the constraints could be self referencing, and it needs the parameters to be added to this type to find them.
            // THUS THE CREATE AND  ADD OPERATIONS NEED TO BE DONE FIRST.  This is the same reason why the add is called on ensuring before anything else.
            for (var i = 0; i < parameters.Count; i++)
            {
                var typeParameter = (BoundGenericParameterTypeDefinition)generic.TypeParameters.All[i];

                BuildConstraints(model, typeParameter);
            }

            //for (var i = 0; i < parameters.Count; i++)
            //{
            //	var typeParameter = (BoundGenericParameterTypeDefinition)generic.TypeParameters.All[i];

            //	//if (typeParameter.InterfaceTypeConstraints != null && typeParameter.InterfaceTypeConstraints.Count > 0)
            //	//{
            //	//	GetInterfaceTypeConstraints(model, typeParameter.InterfaceTypeConstraints);
            //	//}

            //	//GetBaseTypeConstraint(model, typeParameter.BaseTypeConstraint);

            //}
        }
コード例 #3
0
ファイル: CreationApi.cs プロジェクト: Evobolics/EvoAssembly
        public void CreatePost(BoundTypeDefinition bound, SemanticTypeInformation typeInformation, System.Type underlyingType)
        {
            if (bound.IsGeneric())
            {
                var generic = (BoundGenericTypeDefinition_I)bound;

                generic.GenericKind = typeInformation.GenericKind;

                generic.SourceGenericInstanceType = typeInformation.GenericInstanceType;

                if (typeInformation.GenericTypeDefinition == null)
                {
                    if (typeInformation.IsClosedGeneric && !typeInformation.IsAnonymousType)
                    {
                        throw new System.Exception("Expected a generic type definition");
                    }
                }
            }



            bound.AssemblyQualifiedName = Cecil.Metadata.Members.Types.Naming.GetAssemblyQualifiedName(typeInformation.TypeReference);
            bound.FullName = typeInformation.FullName;
            bound.Name     = typeInformation.Name;


            bound.PackingSize         = typeInformation.PackingSize;
            bound.SourceTypeReference = typeInformation.TypeReference;
            bound.ResolutionName      = Types.Naming.GetResolutionName(bound);
            bound.UnderlyingType      = underlyingType;

            if (typeInformation.IsGlobal)
            {
                bound.TypeKind |= Enums.E01D.Runtimic.Infrastructure.Metadata.Members.Typal.TypeKind.Global;
            }
        }
コード例 #4
0
 private void OutputTypeDefinition(BoundTypeDefinition node, string prefix)
 {
     builder.AddFragment(new OutputFragment(prefix, DefaultColour));
     builder.AddFragment(new OutputFragment(node.ValueType.Name, TypeColour));
 }