/// <summary>
 /// Constructs a new SynthesizedDefaultStructSymbol.
 /// </summary>
 /// <param name="name">
 /// The name of the default struct.
 /// </param>
 /// <param name="concept">
 /// The parent concept of the default struct.
 /// </param>
 public SynthesizedDefaultStructSymbol(string name, SourceNamedTypeSymbol concept)
     : base(
         name,
         that =>
         // We duplicate the type parameters of the concept itself,
         // as well as adding one for the calling witness, so the
         // default struct can call back into it.
         that.CreateTypeParameters(concept.Arity, true)
         .Add(
             new SynthesizedWitnessParameterSymbol(
                 // @t-mawind
                 //   need to make this not clash with any typar in
                 //   the parent scopes, hence generated name.
                 GeneratedNames.MakeAnonymousTypeParameterName("witness"),
                 Location.None,
                 concept.Arity,
                 that,
                 _ => ImmutableArray.Create((TypeSymbol)concept),
                 _ => TypeParameterConstraintKind.ValueType
                 )
             ),
         TypeMap.Empty
         )
 {
     _concept = concept;
     // We can't get the default members here: it'll cause an infinite
     // loop...
 }
예제 #2
0
 internal TypeParameterBuilder(SyntaxReference syntaxRef, SourceNamedTypeSymbol owner, Location location)
 {
     this.syntaxRef = syntaxRef;
     Debug.Assert(syntaxRef.GetSyntax().IsKind(SyntaxKind.TypeParameter));
     this.owner    = owner;
     this.location = location;
 }
 /// <summary>
 /// Constructs a new SynthesizedDefaultStructSymbol.
 /// </summary>
 /// <param name="name">
 /// The name of the default struct.
 /// </param>
 /// <param name="concept">
 /// The parent concept of the default struct.
 /// </param>
 public SynthesizedDefaultStructSymbol(string name, SourceNamedTypeSymbol concept)
     : base(
         name,
         concept,
         that =>
         // We add a type parameter for the calling witness, so the
         // default struct can call back into it.
         ImmutableArray <TypeParameterSymbol> .Empty
         .Add(
             new SynthesizedWitnessParameterSymbol(
                 // @t-mawind
                 //   need to make this not clash with any typar in
                 //   the parent scopes, hence generated name.
                 GeneratedNames.WitnessTypeParameterName(),
                 Location.None,
                 0,
                 that,
                 _ => ImmutableArray.Create((TypeSymbol)concept),
                 _ => TypeParameterConstraintKind.ValueType
                 )
             ),
         TypeMap.Empty
         )
 {
 }
 internal TypeParameterBuilder(SyntaxReference syntaxRef, SourceNamedTypeSymbol owner, Location location)
 {
     this.syntaxRef = syntaxRef;
     Debug.Assert(syntaxRef.GetSyntax().IsKind(SyntaxKind.TypeParameter));
     this.owner = owner;
     this.location = location;
 }
예제 #5
0
 public SynthesizedEnumValueFieldSymbol(SourceNamedTypeSymbol containingEnum)
     : base(
         containingEnum,
         WellKnownMemberNames.EnumBackingFieldName,
         isPublic: true,
         isReadOnly: false,
         isStatic: false
         )
 {
 }
