internal FieldMemberBuilder(NamedTypeSymbol owner, Binder enclosing, FieldDeclarationSyntax declaration, TypeSymbol type, VariableDeclaratorSyntax declarator) : base(enclosing.Location(declarator) as SourceLocation, owner, enclosing) { this.owner = owner; this.declaration = declaration; this.declarator = declarator; this.Type = type; }
internal FieldMemberBuilder(NamedTypeSymbol owner, Binder enclosing, FieldDeclarationSyntax declaration, TypeSymbol type, VariableDeclaratorSyntax declarator) : base(enclosing.Location(declarator) as SourceLocation, owner, enclosing) { this.owner = owner; this.declaration = declaration; this.declarator = declarator; this.Type = type; }
protected DelegateMethodSymbol( SourceNamedTypeSymbol containingType, DelegateDeclarationSyntax syntax, MethodKind methodKind, DeclarationModifiers declarationModifiers, Binder binder, DiagnosticBag diagnostics) : base(containingType, binder.GetSyntaxReference(syntax), blockSyntaxReference: null, location: binder.Location(syntax.Identifier)) { this.parameters = MakeParameters(binder, syntax, diagnostics); this.returnType = MakeReturnType(binder, syntax, diagnostics); this.flags = MakeFlags(methodKind, declarationModifiers, this.returnType.SpecialType == SpecialType.System_Void, isExtensionMethod: false); var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers); if (info != null) { diagnostics.Add(info, this.locations[0]); } }
protected DelegateMethodSymbol( SourceNamedTypeSymbol containingType, string name, DelegateDeclarationSyntax syntax, MethodKind methodKind, DeclarationModifiers declarationModifiers, Binder binder, DiagnosticBag diagnostics, CancellationToken cancellationToken) : base(containingType, name, binder.GetSyntaxReference(syntax), blockSyntax: null, location: binder.Location(syntax.Identifier)) { var location = this.locations[0]; bool isExtensionMethod; this.parameters = MakeParameters(binder, syntax, out isExtensionMethod, out this.isVararg, diagnostics, cancellationToken); this.returnType = MakeReturnType(binder, syntax, diagnostics); this.flags = MakeFlags(methodKind, declarationModifiers, IsVoidType(this.returnType), isExtensionMethod: isExtensionMethod); var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers); if (info != null) { diagnostics.Add(info, location); } }
private MethodMemberBuilder(NamedTypeSymbol container, Binder enclosing, MemberDeclarationSyntax syntax, DiagnosticBag diagnostics) : base(enclosing.Location(syntax) as SourceLocation, container, enclosing) { Debug.Assert(syntax != null); this.syntax = syntax; // Make a binder context in which each type parameter binds to a corresponding numbered type parameter Binder parametersContext = Enclosing; if (syntax.Kind == SyntaxKind.MethodDeclaration) { var methodSyntax = syntax as MethodDeclarationSyntax; int arity = methodSyntax.Arity; if (arity != 0) { var typeParamMap = new MultiDictionary<string, TypeParameterSymbol>(); var typeParams = methodSyntax.TypeParameterListOpt.Parameters; for (int iParam = 0; iParam < typeParams.Count; iParam++) { var arg = typeParams[iParam]; var symbol = IndexedTypeParameterSymbol.GetTypeParameter(iParam); typeParamMap.Add(arg.Identifier.ValueText, symbol); } parametersContext = new WithDummyTypeParametersBinder(typeParamMap, Enclosing); } if (methodSyntax.ExplicitInterfaceSpecifierOpt != null) { this.explicitInterfaceType = enclosing.BindType(methodSyntax.ExplicitInterfaceSpecifierOpt.Name, diagnostics); } } // TODOngafter 1: recast this code using ReadOnlyArray. IEnumerable<ParameterSyntax> parameters = SyntaxParameters.HasValue ? SyntaxParameters.Value : SpecializedCollections.EmptyEnumerable<ParameterSyntax>(); declaredParameterTypes = parameters.Select(p => { if (p.TypeOpt == null) return new CSErrorTypeSymbol(enclosing.Compilation.GlobalNamespace, "ErrorType", 0, diagnostics.Add(ErrorCode.ERR_NotYetImplementedInRoslyn, new SourceLocation(Tree, p))); return parametersContext.BindType(p.TypeOpt, diagnostics); }).ToList(); var parameterRefs = parameters.Select(p => p.Modifiers.GetRefKind()).ToList(); switch (syntax.Kind) { case SyntaxKind.ConstructorDeclaration: Binder original = parametersContext; // TODOngafter 1: worry about diagnostic reporting and suppression here. declaredReturnType = Enclosing.GetSpecialType(SpecialType.System_Void, diagnostics, syntax); break; default: declaredReturnType = parametersContext.BindType(SyntaxReturnType, diagnostics); break; } TypeSymbol explType = null; var explSyntax = ExplicitInterface; if (explSyntax != null) { explType = parametersContext.BindType(explSyntax, diagnostics); } // TODOngafter 3: map dynamic->object for the signature this.signature = new MethodSignature(Name, SyntaxArity, declaredParameterTypes, parameterRefs, explType); }
protected DelegateMethodSymbol( SourceNamedTypeSymbol containingType, DelegateDeclarationSyntax syntax, MethodKind methodKind, DeclarationModifiers declarationModifiers, Binder binder, DiagnosticBag diagnostics) : base(containingType, binder.GetSyntaxReference(syntax), blockSyntaxReference: null, location: binder.Location(syntax.Identifier)) { this.parameters = MakeParameters(binder, syntax, diagnostics); this.returnType = MakeReturnType(binder, syntax, diagnostics); this.flags = MakeFlags(methodKind, declarationModifiers, this.returnType.SpecialType == SpecialType.System_Void, isExtensionMethod: false); var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers); if (info != null) { diagnostics.Add(info, this.locations[0]); } }
internal SourceLocation Location(SyntaxNode node) { return(enclosing.Location(node) as SourceLocation); }
protected DelegateMethodSymbol( SourceNamedTypeSymbol containingType, string name, DelegateDeclarationSyntax syntax, MethodKind methodKind, DeclarationModifiers declarationModifiers, Binder binder, DiagnosticBag diagnostics, CancellationToken cancellationToken) : base(containingType, name, binder.GetSyntaxReference(syntax), blockSyntax: null, location: binder.Location(syntax.Identifier)) { var location = this.locations[0]; bool isExtensionMethod; this.parameters = MakeParameters(binder, syntax, out isExtensionMethod, out this.isVararg, diagnostics, cancellationToken); this.returnType = MakeReturnType(binder, syntax, diagnostics); this.flags = MakeFlags(methodKind, declarationModifiers, IsVoidType(this.returnType), isExtensionMethod: isExtensionMethod); var info = ModifierUtils.CheckAccessibility(this.DeclarationModifiers); if (info != null) { diagnostics.Add(info, location); } }
private MethodMemberBuilder(NamedTypeSymbol container, Binder enclosing, MemberDeclarationSyntax syntax, DiagnosticBag diagnostics) : base(enclosing.Location(syntax) as SourceLocation, container, enclosing) { Debug.Assert(syntax != null); this.syntax = syntax; // Make a binder context in which each type parameter binds to a corresponding numbered type parameter Binder parametersContext = Enclosing; if (syntax.Kind == SyntaxKind.MethodDeclaration) { var methodSyntax = syntax as MethodDeclarationSyntax; int arity = methodSyntax.Arity; if (arity != 0) { var typeParamMap = new MultiDictionary <string, TypeParameterSymbol>(); var typeParams = methodSyntax.TypeParameterListOpt.Parameters; for (int iParam = 0; iParam < typeParams.Count; iParam++) { var arg = typeParams[iParam]; var symbol = IndexedTypeParameterSymbol.GetTypeParameter(iParam); typeParamMap.Add(arg.Identifier.ValueText, symbol); } parametersContext = new WithDummyTypeParametersBinder(typeParamMap, Enclosing); } if (methodSyntax.ExplicitInterfaceSpecifierOpt != null) { this.explicitInterfaceType = enclosing.BindType(methodSyntax.ExplicitInterfaceSpecifierOpt.Name, diagnostics); } } // TODOngafter 1: recast this code using ReadOnlyArray. IEnumerable <ParameterSyntax> parameters = SyntaxParameters.HasValue ? SyntaxParameters.Value : SpecializedCollections.EmptyEnumerable <ParameterSyntax>(); declaredParameterTypes = parameters.Select(p => { if (p.TypeOpt == null) { return(new CSErrorTypeSymbol(enclosing.Compilation.GlobalNamespace, "ErrorType", 0, diagnostics.Add(ErrorCode.ERR_NotYetImplementedInRoslyn, new SourceLocation(Tree, p)))); } return(parametersContext.BindType(p.TypeOpt, diagnostics)); }).ToList(); var parameterRefs = parameters.Select(p => p.Modifiers.GetRefKind()).ToList(); switch (syntax.Kind) { case SyntaxKind.ConstructorDeclaration: Binder original = parametersContext; // TODOngafter 1: worry about diagnostic reporting and suppression here. declaredReturnType = Enclosing.GetSpecialType(SpecialType.System_Void, diagnostics, syntax); break; default: declaredReturnType = parametersContext.BindType(SyntaxReturnType, diagnostics); break; } TypeSymbol explType = null; var explSyntax = ExplicitInterface; if (explSyntax != null) { explType = parametersContext.BindType(explSyntax, diagnostics); } // TODOngafter 3: map dynamic->object for the signature this.signature = new MethodSignature(Name, SyntaxArity, declaredParameterTypes, parameterRefs, explType); }