예제 #1
0
        protected void PopulateGenerics(TextWriter trapFile)
        {
            var isFullyConstructed = IsBoundGeneric;

            if (IsGeneric)
            {
                int child = 0;

                if (isFullyConstructed)
                {
                    trapFile.is_constructed(this);
                    trapFile.constructed_generic(this, Method.Create(Context, ConstructedFromSymbol));
                    foreach (var tp in symbol.GetAnnotatedTypeArguments())
                    {
                        trapFile.type_arguments(Type.Create(Context, tp.Symbol), child, this);
                        child++;
                    }

                    var nullability = new Nullability(symbol);
                    if (!nullability.IsOblivious)
                    {
                        trapFile.type_nullability(this, NullabilityEntity.Create(Context, nullability));
                    }
                }
                else
                {
                    trapFile.is_generic(this);
                    foreach (var typeParam in symbol.TypeParameters.Select(tp => TypeParameter.Create(Context, tp)))
                    {
                        trapFile.type_parameters(typeParam, child, this);
                        child++;
                    }
                }
            }
        }
예제 #2
0
파일: Method.cs 프로젝트: xcorail/ql
        protected void ExtractGenerics()
        {
            var isFullyConstructed = IsBoundGeneric;

            if (IsGeneric)
            {
                int child = 0;

                if (isFullyConstructed)
                {
                    Context.Emit(Tuples.is_constructed(this));
                    Context.Emit(Tuples.constructed_generic(this, Method.Create(Context, ConstructedFromSymbol)));
                    foreach (var tp in symbol.GetAnnotatedTypeArguments())
                    {
                        Context.Emit(Tuples.type_arguments(Type.Create(Context, tp.Symbol), child, this));
                        var ta = tp.Nullability.GetTypeAnnotation();
                        if (ta != Kinds.TypeAnnotation.None)
                        {
                            Context.Emit(Tuples.type_argument_annotation(this, child, ta));
                        }
                        child++;
                    }
                }
                else
                {
                    Context.Emit(Tuples.is_generic(this));
                    foreach (var typeParam in symbol.TypeParameters.Select(tp => TypeParameter.Create(Context, tp)))
                    {
                        Context.Emit(Tuples.type_parameters(typeParam, child, this));
                        child++;
                    }
                }
            }
        }
예제 #3
0
        protected void ExtractGenerics()
        {
            var isFullyConstructed = IsBoundGeneric;

            if (IsGeneric)
            {
                int child = 0;

                if (isFullyConstructed)
                {
                    Context.Emit(Tuples.is_constructed(this));
                    Context.Emit(Tuples.constructed_generic(this, Method.Create(Context, ConstructedFromSymbol)));
                    foreach (var tp in symbol.TypeArguments)
                    {
                        Context.Emit(Tuples.type_arguments(Type.Create(Context, tp), child++, this));
                    }
                }
                else
                {
                    Context.Emit(Tuples.is_generic(this));
                    foreach (var typeParam in symbol.TypeParameters.Select(tp => TypeParameter.Create(Context, tp)))
                    {
                        Context.Emit(Tuples.type_parameters(typeParam, child++, this));
                    }
                }
            }
        }
예제 #4
0
        public override void Populate()
        {
            if (symbol.TypeKind == TypeKind.Error)
            {
                Context.Extractor.MissingType(symbol.ToString());
                return;
            }

            Context.Emit(Tuples.typeref_type((NamedTypeRef)TypeRef, this));

            if (symbol.IsGenericType)
            {
                if (symbol.IsBoundNullable())
                {
                    // An instance of Nullable<T>
                    Context.Emit(Tuples.nullable_underlying_type(this, Create(Context, symbol.TypeArguments[0]).TypeRef));
                }
                else if (symbol.IsReallyUnbound())
                {
                    Context.Emit(Tuples.is_generic(this));

                    for (int i = 0; i < symbol.TypeParameters.Length; ++i)
                    {
                        TypeParameter.Create(Context, symbol.TypeParameters[i]);
                        var param         = symbol.TypeParameters[i];
                        var typeParameter = TypeParameter.Create(Context, param);
                        Context.Emit(Tuples.type_parameters(typeParameter, i, this));
                    }
                }
                else
                {
                    Context.Emit(Tuples.is_constructed(this));
                    Context.Emit(Tuples.constructed_generic(this, Type.Create(Context, symbol.ConstructedFrom).TypeRef));

                    for (int i = 0; i < symbol.TypeArguments.Length; ++i)
                    {
                        Context.Emit(Tuples.type_arguments(TypeArguments[i].TypeRef, i, this));
                    }
                }
            }

            ExtractType();

            if (symbol.EnumUnderlyingType != null)
            {
                Context.Emit(Tuples.enum_underlying_type(this, Type.Create(Context, symbol.EnumUnderlyingType).TypeRef));
            }

            // Class location
            if (!symbol.IsGenericType || symbol.IsReallyUnbound())
            {
                foreach (var l in Locations)
                {
                    Context.Emit(Tuples.type_location(this, l));
                }
            }
        }
예제 #5
0
파일: NamedType.cs 프로젝트: zlaski/ql
        public override void Populate(TextWriter trapFile)
        {
            if (symbol.TypeKind == TypeKind.Error)
            {
                Context.Extractor.MissingType(symbol.ToString());
                return;
            }

            trapFile.typeref_type((NamedTypeRef)TypeRef, this);

            if (symbol.IsGenericType)
            {
                if (symbol.IsBoundNullable())
                {
                    // An instance of Nullable<T>
                    trapFile.nullable_underlying_type(this, Create(Context, symbol.TypeArguments[0]).TypeRef);
                }
                else if (symbol.IsReallyUnbound())
                {
                    trapFile.is_generic(this);

                    for (int i = 0; i < symbol.TypeParameters.Length; ++i)
                    {
                        TypeParameter.Create(Context, symbol.TypeParameters[i]);
                        var param         = symbol.TypeParameters[i];
                        var typeParameter = TypeParameter.Create(Context, param);
                        trapFile.type_parameters(typeParameter, i, this);
                    }
                }
                else
                {
                    trapFile.is_constructed(this);
                    trapFile.constructed_generic(this, Type.Create(Context, symbol.ConstructedFrom).TypeRef);

                    for (int i = 0; i < symbol.TypeArguments.Length; ++i)
                    {
                        var ta = symbol.TypeArgumentsNullableAnnotations[i].GetTypeAnnotation();
                        if (ta != Kinds.TypeAnnotation.None)
                        {
                            trapFile.type_argument_annotation(this, i, ta);
                        }
                        trapFile.type_arguments(TypeArguments[i].TypeRef, i, this);
                    }
                }
            }

            PopulateType(trapFile);

            if (symbol.EnumUnderlyingType != null)
            {
                trapFile.enum_underlying_type(this, Type.Create(Context, symbol.EnumUnderlyingType).TypeRef);
            }

            // Class location
            if (!symbol.IsGenericType || symbol.IsReallyUnbound())
            {
                foreach (var l in Locations)
                {
                    trapFile.type_location(this, l);
                }
            }
        }
예제 #6
0
 public TypeParameterConstraints(Context cx, TypeParameter parent)
     : base(cx, parent.Symbol)
 {
     this.parent = parent;
 }
예제 #7
0
 public static TypeParameterConstraints Create(Context cx, TypeParameter p) =>
 TypeParameterConstraintsFactory.Instance.CreateEntity(cx, (typeof(TypeParameterConstraints), p), p);