예제 #6
0
 public SourceTypeParameterSymbol(
     SourceNamedTypeSymbol owner,
     string name,
     int ordinal,
     VarianceKind varianceKind,
     ImmutableArray <Location> locations,
     ImmutableArray <SyntaxReference> syntaxRefs
     ) : base(name, ordinal, locations, syntaxRefs)
 {
     _owner        = owner;
     _varianceKind = varianceKind;
 }
 public SynthesizedEnumValueFieldSymbol(SourceNamedTypeSymbol containingEnum)
     : base(containingEnum, WellKnownMemberNames.EnumBackingFieldName, isPublic: true, isReadOnly: false, isStatic: false)
 {
 }
        private static ImmutableArray<BoundInitializer> BindInitializersWithoutDiagnostics(SourceNamedTypeSymbol typeSymbol, ImmutableArray<ImmutableArray<FieldInitializer>> initializers)
        {
            DiagnosticBag diagnostics = DiagnosticBag.GetInstance();
            try
            {
                ConsList<Imports> unused;
                var boundInitializers = Compiler.BindFieldInitializers(
                    containingType: typeSymbol,
                    scriptCtor: null,
                    initializers: initializers,
                    diagnostics: diagnostics,
                    generateDebugInfo: false,
                    firstDebugImports: out unused);

                var filteredDiag = diagnostics.AsEnumerable();
                foreach (var diagnostic in filteredDiag)
                {
                    Console.WriteLine(diagnostic);
                }

                Assert.True(filteredDiag.IsEmpty());

                return boundInitializers;
            }
            finally
            {
                diagnostics.Free();
            }
        }
 public SourceTypeParameterSymbol(SourceNamedTypeSymbol owner, string name, int ordinal, VarianceKind varianceKind, NullabilityPreservationKind preservationKind, ImmutableArray<Location> locations, ImmutableArray<SyntaxReference> syntaxRefs)
     : base(name, ordinal, preservationKind, locations, syntaxRefs)
 {
     _owner = owner;
     _varianceKind = varianceKind;
 }
 /// <summary>
 /// Constructs a new SynthesizedInlineInstanceSymbol.
 /// </summary>
 /// <param name="name">
 /// The name of the inline instance struct.
 /// </param>
 /// <param name="parent">
 /// The symbol doing inline implementation of concepts.
 /// </param>
 public SynthesizedInlineInstanceSymbol(string name, SourceNamedTypeSymbol parent)
     : base(name, parent, _ => ImmutableArray <TypeParameterSymbol> .Empty, TypeMap.Empty)
 {
 }
예제 #11
0
 protected SynthesizedConceptHelperStructSymbol(string name, SourceNamedTypeSymbol parent, Func <SynthesizedContainer, ImmutableArray <TypeParameterSymbol> > typeParametersF, TypeMap typeMap) : base(name, typeParametersF, typeMap)
 {
     _parent = parent;
 }
 public SourceTypeParameterSymbol(SourceNamedTypeSymbol owner, string name, int ordinal, VarianceKind varianceKind, ImmutableArray<Location> locations, ImmutableArray<SyntaxReference> syntaxRefs)
     : base(name, ordinal, locations, syntaxRefs)
 {
     this.owner = owner;
     this.varianceKind = varianceKind;
 }
예제 #13
0
 /// <summary>
 /// Constructs a new SynthesizedWitnessParameterSymbol.
 /// </summary>
 /// <param name="name">
 /// The name of the type parameter.
 /// </param>
 /// <param name="clauseLocation">
 /// The location of the clause creating this witness.
 /// </param>
 /// <param name="ordinal">
 /// The ordinal of the type parameter.
 /// </param>
 /// <param name="owner">
 /// The symbol containing this type parameter.
 /// </param>
 internal SynthesizedWitnessParameterSymbol(string name, Location clauseLocation, int ordinal, SourceNamedTypeSymbol owner)
     : this(name, clauseLocation, ordinal, owner, owner.GetTypeParameterConstraintTypes, owner.GetTypeParameterConstraints)
 {
 }
        private static ImmutableArray<BoundInitializer> BindInitializersWithoutDiagnostics(SourceNamedTypeSymbol typeSymbol, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers)
        {
            DiagnosticBag diagnostics = DiagnosticBag.GetInstance();
            try
            {
                ImportChain unused;
                var boundInitializers = Binder.BindFieldInitializers(
                    containingType: typeSymbol,
                    scriptCtor: null,
                    initializers: initializers,
                    diagnostics: diagnostics,
                    firstImportChain: out unused);

                diagnostics.Verify();

                return boundInitializers;
            }
            finally
            {
                diagnostics.Free();
            }
        }
 private static ImmutableArray<BoundInitializer> BindInitializersWithoutDiagnostics(SourceNamedTypeSymbol typeSymbol, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers)
 {
     DiagnosticBag diagnostics = DiagnosticBag.GetInstance();
     ImportChain unused;
     var boundInitializers = ArrayBuilder<BoundInitializer>.GetInstance();
     Binder.BindRegularCSharpFieldInitializers(
         typeSymbol.DeclaringCompilation,
         initializers,
         boundInitializers,
         diagnostics,
         firstDebugImports: out unused);
     diagnostics.Verify();
     diagnostics.Free();
     return boundInitializers.ToImmutableAndFree();
 }