internal SourceMemberFieldSymbolFromDeclarator( SourceMemberContainerTypeSymbol containingType, VariableDeclaratorSyntax declarator, DeclarationModifiers modifiers, bool modifierErrors, BindingDiagnosticBag diagnostics) : base(containingType, modifiers, declarator.Identifier.ValueText, declarator.GetReference(), declarator.Identifier.GetLocation()) { _hasInitializer = declarator.Initializer != null; this.CheckAccessibility(diagnostics); if (!modifierErrors) { this.ReportModifiersDiagnostics(diagnostics); } if (containingType.IsInterface) { if (this.IsStatic) { Binder.CheckFeatureAvailability(declarator, MessageID.IDS_DefaultInterfaceImplementation, diagnostics, ErrorLocation); if (!ContainingAssembly.RuntimeSupportsDefaultInterfaceImplementation) { diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportDefaultInterfaceImplementation, ErrorLocation); } } else { diagnostics.Add(ErrorCode.ERR_InterfacesCantContainFields, ErrorLocation); } } }
internal SourceMemberFieldSymbol( SourceMemberContainerTypeSymbol containingType, VariableDeclaratorSyntax declarator, DeclarationModifiers modifiers, bool modifierErrors, DiagnosticBag diagnostics) : base(containingType, declarator.Identifier.ValueText, declarator.GetReference(), declarator.Identifier.GetLocation()) { this.modifiers = modifiers; this.CheckAccessibility(diagnostics); var location = Location; if (modifierErrors) { // skip the following checks } else if (containingType.IsSealed && (DeclaredAccessibility == Accessibility.Protected || DeclaredAccessibility == Accessibility.ProtectedOrInternal)) { diagnostics.Add(AccessCheck.GetProtectedMemberInSealedTypeError(containingType), location, this); } else if (IsVolatile && IsReadOnly) { diagnostics.Add(ErrorCode.ERR_VolatileAndReadonly, location, this); } else if (containingType.IsStatic && !IsStatic) { diagnostics.Add(ErrorCode.ERR_InstanceMemberInStaticClass, location, this); } // TODO: Consider checking presence of core type System.Runtime.CompilerServices.IsVolatile // if there is a volatile modifier. Perhaps an appropriate error should be reported if the // type isn’t available. }
internal SourceMemberFieldSymbolFromDeclarator( SourceMemberContainerTypeSymbol containingType, VariableDeclaratorSyntax declarator, DeclarationModifiers modifiers, bool modifierErrors, DiagnosticBag diagnostics) : base(containingType, modifiers, declarator.Identifier.ValueText, declarator.GetReference(), declarator.Identifier.GetLocation()) { _hasInitializer = declarator.Initializer != null; this.CheckAccessibility(diagnostics); if (!modifierErrors) { this.ReportModifiersDiagnostics(diagnostics); } }
internal SourceMemberFieldSymbol( SourceMemberContainerTypeSymbol containingType, VariableDeclaratorSyntax declarator, DeclarationModifiers modifiers, bool modifierErrors, DiagnosticBag diagnostics) : base(containingType, declarator.Identifier.ValueText, declarator.GetReference(), declarator.Identifier.GetLocation()) { _modifiers = modifiers; _hasInitializer = declarator.Initializer != null; this.CheckAccessibility(diagnostics); if (!modifierErrors) { this.ReportModifiersDiagnostics(diagnostics); } }
public override Evaluation VisitVariableDeclarator(VariableDeclaratorSyntax node) { node.ArgumentList?.Accept <Evaluation>(this); Evaluation eval = node.Initializer?.Accept <Evaluation>(this); Frame frame = _callStack.Peek(); if (eval is Instance inst) { ISymbol s = node.GetReference().GetDeclaringSymbol(_comp); inst.Identities.Push(new Identity(s, NodeKind.LocalVariable, frame, node.Identifier.ValueText)); } else { ISymbol declaringSymbol = ((VariableDeclarationSyntax)node.Parent).Type.GetReference().GetDeclaringSymbol(_comp); // eval = frame.CreateInstance(node.GetReference(), _comp, node.Identifier.ValueText); } return(eval); }