Example #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++;
                    }
                }
            }
        }
Example #2
0
File: Method.cs Project: 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++;
                    }
                }
            }
        }
Example #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));
                    }
                }
            }
        }
Example #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));
                }
            }
        }
Example #5
0
        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);
                }
            }
        }
 public TypeParameterConstraints(Context cx, TypeParameter parent)
     : base(cx, parent.Symbol)
 {
     this.parent = parent;
 }
 public static TypeParameterConstraints Create(Context cx, TypeParameter p) =>
 TypeParameterConstraintsFactory.Instance.CreateEntity(cx, (typeof(TypeParameterConstraints), p), p);