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++; } } } }
protected void PopulateNullability(TextWriter trapFile, AnnotatedTypeSymbol type) { var n = NullabilityEntity.Create(Context, Nullability.Create(type)); if (!type.HasObliviousNullability()) { trapFile.type_nullability(this, n); } }
public override void Populate(TextWriter trapFile) { trapFile.type_parameter_constraints(this, parent); if (Symbol.HasReferenceTypeConstraint) { trapFile.general_type_parameter_constraints(this, 1); } if (Symbol.HasValueTypeConstraint) { trapFile.general_type_parameter_constraints(this, 2); } if (Symbol.HasConstructorConstraint) { trapFile.general_type_parameter_constraints(this, 3); } if (Symbol.HasUnmanagedTypeConstraint) { trapFile.general_type_parameter_constraints(this, 4); } if (Symbol.ReferenceTypeConstraintNullableAnnotation == NullableAnnotation.Annotated) { trapFile.general_type_parameter_constraints(this, 5); } foreach (var abase in Symbol.GetAnnotatedTypeConstraints()) { var t = Type.Create(Context, abase.Symbol); trapFile.specific_type_parameter_constraints(this, t.TypeRef); if (!abase.HasObliviousNullability()) { trapFile.specific_type_parameter_nullability(this, t.TypeRef, NullabilityEntity.Create(Context, Nullability.Create(abase))); } } }
protected sealed override void Populate(TextWriter trapFile) { trapFile.expressions(this, Kind, Type.Type.TypeRef); if (info.Parent.IsTopLevelParent) { trapFile.expr_parent_top_level(this, info.Child, info.Parent); } else { trapFile.expr_parent(this, info.Child, info.Parent); } trapFile.expr_location(this, Location); var annotatedType = Type.Symbol; if (!annotatedType.HasObliviousNullability()) { var n = NullabilityEntity.Create(cx, Nullability.Create(annotatedType)); trapFile.type_nullability(this, n); } if (info.FlowState != NullableFlowState.None) { trapFile.expr_flowstate(this, (int)info.FlowState); } if (info.IsCompilerGenerated) { trapFile.expr_compiler_generated(this); } if (info.ExprValue is string value) { trapFile.expr_value(this, value); } Type.Type.PopulateGenerics(); }
public override void Populate(TextWriter trapFile) { var constraints = new TypeParameterConstraints(Context); trapFile.type_parameter_constraints(constraints, this); if (Symbol.HasReferenceTypeConstraint) { trapFile.general_type_parameter_constraints(constraints, 1); } if (Symbol.HasValueTypeConstraint) { trapFile.general_type_parameter_constraints(constraints, 2); } if (Symbol.HasConstructorConstraint) { trapFile.general_type_parameter_constraints(constraints, 3); } if (Symbol.HasUnmanagedTypeConstraint) { trapFile.general_type_parameter_constraints(constraints, 4); } if (Symbol.ReferenceTypeConstraintNullableAnnotation == NullableAnnotation.Annotated) { trapFile.general_type_parameter_constraints(constraints, 5); } foreach (var abase in Symbol.GetAnnotatedTypeConstraints()) { var t = Create(Context, abase.Symbol); trapFile.specific_type_parameter_constraints(constraints, t.TypeRef); if (!abase.HasObliviousNullability()) { trapFile.specific_type_parameter_nullability(constraints, t.TypeRef, NullabilityEntity.Create(Context, Nullability.Create(abase))); } } trapFile.types(this, Kinds.TypeKind.TYPE_PARAMETER, Symbol.Name); var parentNs = Namespace.Create(Context, Symbol.TypeParameterKind == TypeParameterKind.Method ? Context.Compilation.GlobalNamespace : Symbol.ContainingNamespace); trapFile.parent_namespace(this, parentNs); foreach (var l in Symbol.Locations) { trapFile.type_location(this, Context.CreateLocation(l)); } if (IsSourceDeclaration) { var declSyntaxReferences = Symbol.DeclaringSyntaxReferences .Select(d => d.GetSyntax()) .Select(s => s.Parent) .Where(p => p is not null) .Select(p => p !.Parent) .ToArray(); var clauses = declSyntaxReferences.OfType <MethodDeclarationSyntax>().SelectMany(m => m.ConstraintClauses); clauses = clauses.Concat(declSyntaxReferences.OfType <ClassDeclarationSyntax>().SelectMany(c => c.ConstraintClauses)); clauses = clauses.Concat(declSyntaxReferences.OfType <InterfaceDeclarationSyntax>().SelectMany(c => c.ConstraintClauses)); clauses = clauses.Concat(declSyntaxReferences.OfType <StructDeclarationSyntax>().SelectMany(c => c.ConstraintClauses)); foreach (var clause in clauses.Where(c => c.Name.Identifier.Text == Symbol.Name)) { TypeMention.Create(Context, clause.Name, this, this); foreach (var constraint in clause.Constraints.OfType <TypeConstraintSyntax>()) { var ti = Context.GetModel(constraint).GetTypeInfo(constraint.Type); var target = Type.Create(Context, ti.Type); TypeMention.Create(Context, constraint.Type, this, target); } } } }