diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs index 7fb2d5caf6..f38756188a 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs @@ -420,7 +420,7 @@ namespace ICSharpCode.NRefactory.CSharp } } - AddConstraints (newType, c); + AddConstraints (newType, c.CurrentTypeParameters); if (location != null && curLoc < location.Count) newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace); typeStack.Push (newType); @@ -466,7 +466,7 @@ namespace ICSharpCode.NRefactory.CSharp } } - AddConstraints (newType, s); + AddConstraints (newType, s.CurrentTypeParameters); if (location != null && curLoc < location.Count) newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace); typeStack.Push (newType); @@ -511,7 +511,7 @@ namespace ICSharpCode.NRefactory.CSharp } } - AddConstraints (newType, i); + AddConstraints (newType, i.CurrentTypeParameters); if (location != null && curLoc < location.Count) newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace); typeStack.Push (newType); @@ -548,7 +548,7 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) { newDelegate.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DelegateDeclaration.Roles.RPar); } - AddConstraints (newDelegate, d); + AddConstraints (newDelegate, d.CurrentTypeParameters); if (location != null) { newDelegate.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DelegateDeclaration.Roles.Semicolon); } @@ -643,7 +643,7 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newField, location); if (location != null) newField.AddChild (new CSharpTokenNode (Convert (location [0]), "fixed".Length), FixedFieldDeclaration.Roles.Keyword); - newField.AddChild (ConvertToType (f.TypeName), FixedFieldDeclaration.Roles.Type); + newField.AddChild (ConvertToType (f.TypeExpression), FixedFieldDeclaration.Roles.Type); var variable = new FixedVariableInitializer (); variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier); @@ -690,7 +690,7 @@ namespace ICSharpCode.NRefactory.CSharp FieldDeclaration newField = new FieldDeclaration (); AddAttributeSection (newField, f); AddModifiers (newField, location); - newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type); + newField.AddChild (ConvertToType (f.TypeExpression), FieldDeclaration.Roles.Type); VariableInitializer variable = new VariableInitializer (); variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier); @@ -732,7 +732,7 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers (newField, location); if (location != null) newField.AddChild (new CSharpModifierToken (Convert (location [0]), Modifiers.Const), AttributedNode.ModifierRole); - newField.AddChild (ConvertToType (f.TypeName), FieldDeclaration.Roles.Type); + newField.AddChild (ConvertToType (f.TypeExpression), FieldDeclaration.Roles.Type); VariableInitializer variable = new VariableInitializer (); variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), VariableInitializer.Roles.Identifier); @@ -780,15 +780,15 @@ namespace ICSharpCode.NRefactory.CSharp newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "implicit".Length), OperatorDeclaration.OperatorTypeRole); newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); } - newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type); + newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type); } else if (o.OperatorType == Operator.OpType.Explicit) { if (location != null) { newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "explicit".Length), OperatorDeclaration.OperatorTypeRole); newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); } - newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type); + newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type); } else { - newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type); + newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type); if (location != null) newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); @@ -834,7 +834,7 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newIndexer, indexer); var location = LocationsBag.GetMemberLocation (indexer); AddModifiers (newIndexer, location); - newIndexer.AddChild (ConvertToType (indexer.TypeName), IndexerDeclaration.Roles.Type); + newIndexer.AddChild (ConvertToType (indexer.TypeExpression), IndexerDeclaration.Roles.Type); AddExplicitInterface (newIndexer, indexer.MemberName); var name = indexer.MemberName; newIndexer.AddChild (Identifier.Create ("this", Convert (name.Location)), IndexerDeclaration.Roles.Identifier); @@ -895,7 +895,7 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newMethod, m); var location = LocationsBag.GetMemberLocation (m); AddModifiers (newMethod, location); - newMethod.AddChild (ConvertToType (m.TypeName), AstNode.Roles.Type); + newMethod.AddChild (ConvertToType (m.TypeExpression), AstNode.Roles.Type); AddExplicitInterface (newMethod, m.MethodName); newMethod.AddChild (Identifier.Create (m.MethodName.Name, Convert (m.Location)), AstNode.Roles.Identifier); @@ -908,7 +908,7 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) newMethod.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RPar); - AddConstraints (newMethod, m.GenericMethod); + AddConstraints (newMethod, m.CurrentTypeParameters); if (m.Block != null) { var bodyBlock = (BlockStatement)m.Block.Accept (this); @@ -991,7 +991,7 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newProperty, p); var location = LocationsBag.GetMemberLocation (p); AddModifiers (newProperty, location); - newProperty.AddChild (ConvertToType (p.TypeName), AstNode.Roles.Type); + newProperty.AddChild (ConvertToType (p.TypeExpression), AstNode.Roles.Type); AddExplicitInterface (newProperty, p.MemberName); newProperty.AddChild (Identifier.Create (p.MemberName.Name, Convert (p.Location)), PropertyDeclaration.Roles.Identifier); @@ -1121,7 +1121,7 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), EventDeclaration.Roles.Keyword); - newEvent.AddChild (ConvertToType (e.TypeName), AstNode.Roles.Type); + newEvent.AddChild (ConvertToType (e.TypeExpression), AstNode.Roles.Type); VariableInitializer variable = new VariableInitializer (); variable.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), FieldDeclaration.Roles.Identifier); @@ -1176,7 +1176,7 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), CustomEventDeclaration.Roles.Keyword); - newEvent.AddChild (ConvertToType (ep.TypeName), CustomEventDeclaration.Roles.Type); + newEvent.AddChild (ConvertToType (ep.TypeExpression), CustomEventDeclaration.Roles.Type); AddExplicitInterface (newEvent, ep.MemberName); @@ -2249,7 +2249,7 @@ namespace ICSharpCode.NRefactory.CSharp result.Operator = BinaryOperatorType.NullCoalescing; result.AddChild ((Expression)nullCoalescingOperator.LeftExpression.Accept (this), BinaryOperatorExpression.LeftRole); result.AddChild (new CSharpTokenNode (Convert (nullCoalescingOperator.Location), 2), BinaryOperatorExpression.OperatorRole); - result.AddChild ((Expression)nullCoalescingOperator.Right.Accept (this), BinaryOperatorExpression.RightRole); + result.AddChild ((Expression)nullCoalescingOperator.RightExpression.Accept (this), BinaryOperatorExpression.RightRole); return result; } @@ -2416,12 +2416,17 @@ namespace ICSharpCode.NRefactory.CSharp parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron); } - void AddConstraints (AstNode parent, DeclSpace d) + void AddConstraints (AstNode parent, TypeParameters d) { - if (d == null || d.Constraints == null) + if (d == null) return; - for (int i = 0; i < d.PlainConstraints.Count; i++) { - Constraints c = d.PlainConstraints [i]; + for (int i = d.Count - 1; i >= 0; i--) { + var typeParameter = d[i]; + if (typeParameter == null) + continue; + var c = typeParameter.Constraints; + if (c == null) + continue; var location = LocationsBag.GetLocations (c); var constraint = new Constraint (); constraint.AddChild (new CSharpTokenNode (Convert (c.Location), "where".Length), InvocationExpression.Roles.Keyword); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs index 12228c7436..a5843ef6ec 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs @@ -39,7 +39,7 @@ namespace Mono.CSharp { protected static MemberName MakeMemberName (MemberBase host, string name, int unique_id, TypeParameters tparams, Location loc) { - string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.Name; + string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.MemberName.Name; string tname = MakeName (host_name, "c", name, unique_id); TypeParameters args = null; if (tparams != null) { @@ -95,7 +95,7 @@ namespace Mono.CSharp { var dst = new TypeParameterSpec[tparams.Count]; for (int i = 0; i < tparams.Count; ++i) { - type_params[i] = tparams[i].CreateHoistedCopy (this, spec); + type_params[i] = tparams[i].CreateHoistedCopy (spec); src[i] = tparams[i].Type; dst[i] = type_params[i].Type; @@ -127,7 +127,7 @@ namespace Mono.CSharp { public HoistedStoreyClass GetGenericStorey () { - DeclSpace storey = this; + TypeContainer storey = this; while (storey != null && storey.CurrentTypeParameters == null) storey = storey.Parent; @@ -231,7 +231,7 @@ namespace Mono.CSharp { CheckMembersDefined (); FullNamedExpression field_type = new TypeExpression (type, Location); - if (!IsGeneric) + if (!spec.IsGenericOrParentIsGeneric) return AddCompilerGeneratedField (name, field_type); const Modifiers mod = Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED; @@ -718,7 +718,7 @@ namespace Mono.CSharp { } if (inner_access == null) { - if (field.Parent.IsGeneric) { + if (field.Parent.IsGenericOrParentIsGeneric) { var fs = MemberCache.GetMember (field.Parent.CurrentType, field.Spec); inner_access = new FieldExpr (fs, field.Location); } else { @@ -1326,11 +1326,11 @@ namespace Mono.CSharp { public readonly AnonymousMethodStorey Storey; readonly string RealName; - public AnonymousMethodMethod (DeclSpace parent, AnonymousExpression am, AnonymousMethodStorey storey, - GenericMethod generic, TypeExpr return_type, + public AnonymousMethodMethod (TypeContainer parent, AnonymousExpression am, AnonymousMethodStorey storey, + TypeExpr return_type, Modifiers mod, string real_name, MemberName name, ParametersCompiled parameters) - : base (parent, generic, return_type, mod | Modifiers.COMPILER_GENERATED, + : base (parent, return_type, mod | Modifiers.COMPILER_GENERATED, name, parameters, null) { this.AnonymousMethod = am; @@ -1590,22 +1590,17 @@ namespace Mono.CSharp { "m", null, unique_id++); MemberName member_name; - GenericMethod generic_method; if (storey == null && ec.CurrentTypeParameters != null) { var hoisted_tparams = ec.CurrentTypeParameters; var type_params = new TypeParameters (hoisted_tparams.Count); for (int i = 0; i < hoisted_tparams.Count; ++i) { - type_params.Add (hoisted_tparams[i].CreateHoistedCopy (parent, null)); + type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null)); } member_name = new MemberName (name, type_params, Location); - - generic_method = new GenericMethod (parent.NamespaceEntry, parent, member_name, //type_params, - new TypeExpression (ReturnType, Location), parameters); } else { member_name = new MemberName (name, Location); - generic_method = null; } string real_name = String.Format ( @@ -1613,7 +1608,7 @@ namespace Mono.CSharp { parameters.GetSignatureForError ()); return new AnonymousMethodMethod (parent, - this, storey, generic_method, new TypeExpression (ReturnType, Location), modifiers, + this, storey, new TypeExpression (ReturnType, Location), modifiers, real_name, member_name, parameters); } @@ -1825,9 +1820,6 @@ namespace Mono.CSharp { AnonymousTypeClass a_type = new AnonymousTypeClass (parent.NamespaceEntry.SlaveDeclSpace, new MemberName (name, tparams, loc), parameters, loc); - if (parameters.Count > 0) - a_type.SetParameterInfo (null); - Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, null, all_parameters, loc); c.Block = new ToplevelBlock (parent.Module.Compiler, c.ParameterInfo, loc); @@ -1903,13 +1895,13 @@ namespace Mono.CSharp { var equals_parameters = ParametersCompiled.CreateFullyResolved ( new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc), Compiler.BuiltinTypes.Object); - Method equals = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Bool, loc), + Method equals = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc), equals_parameters, null); equals_parameters[0].Resolve (equals, 0); - Method tostring = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.String, loc), + Method tostring = new Method (this, new TypeExpression (Compiler.BuiltinTypes.String, loc), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc), Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null); @@ -2021,7 +2013,7 @@ namespace Mono.CSharp { // // GetHashCode () override // - Method hashcode = new Method (this, null, new TypeExpression (Compiler.BuiltinTypes.Int, loc), + Method hashcode = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Int, loc), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("GetHashCode", loc), Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs index 7a786da549..032a47f709 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs @@ -783,7 +783,7 @@ namespace Mono.CSharp class StackField : Field { - public StackField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name) + public StackField (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name) : base (parent, type, mod, name, null) { } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs index 6a8eb55921..84cb9ed673 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs @@ -45,7 +45,7 @@ namespace Mono.CSharp /// /// This is the base class for structs and classes. /// - public abstract class TypeContainer : DeclSpace, ITypeDefinition, ITypesContainer + public abstract class TypeContainer : MemberCore, ITypeDefinition, ITypesContainer { // // Different context is needed when resolving type container base @@ -180,6 +180,7 @@ namespace Mono.CSharp Dictionary hoisted_base_call_proxies; + protected Dictionary defined_names; Dictionary Cache = new Dictionary (); // @@ -211,7 +212,9 @@ namespace Mono.CSharp bool type_defined; TypeContainer InTransit; + public TypeContainer PartialContainer; + public TypeBuilder TypeBuilder; GenericTypeParameterBuilder[] all_tp_builders; // // All recursive type parameters put together sharing same @@ -219,6 +222,13 @@ namespace Mono.CSharp // TypeParameters all_type_parameters; + // + // This is the namespace in which this typecontainer + // was declared. We use this to resolve names. + // + public NamespaceContainer NamespaceEntry; + + public readonly string Basename; public const string DefaultIndexerName = "Item"; private bool seen_normal_indexers = false; @@ -235,21 +245,26 @@ namespace Mono.CSharp public int DynamicSitesCounter; + static readonly string[] attribute_targets = new string[] { "type" }; + /// /// The pending methods that need to be implemented // (interfaces or abstract methods) /// PendingImplementation pending; - public TypeContainer (NamespaceContainer ns, DeclSpace parent, MemberName name, - Attributes attrs, MemberKind kind) - : base (ns, parent, name, attrs) + public TypeContainer (NamespaceContainer ns, TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) + : base (parent, name, attrs) { if (parent != null && parent.NamespaceEntry != ns) throw new InternalErrorException ("A nested type should be in the same NamespaceEntry as its enclosing class"); this.Kind = kind; this.PartialContainer = this; + this.Basename = name.Basename; + this.NamespaceEntry = ns; + + defined_names = new Dictionary (); } List orderedAllMembers = new List (); @@ -270,7 +285,7 @@ namespace Mono.CSharp public override TypeSpec CurrentType { get { if (current_type == null) { - if (IsGeneric) { + if (IsGenericOrParentIsGeneric) { // // Switch to inflated version as it's used by all expressions // @@ -337,12 +352,58 @@ namespace Mono.CSharp } } + public bool IsGenericOrParentIsGeneric { + get { + return all_type_parameters != null; + } + } + + // + // root_types contains all the types. All TopLevel types + // hence have a parent that points to `root_types', that is + // why there is a non-obvious test down here. + // + public bool IsTopLevel { + get { + return Parent != null && Parent.Parent == null; + } + } + + string ITypeDefinition.Namespace { + get { + return NamespaceEntry.NS.MemberName.GetSignatureForError (); + } + } + public TypeParameters TypeParametersAll { get { return all_type_parameters; } } + public override string[] ValidAttributeTargets { + get { + return attribute_targets; + } + } + +#if FULL_AST + public bool HasOptionalSemicolon { + get; + private set; + } + Location optionalSemicolon; + public Location OptionalSemicolon { + get { + return optionalSemicolon; + } + set { + optionalSemicolon = value; + HasOptionalSemicolon = true; + } + } +#endif + #endregion public override void Accept (StructuralVisitor visitor) @@ -367,7 +428,7 @@ namespace Mono.CSharp protected virtual void RemoveMemberType (TypeContainer ds) { - RemoveFromContainer (ds.Basename); + defined_names.Remove (ds.Basename); } public void AddConstant (Const constant) @@ -381,12 +442,62 @@ namespace Mono.CSharp constants.Add (constant); } + // + // Adds the member to defined_names table. It tests for duplications and enclosing name conflicts + // + protected virtual bool AddToContainer (MemberCore symbol, string name) + { + MemberCore mc; + if (!defined_names.TryGetValue (name, out mc)) { + defined_names.Add (name, symbol); + return true; + } + + if (((mc.ModFlags | symbol.ModFlags) & Modifiers.COMPILER_GENERATED) != 0) + return true; + + if (symbol.EnableOverloadChecks (mc)) + return true; + + InterfaceMemberBase im = mc as InterfaceMemberBase; + if (im != null && im.IsExplicitImpl) + return true; + + Report.SymbolRelatedToPreviousError (mc); + if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (symbol is ClassOrStruct || symbol is Interface)) { + Error_MissingPartialModifier (symbol); + return false; + } + + if (symbol is TypeParameter) { + Report.Error (692, symbol.Location, + "Duplicate type parameter `{0}'", symbol.GetSignatureForError ()); + } else { + Report.Error (102, symbol.Location, + "The type `{0}' already contains a definition for `{1}'", + GetSignatureForError (), name); + } + + return false; + } + public TypeContainer AddTypeContainer (TypeContainer tc) { orderedAllMembers.Add (tc); if (!AddMemberType (tc)) return tc; + var tparams = tc.MemberName.TypeParameters; + if (tparams != null) { + for (int i = 0; i < tparams.Count; ++i) { + var tp = tparams[i]; + if (tp.MemberName == null) + continue; + + tc.AddMember (tp, tp.Name); + } + } + if (types == null) types = new List (); @@ -427,6 +538,26 @@ namespace Mono.CSharp next_part.GetSignatureForError ()); } + var tc_names = tc.CurrentTypeParameters; + if (tc_names != null) { + for (int i = 0; i < tc_names.Count; ++i) { + var tp = next_part.MemberName.TypeParameters[i]; + if (tc_names[i].MemberName.Name != tp.MemberName.Name) { + Report.SymbolRelatedToPreviousError (tc.Location, ""); + Report.Error (264, next_part.Location, "Partial declarations of `{0}' must have the same type parameter names in the same order", + next_part.GetSignatureForError ()); + break; + } + + if (tc_names[i].Variance != tp.Variance) { + Report.SymbolRelatedToPreviousError (tc.Location, ""); + Report.Error (1067, next_part.Location, "Partial declarations of `{0}' must have the same type parameter variance modifiers", + next_part.GetSignatureForError ()); + break; + } + } + } + if (tc.partial_parts == null) tc.partial_parts = new List (1); @@ -692,7 +823,7 @@ namespace Mono.CSharp } } - protected override TypeAttributes TypeAttr { + protected virtual TypeAttributes TypeAttr { get { return ModifiersExtensions.TypeAttr (ModFlags, IsTopLevel); } @@ -724,12 +855,6 @@ namespace Mono.CSharp } } - string ITypeDefinition.Namespace { - get { - return NamespaceEntry.NS.MemberName.GetSignatureForError (); - } - } - public virtual void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression) { if ((field.ModFlags & Modifiers.STATIC) != 0){ @@ -898,11 +1023,9 @@ namespace Mono.CSharp return a.GetAttributeUsageAttribute (); } - public virtual void AddBasesForPart (DeclSpace part, List bases) + public virtual void AddBasesForPart (TypeContainer part, List bases) { - // FIXME: get rid of partial_parts and store lists of bases of each part here - // assumed, not verified: 'part' is in 'partial_parts' - ((TypeContainer) part).type_bases = bases; + part.type_bases = bases; } /// @@ -980,6 +1103,19 @@ namespace Mono.CSharp return ifaces; } + // + // Returns the MemberCore associated with a given name in the declaration + // space. It doesn't return method based symbols !! + // + // TODO: protected or private + // + public MemberCore GetDefinition (string name) + { + MemberCore mc = null; + defined_names.TryGetValue (name, out mc); + return mc; + } + TypeSpec[] GetNormalPartialBases () { var ifaces = new List (0); @@ -1018,6 +1154,16 @@ namespace Mono.CSharp return ifaces.ToArray (); } + public override string GetSignatureForDocumentation () + { + return MemberName.GetName (true); + } + + public override string GetSignatureForError () + { + return MemberName.GetSignatureForError (); + } + // // Checks that some operators come in pairs: // == and != @@ -1097,7 +1243,7 @@ namespace Mono.CSharp int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null ? 1 : 0; if (IsTopLevel) { - TypeBuilder = Module.CreateBuilder (Name, TypeAttr, type_size); + TypeBuilder = Module.CreateBuilder (MemberName.GetName (true), TypeAttr, type_size); } else { TypeBuilder = Parent.TypeBuilder.DefineNestedType (Basename, TypeAttr, null, type_size); } @@ -1112,7 +1258,7 @@ namespace Mono.CSharp if (!IsTopLevel) Parent.MemberCache.AddMember (spec); - if (IsGeneric) { + if (MemberName.TypeParameters != null || Parent.IsGenericOrParentIsGeneric) { var tparam_names = CreateTypeParameters (); all_tp_builders = TypeBuilder.DefineGenericParameters (tparam_names); @@ -1204,7 +1350,6 @@ namespace Mono.CSharp cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve (); } - GenericMethod generic_method; MemberName member_name; TypeArguments targs = null; if (method.IsGeneric) { @@ -1218,22 +1363,19 @@ namespace Mono.CSharp targs.Arguments = new TypeSpec[hoisted_tparams.Length]; for (int i = 0; i < hoisted_tparams.Length; ++i) { var tp = hoisted_tparams[i]; - tparams.Add (new TypeParameter (tp, this, null, new MemberName (tp.Name, Location), null)); + tparams.Add (new TypeParameter (tp, null, new MemberName (tp.Name, Location), null)); targs.Add (new SimpleName (tp.Name, Location)); targs.Arguments[i] = tp; } member_name = new MemberName (name, tparams, Location); - generic_method = new GenericMethod (NamespaceEntry, this, member_name, - new TypeExpression (method.ReturnType, Location), cloned_params); } else { member_name = new MemberName (name); - generic_method = null; } // Compiler generated proxy - proxy_method = new Method (this, generic_method, new TypeExpression (method.ReturnType, Location), + proxy_method = new Method (this, new TypeExpression (method.ReturnType, Location), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN, member_name, cloned_params, null); @@ -1412,7 +1554,7 @@ namespace Mono.CSharp return true; } - public override void DefineType () + public void DefineType () { if (error) return; @@ -1441,32 +1583,6 @@ namespace Mono.CSharp } } - public override void SetParameterInfo (List constraints_list) - { - base.SetParameterInfo (constraints_list); - - if (PartialContainer.CurrentTypeParameters == null || PartialContainer == this) - return; - - var tc_names = PartialContainer.CurrentTypeParameters; - for (int i = 0; i < tc_names.Count; ++i) { - var tp = MemberName.TypeParameters[i]; - if (tc_names[i].MemberName.Name != tp.MemberName.Name) { - Report.SymbolRelatedToPreviousError (PartialContainer.Location, ""); - Report.Error (264, Location, "Partial declarations of `{0}' must have the same type parameter names in the same order", - GetSignatureForError ()); - break; - } - - if (tc_names[i].Variance != tp.Variance) { - Report.SymbolRelatedToPreviousError (PartialContainer.Location, ""); - Report.Error (1067, Location, "Partial declarations of `{0}' must have the same type parameter variance modifiers", - GetSignatureForError ()); - break; - } - } - } - // // Replaces normal spec with predefined one when compiling corlib // and this type container defines predefined type @@ -1667,7 +1783,7 @@ namespace Mono.CSharp if (obsolete_attr != null && !IsObsolete) AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), base_type_expr.Location, Report); - if (IsGeneric && base_type.IsAttribute) { + if (IsGenericOrParentIsGeneric && base_type.IsAttribute) { Report.Error (698, base_type_expr.Location, "A generic type cannot derive from `{0}' because it is an attribute class", base_type.GetSignatureForError ()); @@ -2078,6 +2194,13 @@ namespace Mono.CSharp } } + protected void Error_MissingPartialModifier (MemberCore type) + { + Report.Error (260, type.Location, + "Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists", + type.GetSignatureForError ()); + } + public virtual void CloseType () { if ((caching_flags & Flags.CloseTypeCreated) != 0) @@ -2279,6 +2402,11 @@ namespace Mono.CSharp return Module.DeclaringAssembly == assembly; } + public virtual bool IsUnmanagedType () + { + return false; + } + public void LoadMembers (TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) { throw new NotSupportedException ("Not supported for compiled definition " + GetSignatureForError ()); @@ -2401,8 +2529,7 @@ namespace Mono.CSharp { SecurityType declarative_security; - public ClassOrStruct (NamespaceContainer ns, DeclSpace parent, - MemberName name, Attributes attrs, MemberKind kind) + public ClassOrStruct (NamespaceContainer ns, TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) : base (ns, parent, name, attrs, kind) { } @@ -2527,8 +2654,7 @@ namespace Mono.CSharp public override ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity) { - DeclSpace top_level = Parent; - if (top_level != null) { + if (Parent != null) { var methods = NamespaceEntry.NS.LookupExtensionMethod (this, extensionType, name, arity); if (methods != null) { return new ExtensionMethodCandidates (methods, NamespaceEntry, NamespaceEntry.NS) { @@ -2566,8 +2692,7 @@ namespace Mono.CSharp public const TypeAttributes StaticClassAttribute = TypeAttributes.Abstract | TypeAttributes.Sealed; - public Class (NamespaceContainer ns, DeclSpace parent, MemberName name, Modifiers mod, - Attributes attrs) + public Class (NamespaceContainer ns, TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base (ns, parent, name, attrs, MemberKind.Class) { var accmods = (Parent == null || Parent.Parent == null) ? Modifiers.INTERNAL : Modifiers.PRIVATE; @@ -2580,9 +2705,10 @@ namespace Mono.CSharp visitor.Visit (this); } - public override void AddBasesForPart (DeclSpace part, List bases) + public override void AddBasesForPart (TypeContainer part, List bases) { - if (part.Name == "System.Object") + var pmn = part.MemberName; + if (pmn.Name == "Object" && pmn.Left != null && pmn.Left.Name == "System" && pmn.TypeParameters == null) Report.Error (537, part.Location, "The class System.Object cannot have a base class or implement an interface."); base.AddBasesForPart (part, bases); @@ -2800,8 +2926,7 @@ namespace Mono.CSharp Modifiers.UNSAFE | Modifiers.PRIVATE; - public Struct (NamespaceContainer ns, DeclSpace parent, MemberName name, - Modifiers mod, Attributes attrs) + public Struct (NamespaceContainer ns, TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base (ns, parent, name, attrs, MemberKind.Struct) { var accmods = parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE; @@ -2912,7 +3037,7 @@ namespace Mono.CSharp if (requires_delayed_unmanagedtype_check) return true; - if (Parent != null && Parent.IsGeneric) { + if (Parent != null && Parent.IsGenericOrParentIsGeneric) { has_unmanaged_check_done = true; return false; } @@ -2991,8 +3116,7 @@ namespace Mono.CSharp Modifiers.UNSAFE | Modifiers.PRIVATE; - public Interface (NamespaceContainer ns, DeclSpace parent, MemberName name, Modifiers mod, - Attributes attrs) + public Interface (NamespaceContainer ns, TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base (ns, parent, name, attrs, MemberKind.Interface) { var accmods = parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE; @@ -3122,11 +3246,8 @@ namespace Mono.CSharp readonly Modifiers explicit_mod_flags; public MethodAttributes flags; - public InterfaceMemberBase (DeclSpace parent, GenericMethod generic, - FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, - MemberName name, Attributes attrs) - : base (parent, generic, type, mod, allowed_mod, Modifiers.PRIVATE, - name, attrs) + public InterfaceMemberBase (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs) + : base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs) { IsInterface = parent.PartialContainer.Kind == MemberKind.Interface; IsExplicitImpl = (MemberName.ExplicitInterface != null); @@ -3523,18 +3644,6 @@ namespace Mono.CSharp return Parent.GetSignatureForDocumentation () + "." + ShortName; } - protected override bool VerifyClsCompliance () - { - if (!base.VerifyClsCompliance ()) { - return false; - } - - if (GenericMethod != null) - GenericMethod.VerifyClsCompliance (); - - return true; - } - public override bool IsUsed { get { return IsExplicitImpl || base.IsUsed; } @@ -3547,26 +3656,11 @@ namespace Mono.CSharp protected FullNamedExpression type_expr; protected TypeSpec member_type; - public readonly DeclSpace ds; - public readonly GenericMethod GenericMethod; - - public FullNamedExpression TypeName { - get { - return type_expr; - } - } - - protected MemberBase (DeclSpace parent, GenericMethod generic, - FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod, - MemberName name, Attributes attrs) + protected MemberBase (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod, MemberName name, Attributes attrs) : base (parent, name, attrs) { - this.ds = generic != null ? generic : (DeclSpace) parent; this.type_expr = type; ModFlags = ModifiersExtensions.Check (allowed_mod, mod, def_mod, Location, Report); - GenericMethod = generic; - if (GenericMethod != null) - GenericMethod.ModFlags = ModFlags; } #region Properties @@ -3679,7 +3773,7 @@ namespace Mono.CSharp public override string GetSignatureForDocumentation () { - return Parent.Name + "." + Name; + return Parent.GetSignatureForDocumentation () + "." + MemberName.Basename; } protected virtual bool ResolveMemberType () diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs index 0ff7bf81f8..9789bd9ad0 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs @@ -26,7 +26,7 @@ namespace Mono.CSharp { Modifiers.INTERNAL | Modifiers.PRIVATE; - public Const (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) + public Const (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base (parent, type, mod_flags, AllowedModifiers, name, attrs) { ModFlags |= Modifiers.STATIC; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs index 4891be04be..0b2b2eeea8 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs @@ -49,7 +49,7 @@ namespace Mono.CSharp NamespaceContainer current_namespace; TypeContainer current_container; - DeclSpace current_class; + TypeContainer current_class; PropertyBase current_property; EventProperty current_event; EventField current_event_field; @@ -1611,7 +1611,7 @@ case 99: case_99(); break; case 100: -#line 978 "cs-parser.jay" +#line 979 "cs-parser.jay" { Error_SyntaxError (yyToken); } @@ -1623,13 +1623,13 @@ case 102: case_102(); break; case 105: -#line 1019 "cs-parser.jay" +#line 1020 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 106: -#line 1023 "cs-parser.jay" +#line 1024 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1638,7 +1638,7 @@ case 107: case_107(); break; case 108: -#line 1039 "cs-parser.jay" +#line 1040 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1662,7 +1662,7 @@ case 116: case_116(); break; case 117: -#line 1118 "cs-parser.jay" +#line 1119 "cs-parser.jay" { report.Error (1641, GetLocation (yyVals[-1+yyTop]), "A fixed size buffer field must have the array size specifier after the field name"); } @@ -1674,13 +1674,13 @@ case 120: case_120(); break; case 123: -#line 1148 "cs-parser.jay" +#line 1149 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 124: -#line 1152 "cs-parser.jay" +#line 1153 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1689,7 +1689,7 @@ case 125: case_125(); break; case 126: -#line 1165 "cs-parser.jay" +#line 1166 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1698,13 +1698,13 @@ case 127: case_127(); break; case 130: -#line 1184 "cs-parser.jay" +#line 1185 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 131: -#line 1188 "cs-parser.jay" +#line 1189 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1713,7 +1713,7 @@ case 132: case_132(); break; case 133: -#line 1204 "cs-parser.jay" +#line 1205 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1734,13 +1734,13 @@ case 140: case_140(); break; case 141: -#line 1275 "cs-parser.jay" +#line 1276 "cs-parser.jay" { valid_param_mod = ParameterModifierType.All; } break; case 142: -#line 1279 "cs-parser.jay" +#line 1280 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1749,7 +1749,7 @@ case 143: case_143(); break; case 144: -#line 1313 "cs-parser.jay" +#line 1306 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -1758,7 +1758,7 @@ case 145: case_145(); break; case 146: -#line 1323 "cs-parser.jay" +#line 1316 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1770,11 +1770,11 @@ case 148: case_148(); break; case 150: -#line 1381 "cs-parser.jay" +#line 1364 "cs-parser.jay" { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } break; case 151: -#line 1385 "cs-parser.jay" +#line 1368 "cs-parser.jay" { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 153: @@ -1799,13 +1799,13 @@ case 159: case_159(); break; case 160: -#line 1457 "cs-parser.jay" +#line 1440 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } ); } break; case 161: -#line 1461 "cs-parser.jay" +#line 1444 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true); } @@ -1829,7 +1829,7 @@ case 167: case_167(); break; case 168: -#line 1536 "cs-parser.jay" +#line 1519 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1838,11 +1838,11 @@ case 169: case_169(); break; case 170: -#line 1577 "cs-parser.jay" +#line 1560 "cs-parser.jay" { yyVal = Parameter.Modifier.NONE; } break; case 172: -#line 1585 "cs-parser.jay" +#line 1568 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -1875,7 +1875,7 @@ case 181: case_181(); break; case 182: -#line 1678 "cs-parser.jay" +#line 1661 "cs-parser.jay" { Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); } @@ -1896,7 +1896,7 @@ case 187: case_187(); break; case 188: -#line 1732 "cs-parser.jay" +#line 1715 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; } @@ -1905,7 +1905,7 @@ case 189: case_189(); break; case 190: -#line 1761 "cs-parser.jay" +#line 1744 "cs-parser.jay" { lexer.PropertyParsing = false; } @@ -1935,7 +1935,7 @@ case 203: case_203(); break; case 204: -#line 1910 "cs-parser.jay" +#line 1893 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1953,55 +1953,55 @@ case 208: case_208(); break; case 209: -#line 1947 "cs-parser.jay" +#line 1931 "cs-parser.jay" { Error_SyntaxError (yyToken); } break; case 212: -#line 1959 "cs-parser.jay" +#line 1943 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; case 213: -#line 1963 "cs-parser.jay" +#line 1947 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; case 214: -#line 1970 "cs-parser.jay" +#line 1954 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; case 215: -#line 1974 "cs-parser.jay" +#line 1958 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; case 220: -#line 1982 "cs-parser.jay" +#line 1966 "cs-parser.jay" { report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators"); } break; case 221: -#line 1986 "cs-parser.jay" +#line 1970 "cs-parser.jay" { report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors"); } break; case 222: -#line 1990 "cs-parser.jay" +#line 1974 "cs-parser.jay" { report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations"); } break; case 223: -#line 1996 "cs-parser.jay" +#line 1980 "cs-parser.jay" { } break; @@ -2009,14 +2009,14 @@ case 224: case_224(); break; case 226: -#line 2029 "cs-parser.jay" +#line 2013 "cs-parser.jay" { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } break; case 228: case_228(); break; case 229: -#line 2045 "cs-parser.jay" +#line 2029 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2025,95 +2025,95 @@ case 230: case_230(); break; case 232: -#line 2091 "cs-parser.jay" +#line 2075 "cs-parser.jay" { yyVal = Operator.OpType.LogicalNot; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 233: -#line 2092 "cs-parser.jay" +#line 2076 "cs-parser.jay" { yyVal = Operator.OpType.OnesComplement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 234: -#line 2093 "cs-parser.jay" +#line 2077 "cs-parser.jay" { yyVal = Operator.OpType.Increment; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 235: -#line 2094 "cs-parser.jay" +#line 2078 "cs-parser.jay" { yyVal = Operator.OpType.Decrement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 236: -#line 2095 "cs-parser.jay" +#line 2079 "cs-parser.jay" { yyVal = Operator.OpType.True; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 237: -#line 2096 "cs-parser.jay" +#line 2080 "cs-parser.jay" { yyVal = Operator.OpType.False; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 238: -#line 2098 "cs-parser.jay" +#line 2082 "cs-parser.jay" { yyVal = Operator.OpType.Addition; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 239: -#line 2099 "cs-parser.jay" +#line 2083 "cs-parser.jay" { yyVal = Operator.OpType.Subtraction; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 240: -#line 2101 "cs-parser.jay" +#line 2085 "cs-parser.jay" { yyVal = Operator.OpType.Multiply; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 241: -#line 2102 "cs-parser.jay" +#line 2086 "cs-parser.jay" { yyVal = Operator.OpType.Division; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 242: -#line 2103 "cs-parser.jay" +#line 2087 "cs-parser.jay" { yyVal = Operator.OpType.Modulus; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 243: -#line 2104 "cs-parser.jay" +#line 2088 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseAnd; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 244: -#line 2105 "cs-parser.jay" +#line 2089 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 245: -#line 2106 "cs-parser.jay" +#line 2090 "cs-parser.jay" { yyVal = Operator.OpType.ExclusiveOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 246: -#line 2107 "cs-parser.jay" +#line 2091 "cs-parser.jay" { yyVal = Operator.OpType.LeftShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 247: -#line 2108 "cs-parser.jay" +#line 2092 "cs-parser.jay" { yyVal = Operator.OpType.RightShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 248: -#line 2109 "cs-parser.jay" +#line 2093 "cs-parser.jay" { yyVal = Operator.OpType.Equality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 249: -#line 2110 "cs-parser.jay" +#line 2094 "cs-parser.jay" { yyVal = Operator.OpType.Inequality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 250: -#line 2111 "cs-parser.jay" +#line 2095 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 251: -#line 2112 "cs-parser.jay" +#line 2096 "cs-parser.jay" { yyVal = Operator.OpType.LessThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 252: -#line 2113 "cs-parser.jay" +#line 2097 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 253: -#line 2114 "cs-parser.jay" +#line 2098 "cs-parser.jay" { yyVal = Operator.OpType.LessThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 254: -#line 2121 "cs-parser.jay" +#line 2105 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2122,7 +2122,7 @@ case 255: case_255(); break; case 256: -#line 2140 "cs-parser.jay" +#line 2124 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2149,11 +2149,11 @@ case 263: case_263(); break; case 265: -#line 2248 "cs-parser.jay" +#line 2230 "cs-parser.jay" { current_block = null; yyVal = null; } break; case 268: -#line 2260 "cs-parser.jay" +#line 2242 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2162,7 +2162,7 @@ case 269: case_269(); break; case 270: -#line 2270 "cs-parser.jay" +#line 2252 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2195,7 +2195,7 @@ case 279: case_279(); break; case 281: -#line 2379 "cs-parser.jay" +#line 2361 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2204,13 +2204,13 @@ case 282: case_282(); break; case 285: -#line 2396 "cs-parser.jay" +#line 2378 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 286: -#line 2400 "cs-parser.jay" +#line 2382 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -2219,7 +2219,7 @@ case 287: case_287(); break; case 288: -#line 2413 "cs-parser.jay" +#line 2395 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2231,7 +2231,7 @@ case 290: case_290(); break; case 291: -#line 2438 "cs-parser.jay" +#line 2420 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2279,7 +2279,7 @@ case 309: case_309(); break; case 312: -#line 2601 "cs-parser.jay" +#line 2583 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[0+yyTop])); } @@ -2297,7 +2297,7 @@ case 317: case_317(); break; case 318: -#line 2659 "cs-parser.jay" +#line 2641 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; } @@ -2306,7 +2306,7 @@ case 319: case_319(); break; case 320: -#line 2681 "cs-parser.jay" +#line 2663 "cs-parser.jay" { lexer.ConstraintsParsing = false; } @@ -2339,7 +2339,7 @@ case 333: case_333(); break; case 334: -#line 2786 "cs-parser.jay" +#line 2769 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -2384,13 +2384,13 @@ case 349: case_349(); break; case 351: -#line 2904 "cs-parser.jay" +#line 2887 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } break; case 352: -#line 2911 "cs-parser.jay" +#line 2894 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -2405,7 +2405,7 @@ case 358: case_358(); break; case 360: -#line 2949 "cs-parser.jay" +#line 2932 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -2414,7 +2414,7 @@ case 361: case_361(); break; case 362: -#line 2968 "cs-parser.jay" +#line 2951 "cs-parser.jay" { yyVal = new ComposedCast ((ATypeNameExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -2423,13 +2423,13 @@ case 363: case_363(); break; case 364: -#line 2977 "cs-parser.jay" +#line 2960 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; case 365: -#line 2981 "cs-parser.jay" +#line 2964 "cs-parser.jay" { yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -2447,63 +2447,63 @@ case 369: case_369(); break; case 370: -#line 3020 "cs-parser.jay" +#line 3003 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } break; case 371: -#line 3021 "cs-parser.jay" +#line 3004 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } break; case 372: -#line 3022 "cs-parser.jay" +#line 3005 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } break; case 373: -#line 3023 "cs-parser.jay" +#line 3006 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } break; case 374: -#line 3024 "cs-parser.jay" +#line 3007 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } break; case 375: -#line 3025 "cs-parser.jay" +#line 3008 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); } break; case 377: -#line 3030 "cs-parser.jay" +#line 3013 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation (yyVals[0+yyTop])); } break; case 378: -#line 3031 "cs-parser.jay" +#line 3014 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation (yyVals[0+yyTop])); } break; case 379: -#line 3032 "cs-parser.jay" +#line 3015 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation (yyVals[0+yyTop])); } break; case 380: -#line 3033 "cs-parser.jay" +#line 3016 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation (yyVals[0+yyTop])); } break; case 381: -#line 3034 "cs-parser.jay" +#line 3017 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation (yyVals[0+yyTop])); } break; case 382: -#line 3035 "cs-parser.jay" +#line 3018 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation (yyVals[0+yyTop])); } break; case 383: -#line 3036 "cs-parser.jay" +#line 3019 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation (yyVals[0+yyTop])); } break; case 384: -#line 3037 "cs-parser.jay" +#line 3020 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation (yyVals[0+yyTop])); } break; case 385: -#line 3038 "cs-parser.jay" +#line 3021 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation (yyVals[0+yyTop])); } break; case 406: @@ -2513,22 +2513,22 @@ case 407: case_407(); break; case 411: -#line 3085 "cs-parser.jay" +#line 3068 "cs-parser.jay" { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } break; case 412: -#line 3089 "cs-parser.jay" +#line 3072 "cs-parser.jay" { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } break; case 413: -#line 3090 "cs-parser.jay" +#line 3073 "cs-parser.jay" { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } break; case 418: case_418(); break; case 419: -#line 3123 "cs-parser.jay" +#line 3106 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); } @@ -2546,7 +2546,7 @@ case 423: case_423(); break; case 424: -#line 3158 "cs-parser.jay" +#line 3141 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); } @@ -2555,7 +2555,7 @@ case 425: case_425(); break; case 426: -#line 3166 "cs-parser.jay" +#line 3149 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); } @@ -2567,7 +2567,7 @@ case 428: case_428(); break; case 429: -#line 3182 "cs-parser.jay" +#line 3165 "cs-parser.jay" { yyVal = null; } break; case 431: @@ -2577,11 +2577,11 @@ case 432: case_432(); break; case 433: -#line 3205 "cs-parser.jay" +#line 3188 "cs-parser.jay" { yyVal = null; } break; case 434: -#line 3209 "cs-parser.jay" +#line 3192 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2599,7 +2599,7 @@ case 438: case_438(); break; case 439: -#line 3242 "cs-parser.jay" +#line 3225 "cs-parser.jay" { yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); } @@ -2614,7 +2614,7 @@ case 442: case_442(); break; case 445: -#line 3270 "cs-parser.jay" +#line 3253 "cs-parser.jay" { yyVal = null; } break; case 447: @@ -2633,7 +2633,7 @@ case 451: case_451(); break; case 452: -#line 3322 "cs-parser.jay" +#line 3305 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } @@ -2654,13 +2654,13 @@ case 461: case_461(); break; case 462: -#line 3367 "cs-parser.jay" +#line 3350 "cs-parser.jay" { yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); } break; case 463: -#line 3371 "cs-parser.jay" +#line 3354 "cs-parser.jay" { yyVal = new ElementAccess ((Expression) yyVals[-2+yyTop], null, GetLocation (yyVals[-1+yyTop])); } @@ -2681,13 +2681,13 @@ case 468: case_468(); break; case 469: -#line 3417 "cs-parser.jay" +#line 3400 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; case 471: -#line 3425 "cs-parser.jay" +#line 3408 "cs-parser.jay" { yyVal = new This (GetLocation (yyVals[0+yyTop])); } @@ -2699,13 +2699,13 @@ case 473: case_473(); break; case 474: -#line 3445 "cs-parser.jay" +#line 3428 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; case 475: -#line 3452 "cs-parser.jay" +#line 3435 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } @@ -2732,7 +2732,7 @@ case 482: case_482(); break; case 483: -#line 3518 "cs-parser.jay" +#line 3501 "cs-parser.jay" { ++lexer.parsing_type; } @@ -2744,7 +2744,7 @@ case 485: case_485(); break; case 488: -#line 3545 "cs-parser.jay" +#line 3528 "cs-parser.jay" { yyVal = null; } break; case 490: @@ -2775,25 +2775,25 @@ case 501: case_501(); break; case 502: -#line 3623 "cs-parser.jay" +#line 3606 "cs-parser.jay" { yyVal = 2; } break; case 503: -#line 3627 "cs-parser.jay" +#line 3610 "cs-parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; case 504: -#line 3634 "cs-parser.jay" +#line 3617 "cs-parser.jay" { yyVal = null; } break; case 505: -#line 3638 "cs-parser.jay" +#line 3621 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2811,7 +2811,7 @@ case 509: case_509(); break; case 510: -#line 3682 "cs-parser.jay" +#line 3665 "cs-parser.jay" { lexer.TypeOfParsing = true; } @@ -2856,7 +2856,7 @@ case 525: case_525(); break; case 526: -#line 3802 "cs-parser.jay" +#line 3785 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop])); } @@ -2865,7 +2865,7 @@ case 527: case_527(); break; case 528: -#line 3815 "cs-parser.jay" +#line 3798 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop])); } @@ -2874,13 +2874,13 @@ case 529: case_529(); break; case 530: -#line 3832 "cs-parser.jay" +#line 3815 "cs-parser.jay" { yyVal = ParametersCompiled.Undefined; } break; case 532: -#line 3840 "cs-parser.jay" +#line 3823 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -2892,13 +2892,13 @@ case 534: case_534(); break; case 536: -#line 3866 "cs-parser.jay" +#line 3849 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 537: -#line 3870 "cs-parser.jay" +#line 3853 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2910,37 +2910,37 @@ case 539: case_539(); break; case 541: -#line 3898 "cs-parser.jay" +#line 3881 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 542: -#line 3902 "cs-parser.jay" +#line 3885 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 543: -#line 3906 "cs-parser.jay" +#line 3889 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 544: -#line 3910 "cs-parser.jay" +#line 3893 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 545: -#line 3914 "cs-parser.jay" +#line 3897 "cs-parser.jay" { yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 546: -#line 3918 "cs-parser.jay" +#line 3901 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2958,7 +2958,7 @@ case 552: case_552(); break; case 553: -#line 3950 "cs-parser.jay" +#line 3933 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -2967,13 +2967,13 @@ case 554: case_554(); break; case 555: -#line 3959 "cs-parser.jay" +#line 3942 "cs-parser.jay" { yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 556: -#line 3963 "cs-parser.jay" +#line 3946 "cs-parser.jay" { yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3024,7 +3024,7 @@ case 581: case_581(); break; case 582: -#line 4087 "cs-parser.jay" +#line 4070 "cs-parser.jay" { yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3075,14 +3075,14 @@ case 597: case_597(); break; case 598: -#line 4184 "cs-parser.jay" +#line 4167 "cs-parser.jay" { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 599: case_599(); break; case 602: -#line 4200 "cs-parser.jay" +#line 4183 "cs-parser.jay" { start_block (lexer.Location); } @@ -3106,7 +3106,7 @@ case 609: case_609(); break; case 610: -#line 4245 "cs-parser.jay" +#line 4228 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3118,7 +3118,7 @@ case 612: case_612(); break; case 613: -#line 4259 "cs-parser.jay" +#line 4242 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3130,7 +3130,7 @@ case 615: case_615(); break; case 621: -#line 4284 "cs-parser.jay" +#line 4267 "cs-parser.jay" { yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); } @@ -3145,13 +3145,13 @@ case 624: case_624(); break; case 626: -#line 4313 "cs-parser.jay" +#line 4296 "cs-parser.jay" { yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); } break; case 627: -#line 4326 "cs-parser.jay" +#line 4309 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -3169,18 +3169,18 @@ case 631: case_631(); break; case 632: -#line 4369 "cs-parser.jay" +#line 4353 "cs-parser.jay" { yyVal = null; } break; case 633: -#line 4371 "cs-parser.jay" +#line 4355 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } break; case 634: case_634(); break; case 635: -#line 4384 "cs-parser.jay" +#line 4368 "cs-parser.jay" { lexer.parsing_modifiers = false; } @@ -3237,7 +3237,7 @@ case 654: case_654(); break; case 656: -#line 4504 "cs-parser.jay" +#line 4488 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3267,19 +3267,19 @@ case 664: case_664(); break; case 665: -#line 4595 "cs-parser.jay" +#line 4579 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop])); } break; case 666: -#line 4599 "cs-parser.jay" +#line 4583 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop])); } break; case 667: -#line 4606 "cs-parser.jay" +#line 4590 "cs-parser.jay" { yyVal = Variance.None; } @@ -3297,7 +3297,7 @@ case 671: case_671(); break; case 672: -#line 4651 "cs-parser.jay" +#line 4635 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3315,13 +3315,13 @@ case 676: case_676(); break; case 681: -#line 4695 "cs-parser.jay" +#line 4679 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; case 682: -#line 4699 "cs-parser.jay" +#line 4683 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } @@ -3333,13 +3333,13 @@ case 685: case_685(); break; case 688: -#line 4733 "cs-parser.jay" +#line 4717 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; case 689: -#line 4737 "cs-parser.jay" +#line 4721 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } @@ -3372,13 +3372,13 @@ case 728: case_728(); break; case 729: -#line 4881 "cs-parser.jay" +#line 4865 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; case 730: -#line 4885 "cs-parser.jay" +#line 4869 "cs-parser.jay" { yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } @@ -3390,7 +3390,7 @@ case 733: case_733(); break; case 734: -#line 4906 "cs-parser.jay" +#line 4890 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); } @@ -3429,7 +3429,7 @@ case 752: case_752(); break; case 753: -#line 5031 "cs-parser.jay" +#line 5015 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); } @@ -3450,15 +3450,15 @@ case 763: case_763(); break; case 764: -#line 5081 "cs-parser.jay" +#line 5065 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 765: -#line 5085 "cs-parser.jay" +#line 5069 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 766: -#line 5086 "cs-parser.jay" +#line 5070 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 767: @@ -3480,7 +3480,7 @@ case 774: case_774(); break; case 775: -#line 5161 "cs-parser.jay" +#line 5145 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); } @@ -3504,13 +3504,13 @@ case 782: case_782(); break; case 783: -#line 5212 "cs-parser.jay" +#line 5196 "cs-parser.jay" { current_block = current_block.CreateSwitchBlock (lexer.Location); } break; case 784: -#line 5216 "cs-parser.jay" +#line 5200 "cs-parser.jay" { yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); } @@ -3525,7 +3525,7 @@ case 787: case_787(); break; case 788: -#line 5245 "cs-parser.jay" +#line 5229 "cs-parser.jay" { yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); } @@ -3549,25 +3549,25 @@ case 798: case_798(); break; case 799: -#line 5305 "cs-parser.jay" +#line 5289 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; case 800: -#line 5313 "cs-parser.jay" +#line 5297 "cs-parser.jay" { ((For) yyVals[-2+yyTop]).Initializer = (Statement) yyVals[-1+yyTop]; } break; case 801: -#line 5317 "cs-parser.jay" +#line 5301 "cs-parser.jay" { ((For) yyVals[-5+yyTop]).Condition = (BooleanExpression) yyVals[-1+yyTop]; } break; case 802: -#line 5321 "cs-parser.jay" +#line 5305 "cs-parser.jay" { ((For) yyVals[-8+yyTop]).Iterator = (Statement) yyVals[-1+yyTop]; } @@ -3579,7 +3579,7 @@ case 804: case_804(); break; case 805: -#line 5341 "cs-parser.jay" +#line 5325 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; case 807: @@ -3589,11 +3589,11 @@ case 808: case_808(); break; case 810: -#line 5362 "cs-parser.jay" +#line 5346 "cs-parser.jay" { yyVal = null; } break; case 812: -#line 5367 "cs-parser.jay" +#line 5351 "cs-parser.jay" { yyVal = new EmptyStatement (lexer.Location); } break; case 816: @@ -3645,7 +3645,7 @@ case 837: case_837(); break; case 840: -#line 5568 "cs-parser.jay" +#line 5552 "cs-parser.jay" { yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); } @@ -3666,7 +3666,7 @@ case 845: case_845(); break; case 848: -#line 5617 "cs-parser.jay" +#line 5601 "cs-parser.jay" { yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3675,7 +3675,7 @@ case 849: case_849(); break; case 850: -#line 5636 "cs-parser.jay" +#line 5620 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } @@ -3684,13 +3684,13 @@ case 851: case_851(); break; case 852: -#line 5654 "cs-parser.jay" +#line 5638 "cs-parser.jay" { yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; case 853: -#line 5661 "cs-parser.jay" +#line 5645 "cs-parser.jay" { yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } @@ -3699,7 +3699,7 @@ case 854: case_854(); break; case 855: -#line 5671 "cs-parser.jay" +#line 5655 "cs-parser.jay" { yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } @@ -3738,7 +3738,7 @@ case 867: case_867(); break; case 868: -#line 5776 "cs-parser.jay" +#line 5760 "cs-parser.jay" { Error_MissingInitializer (lexer.Location); } @@ -3771,7 +3771,7 @@ case 877: case_877(); break; case 878: -#line 5877 "cs-parser.jay" +#line 5861 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3780,7 +3780,7 @@ case 879: case_879(); break; case 880: -#line 5892 "cs-parser.jay" +#line 5876 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3795,7 +3795,7 @@ case 884: case_884(); break; case 885: -#line 5937 "cs-parser.jay" +#line 5921 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3816,7 +3816,7 @@ case 893: case_893(); break; case 899: -#line 5996 "cs-parser.jay" +#line 5980 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3825,7 +3825,7 @@ case 900: case_900(); break; case 901: -#line 6015 "cs-parser.jay" +#line 5999 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3858,13 +3858,13 @@ case 910: case_910(); break; case 912: -#line 6159 "cs-parser.jay" +#line 6143 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; case 913: -#line 6166 "cs-parser.jay" +#line 6150 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } @@ -3885,7 +3885,7 @@ case 920: case_920(); break; case 921: -#line 6212 "cs-parser.jay" +#line 6196 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } @@ -3897,7 +3897,7 @@ case 923: case_923(); break; case 924: -#line 6229 "cs-parser.jay" +#line 6213 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); } @@ -3921,13 +3921,13 @@ case 933: case_933(); break; case 941: -#line 6353 "cs-parser.jay" +#line 6336 "cs-parser.jay" { module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop]; } break; case 942: -#line 6360 "cs-parser.jay" +#line 6343 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; } @@ -3939,13 +3939,13 @@ case 944: case_944(); break; case 945: -#line 6377 "cs-parser.jay" +#line 6360 "cs-parser.jay" { yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], MemberCache.IndexerNameAlias, Location.Null); } break; case 946: -#line 6381 "cs-parser.jay" +#line 6364 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } @@ -3963,25 +3963,25 @@ case 950: case_950(); break; case 952: -#line 6417 "cs-parser.jay" +#line 6400 "cs-parser.jay" { yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]); } break; case 954: -#line 6425 "cs-parser.jay" +#line 6408 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; case 955: -#line 6429 "cs-parser.jay" +#line 6412 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 956: -#line 6436 "cs-parser.jay" +#line 6419 "cs-parser.jay" { yyVal = new List (0); } @@ -4438,7 +4438,8 @@ void case_96() { lexer.ConstraintsParsing = false; - current_class.SetParameterInfo ((List) yyVals[0+yyTop]); + if (yyVals[0+yyTop] != null) + current_class.SetConstraints ((List) yyVals[0+yyTop]); if (doc_support) current_container.DocComment = Lexer.consume_doc_comment (); @@ -4448,14 +4449,14 @@ void case_96() } void case_97() -#line 958 "cs-parser.jay" +#line 959 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_98() -#line 963 "cs-parser.jay" +#line 964 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); --lexer.parsing_declaration; @@ -4464,7 +4465,7 @@ void case_98() } void case_99() -#line 970 "cs-parser.jay" +#line 971 "cs-parser.jay" { if (yyVals[-1+yyTop] != null) current_class.OptionalSemicolon = GetLocation (yyVals[-1+yyTop]); @@ -4472,7 +4473,7 @@ void case_99() } void case_101() -#line 985 "cs-parser.jay" +#line 986 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var mod = (Modifiers) yyVals[-3+yyTop]; @@ -4487,7 +4488,7 @@ void case_101() } void case_102() -#line 998 "cs-parser.jay" +#line 999 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4500,7 +4501,7 @@ void case_102() } void case_107() -#line 1028 "cs-parser.jay" +#line 1029 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4508,7 +4509,7 @@ void case_107() } void case_109() -#line 1041 "cs-parser.jay" +#line 1042 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -4516,14 +4517,14 @@ void case_109() } void case_110() -#line 1047 "cs-parser.jay" +#line 1048 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); yyVal = null; } void case_113() -#line 1062 "cs-parser.jay" +#line 1063 "cs-parser.jay" { lexer.parsing_generic_declaration = false; @@ -4538,7 +4539,7 @@ void case_113() } void case_114() -#line 1077 "cs-parser.jay" +#line 1078 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4551,7 +4552,7 @@ void case_114() } void case_115() -#line 1090 "cs-parser.jay" +#line 1091 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "fixed size buffers"); @@ -4564,7 +4565,7 @@ void case_115() } void case_116() -#line 1101 "cs-parser.jay" +#line 1102 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4578,7 +4579,7 @@ void case_116() } void case_119() -#line 1124 "cs-parser.jay" +#line 1125 "cs-parser.jay" { ++lexer.parsing_block; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -4586,7 +4587,7 @@ void case_119() } void case_120() -#line 1130 "cs-parser.jay" +#line 1131 "cs-parser.jay" { --lexer.parsing_block; current_field.Initializer = (Expression) yyVals[0+yyTop]; @@ -4596,7 +4597,7 @@ void case_120() } void case_125() -#line 1157 "cs-parser.jay" +#line 1158 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -4604,7 +4605,7 @@ void case_125() } void case_127() -#line 1167 "cs-parser.jay" +#line 1168 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4613,7 +4614,7 @@ void case_127() } void case_132() -#line 1193 "cs-parser.jay" +#line 1194 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4621,7 +4622,7 @@ void case_132() } void case_134() -#line 1206 "cs-parser.jay" +#line 1207 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); @@ -4629,14 +4630,14 @@ void case_134() } void case_135() -#line 1212 "cs-parser.jay" +#line 1213 "cs-parser.jay" { report.Error (443, lexer.Location, "Value or constant expected"); yyVal = null; } void case_138() -#line 1222 "cs-parser.jay" +#line 1223 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); @@ -4644,7 +4645,7 @@ void case_138() } void case_139() -#line 1231 "cs-parser.jay" +#line 1232 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.NotAllowed; @@ -4656,7 +4657,7 @@ void case_139() } void case_140() -#line 1241 "cs-parser.jay" +#line 1242 "cs-parser.jay" { Method method = (Method) yyVals[-2+yyTop]; method.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -4684,26 +4685,18 @@ void case_140() } void case_143() -#line 1281 "cs-parser.jay" +#line 1282 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; MemberName name = (MemberName) yyVals[-6+yyTop]; current_local_parameters = (ParametersCompiled) yyVals[-3+yyTop]; - GenericMethod generic = null; - if (name.TypeParameters != null) { - generic = new GenericMethod (current_namespace, current_class, name, - (FullNamedExpression) yyVals[-7+yyTop], current_local_parameters); - - generic.SetParameterInfo ((List) yyVals[0+yyTop]); - } else if (yyVals[0+yyTop] != null) { - report.Error (80, GetLocation (yyVals[0+yyTop]), - "Constraints are not allowed on non-generic declarations"); - } - - var method = Method.Create (current_class, generic, (FullNamedExpression) yyVals[-7+yyTop], (Modifiers) yyVals[-8+yyTop], + var method = Method.Create (current_class, (FullNamedExpression) yyVals[-7+yyTop], (Modifiers) yyVals[-8+yyTop], name, current_local_parameters, (Attributes) yyVals[-9+yyTop], yyVals[0+yyTop] != null); + + if (yyVals[0+yyTop] != null) + method.SetConstraints ((List) yyVals[0+yyTop]); if (doc_support) method.DocComment = Lexer.consume_doc_comment (); @@ -4713,14 +4706,14 @@ void case_143() } void case_145() -#line 1316 "cs-parser.jay" +#line 1309 "cs-parser.jay" { lexer.parsing_generic_declaration = false; valid_param_mod = ParameterModifierType.All; } void case_147() -#line 1325 "cs-parser.jay" +#line 1318 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4728,25 +4721,15 @@ void case_147() MemberName name = (MemberName) yyVals[-6+yyTop]; current_local_parameters = (ParametersCompiled) yyVals[-3+yyTop]; - if (yyVals[-1+yyTop] != null && name.TypeParameters == null) - report.Error (80, lexer.Location, - "Constraints are not allowed on non-generic declarations"); - - GenericMethod generic = null; - if (name.TypeParameters != null) { - generic = new GenericMethod (current_namespace, current_class, name, - new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-8+yyTop])), - current_local_parameters); - - generic.SetParameterInfo ((List) yyVals[-1+yyTop]); - } - var modifiers = (Modifiers) yyVals[-10+yyTop]; modifiers |= Modifiers.PARTIAL; - var method = Method.Create (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-8+yyTop])), + var method = Method.Create (current_class, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-8+yyTop])), modifiers, name, current_local_parameters, (Attributes) yyVals[-11+yyTop], yyVals[-1+yyTop] != null); + if (yyVals[-1+yyTop] != null) + method.SetConstraints ((List) yyVals[-1+yyTop]); + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); @@ -4756,13 +4739,13 @@ void case_147() } void case_148() -#line 1362 "cs-parser.jay" +#line 1345 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-3+yyTop]; report.Error (1585, name.Location, "Member modifier `{0}' must precede the member type and name", ModifiersExtensions.Name ((Modifiers) yyVals[-4+yyTop])); - var method = Method.Create (current_class, null, (FullNamedExpression) yyVals[-5+yyTop], + var method = Method.Create (current_class, (FullNamedExpression) yyVals[-5+yyTop], 0, name, (ParametersCompiled) yyVals[-1+yyTop], (Attributes) yyVals[-7+yyTop], false); current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; @@ -4774,7 +4757,7 @@ void case_148() } void case_153() -#line 1391 "cs-parser.jay" +#line 1374 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); @@ -4782,7 +4765,7 @@ void case_153() } void case_154() -#line 1397 "cs-parser.jay" +#line 1380 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add ((Parameter) yyVals[0+yyTop]); @@ -4793,7 +4776,7 @@ void case_154() } void case_155() -#line 1406 "cs-parser.jay" +#line 1389 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add (new ArglistParameter (GetLocation (yyVals[0+yyTop]))); @@ -4804,7 +4787,7 @@ void case_155() } void case_156() -#line 1415 "cs-parser.jay" +#line 1398 "cs-parser.jay" { if (yyVals[-2+yyTop] != null) report.Error (231, ((Parameter) yyVals[-2+yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list"); @@ -4814,7 +4797,7 @@ void case_156() } void case_157() -#line 1423 "cs-parser.jay" +#line 1406 "cs-parser.jay" { if (yyVals[-2+yyTop] != null) report.Error (231, ((Parameter) yyVals[-2+yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list"); @@ -4829,7 +4812,7 @@ void case_157() } void case_158() -#line 1436 "cs-parser.jay" +#line 1419 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4838,7 +4821,7 @@ void case_158() } void case_159() -#line 1443 "cs-parser.jay" +#line 1426 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4852,14 +4835,14 @@ void case_159() } void case_162() -#line 1463 "cs-parser.jay" +#line 1446 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = ParametersCompiled.EmptyReadOnlyParameters; } void case_163() -#line 1471 "cs-parser.jay" +#line 1454 "cs-parser.jay" { parameters_bucket.Clear (); Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4870,7 +4853,7 @@ void case_163() } void case_164() -#line 1480 "cs-parser.jay" +#line 1463 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4890,7 +4873,7 @@ void case_164() } void case_165() -#line 1504 "cs-parser.jay" +#line 1487 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Parameter.Modifier) yyVals[-2+yyTop], (Attributes) yyVals[-3+yyTop], lt.Location); @@ -4898,7 +4881,7 @@ void case_165() } void case_166() -#line 1513 "cs-parser.jay" +#line 1496 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name"); @@ -4907,7 +4890,7 @@ void case_166() } void case_167() -#line 1523 "cs-parser.jay" +#line 1506 "cs-parser.jay" { Error_SyntaxError (yyToken); Location l = GetLocation (yyVals[0+yyTop]); @@ -4916,7 +4899,7 @@ void case_167() } void case_169() -#line 1538 "cs-parser.jay" +#line 1521 "cs-parser.jay" { --lexer.parsing_block; if (lang_version <= LanguageVersion.V_3) { @@ -4955,7 +4938,7 @@ void case_169() } void case_173() -#line 1587 "cs-parser.jay" +#line 1570 "cs-parser.jay" { Parameter.Modifier p2 = (Parameter.Modifier)yyVals[0+yyTop]; Parameter.Modifier mod = (Parameter.Modifier)yyVals[-1+yyTop] | p2; @@ -4978,7 +4961,7 @@ void case_173() } void case_174() -#line 1611 "cs-parser.jay" +#line 1594 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Ref) == 0) Error_ParameterModifierNotValid ("ref", GetLocation (yyVals[0+yyTop])); @@ -4987,7 +4970,7 @@ void case_174() } void case_175() -#line 1618 "cs-parser.jay" +#line 1601 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Out) == 0) Error_ParameterModifierNotValid ("out", GetLocation (yyVals[0+yyTop])); @@ -4996,7 +4979,7 @@ void case_175() } void case_176() -#line 1625 "cs-parser.jay" +#line 1608 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.This) == 0) Error_ParameterModifierNotValid ("this", GetLocation (yyVals[0+yyTop])); @@ -5008,7 +4991,7 @@ void case_176() } void case_177() -#line 1638 "cs-parser.jay" +#line 1621 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ParamsParameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Attributes) yyVals[-3+yyTop], lt.Location); @@ -5016,7 +4999,7 @@ void case_177() } void case_178() -#line 1644 "cs-parser.jay" +#line 1627 "cs-parser.jay" { report.Error (1751, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for a parameter array"); @@ -5026,14 +5009,14 @@ void case_178() } void case_179() -#line 1652 "cs-parser.jay" +#line 1635 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_180() -#line 1660 "cs-parser.jay" +#line 1643 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Params) == 0) report.Error (1670, (GetLocation (yyVals[0+yyTop])), "The `params' modifier is not allowed in current context"); @@ -5041,7 +5024,7 @@ void case_180() } void case_181() -#line 1666 "cs-parser.jay" +#line 1649 "cs-parser.jay" { Parameter.Modifier mod = (Parameter.Modifier)yyVals[0+yyTop]; if ((mod & Parameter.Modifier.This) != 0) { @@ -5053,21 +5036,21 @@ void case_181() } void case_183() -#line 1683 "cs-parser.jay" +#line 1666 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Arglist) == 0) report.Error (1669, GetLocation (yyVals[0+yyTop]), "__arglist is not valid in this context"); } void case_184() -#line 1694 "cs-parser.jay" +#line 1677 "cs-parser.jay" { if (doc_support) tmpComment = Lexer.consume_doc_comment (); } void case_185() -#line 1699 "cs-parser.jay" +#line 1682 "cs-parser.jay" { var type = (FullNamedExpression) yyVals[-3+yyTop]; current_property = new Property (current_class, type, (Modifiers) yyVals[-4+yyTop], @@ -5083,7 +5066,7 @@ void case_185() } void case_186() -#line 1713 "cs-parser.jay" +#line 1696 "cs-parser.jay" { lexer.PropertyParsing = false; @@ -5092,14 +5075,14 @@ void case_186() } void case_187() -#line 1720 "cs-parser.jay" +#line 1703 "cs-parser.jay" { lbag.AppendToMember (current_property, GetLocation (yyVals[0+yyTop])); current_property = null; } void case_189() -#line 1734 "cs-parser.jay" +#line 1717 "cs-parser.jay" { valid_param_mod = 0; var type = (FullNamedExpression) yyVals[-6+yyTop]; @@ -5126,7 +5109,7 @@ void case_189() } void case_191() -#line 1763 "cs-parser.jay" +#line 1746 "cs-parser.jay" { if (current_property.AccessorFirst != null && current_property.AccessorFirst.Block == null) ((Indexer) current_property).ParameterInfo.CheckParameters (current_property); @@ -5139,7 +5122,7 @@ void case_191() } void case_196() -#line 1782 "cs-parser.jay" +#line 1765 "cs-parser.jay" { if (yyToken == Token.CLOSE_BRACE) { report.Error (548, lexer.Location, "`{0}': property or indexer must have at least one accessor", current_property.GetSignatureForError ()); @@ -5152,7 +5135,7 @@ void case_196() } void case_197() -#line 1796 "cs-parser.jay" +#line 1779 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5175,7 +5158,7 @@ void case_197() } void case_198() -#line 1817 "cs-parser.jay" +#line 1800 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Get.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5198,7 +5181,7 @@ void case_198() } void case_199() -#line 1841 "cs-parser.jay" +#line 1824 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5226,7 +5209,7 @@ void case_199() } void case_200() -#line 1867 "cs-parser.jay" +#line 1850 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Set.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5249,21 +5232,21 @@ void case_200() } void case_202() -#line 1892 "cs-parser.jay" +#line 1875 "cs-parser.jay" { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } void case_203() -#line 1897 "cs-parser.jay" +#line 1880 "cs-parser.jay" { Error_SyntaxError (1043, yyToken, "Invalid accessor body"); yyVal = null; } void case_205() -#line 1912 "cs-parser.jay" +#line 1895 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); push_current_class (new Interface (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]); @@ -5271,11 +5254,12 @@ void case_205() } void case_206() -#line 1919 "cs-parser.jay" +#line 1902 "cs-parser.jay" { lexer.ConstraintsParsing = false; - current_class.SetParameterInfo ((List) yyVals[0+yyTop]); + if (yyVals[0+yyTop] != null) + current_class.SetConstraints ((List) yyVals[0+yyTop]); if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); @@ -5286,7 +5270,7 @@ void case_206() } void case_207() -#line 1932 "cs-parser.jay" +#line 1916 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -5294,7 +5278,7 @@ void case_207() } void case_208() -#line 1938 "cs-parser.jay" +#line 1922 "cs-parser.jay" { if (yyVals[0+yyTop] != null) current_class.OptionalSemicolon = GetLocation (yyVals[0+yyTop]); @@ -5303,7 +5287,7 @@ void case_208() } void case_224() -#line 1998 "cs-parser.jay" +#line 1982 "cs-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { @@ -5333,14 +5317,14 @@ void case_224() } void case_228() -#line 2035 "cs-parser.jay" +#line 2019 "cs-parser.jay" { report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void"); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_230() -#line 2047 "cs-parser.jay" +#line 2031 "cs-parser.jay" { valid_param_mod = 0; @@ -5382,7 +5366,7 @@ void case_230() } void case_255() -#line 2123 "cs-parser.jay" +#line 2107 "cs-parser.jay" { valid_param_mod = 0; @@ -5399,7 +5383,7 @@ void case_255() } void case_257() -#line 2142 "cs-parser.jay" +#line 2126 "cs-parser.jay" { valid_param_mod = 0; @@ -5416,7 +5400,7 @@ void case_257() } void case_258() -#line 2157 "cs-parser.jay" +#line 2141 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -5424,7 +5408,7 @@ void case_258() } void case_259() -#line 2163 "cs-parser.jay" +#line 2147 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -5432,7 +5416,7 @@ void case_259() } void case_260() -#line 2173 "cs-parser.jay" +#line 2157 "cs-parser.jay" { Constructor c = (Constructor) yyVals[-1+yyTop]; c.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5440,15 +5424,13 @@ void case_260() if (doc_support) c.DocComment = ConsumeStoredComment (); - current_container.AddConstructor (c); - current_local_parameters = null; if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_261() -#line 2192 "cs-parser.jay" +#line 2174 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5459,7 +5441,7 @@ void case_261() } void case_262() -#line 2201 "cs-parser.jay" +#line 2183 "cs-parser.jay" { valid_param_mod = 0; current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; @@ -5478,6 +5460,7 @@ void case_262() } } + current_container.AddConstructor (c); lbag.AddMember (c, GetModifierLocations (), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); yyVal = c; @@ -5489,7 +5472,7 @@ void case_262() } void case_263() -#line 2229 "cs-parser.jay" +#line 2212 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { var c = (Constructor) yyVals[-1+yyTop]; @@ -5500,14 +5483,13 @@ void case_263() "`{0}': static constructor cannot have an explicit `this' or `base' constructor call", c.GetSignatureForError ()); } - lbag.AddMember (c, GetModifierLocations (), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } yyVal = yyVals[-1+yyTop]; } void case_269() -#line 2262 "cs-parser.jay" +#line 2244 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorBaseInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -5515,7 +5497,7 @@ void case_269() } void case_271() -#line 2272 "cs-parser.jay" +#line 2254 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorThisInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -5523,14 +5505,14 @@ void case_271() } void case_272() -#line 2278 "cs-parser.jay" +#line 2260 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_273() -#line 2286 "cs-parser.jay" +#line 2268 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5541,7 +5523,7 @@ void case_273() } void case_274() -#line 2295 "cs-parser.jay" +#line 2277 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lt.Value != current_container.MemberName.Name){ @@ -5563,7 +5545,7 @@ void case_274() } void case_275() -#line 2320 "cs-parser.jay" +#line 2302 "cs-parser.jay" { current_event_field = new EventField (current_class, (FullNamedExpression) yyVals[-1+yyTop], (Modifiers) yyVals[-3+yyTop], (MemberName) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop]); current_container.AddEvent (current_event_field); @@ -5577,7 +5559,7 @@ void case_275() } void case_276() -#line 2334 "cs-parser.jay" +#line 2316 "cs-parser.jay" { if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); @@ -5589,7 +5571,7 @@ void case_276() } void case_277() -#line 2347 "cs-parser.jay" +#line 2329 "cs-parser.jay" { current_event = new EventProperty (current_class, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-4+yyTop], (MemberName) yyVals[-1+yyTop], (Attributes) yyVals[-5+yyTop]); current_container.AddEvent (current_event); @@ -5599,7 +5581,7 @@ void case_277() } void case_278() -#line 2355 "cs-parser.jay" +#line 2337 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) report.Error (69, GetLocation (yyVals[-2+yyTop]), "Event in interface cannot have add or remove accessors"); @@ -5608,7 +5590,7 @@ void case_278() } void case_279() -#line 2362 "cs-parser.jay" +#line 2344 "cs-parser.jay" { if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); @@ -5621,14 +5603,14 @@ void case_279() } void case_282() -#line 2381 "cs-parser.jay" +#line 2363 "cs-parser.jay" { --lexer.parsing_block; current_event_field.Initializer = (Expression) yyVals[0+yyTop]; } void case_287() -#line 2405 "cs-parser.jay" +#line 2387 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -5636,7 +5618,7 @@ void case_287() } void case_289() -#line 2415 "cs-parser.jay" +#line 2397 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -5645,7 +5627,7 @@ void case_289() } void case_290() -#line 2424 "cs-parser.jay" +#line 2406 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) { report.Error (68, lexer.Location, "`{0}': event in interface cannot have an initializer", @@ -5659,28 +5641,28 @@ void case_290() } void case_294() -#line 2445 "cs-parser.jay" +#line 2427 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } void case_295() -#line 2450 "cs-parser.jay" +#line 2432 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } void case_296() -#line 2455 "cs-parser.jay" +#line 2437 "cs-parser.jay" { report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected"); yyVal = null; } void case_297() -#line 2463 "cs-parser.jay" +#line 2445 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5694,7 +5676,7 @@ void case_297() } void case_298() -#line 2475 "cs-parser.jay" +#line 2457 "cs-parser.jay" { lexer.EventParsing = true; @@ -5709,7 +5691,7 @@ void case_298() } void case_299() -#line 2491 "cs-parser.jay" +#line 2473 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5723,7 +5705,7 @@ void case_299() } void case_300() -#line 2503 "cs-parser.jay" +#line 2485 "cs-parser.jay" { lexer.EventParsing = true; @@ -5738,21 +5720,21 @@ void case_300() } void case_301() -#line 2519 "cs-parser.jay" +#line 2501 "cs-parser.jay" { report.Error (73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } void case_303() -#line 2532 "cs-parser.jay" +#line 2514 "cs-parser.jay" { if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } void case_304() -#line 2537 "cs-parser.jay" +#line 2519 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -5771,7 +5753,7 @@ void case_304() } void case_305() -#line 2554 "cs-parser.jay" +#line 2536 "cs-parser.jay" { /* here will be evaluated after CLOSE_BLACE is consumed.*/ if (doc_support) @@ -5779,7 +5761,7 @@ void case_305() } void case_306() -#line 2560 "cs-parser.jay" +#line 2542 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-1+yyTop])); if (yyVals[0+yyTop] != null) { @@ -5795,7 +5777,7 @@ void case_306() } void case_308() -#line 2578 "cs-parser.jay" +#line 2560 "cs-parser.jay" { var te = yyVals[0+yyTop] as TypeExpression; if (te == null || !EnumSpec.IsValidUnderlyingType (te.Type)) { @@ -5808,21 +5790,21 @@ void case_308() } void case_309() -#line 2589 "cs-parser.jay" +#line 2571 "cs-parser.jay" { Error_TypeExpected (GetLocation (yyVals[-1+yyTop])); yyVal = null; } void case_314() -#line 2607 "cs-parser.jay" +#line 2589 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } void case_315() -#line 2615 "cs-parser.jay" +#line 2597 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var em = new EnumMember ((Enum) current_class, new MemberName (lt.Value, lt.Location), (Attributes) yyVals[-1+yyTop]); @@ -5837,7 +5819,7 @@ void case_315() } void case_316() -#line 2628 "cs-parser.jay" +#line 2610 "cs-parser.jay" { ++lexer.parsing_block; if (doc_support) { @@ -5847,7 +5829,7 @@ void case_316() } void case_317() -#line 2636 "cs-parser.jay" +#line 2618 "cs-parser.jay" { --lexer.parsing_block; @@ -5863,7 +5845,7 @@ void case_317() } void case_319() -#line 2661 "cs-parser.jay" +#line 2643 "cs-parser.jay" { valid_param_mod = 0; @@ -5883,14 +5865,15 @@ void case_319() } void case_321() -#line 2683 "cs-parser.jay" +#line 2665 "cs-parser.jay" { if (doc_support) { current_delegate.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } - current_delegate.SetParameterInfo ((List) yyVals[-2+yyTop]); + if (yyVals[-2+yyTop] != null) + current_delegate.SetConstraints ((List) yyVals[-2+yyTop]); lbag.AddMember (current_delegate, GetModifierLocations (), GetLocation (yyVals[-10+yyTop]), GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[0+yyTop])); yyVal = current_delegate; @@ -5899,7 +5882,7 @@ void case_321() } void case_323() -#line 2701 "cs-parser.jay" +#line 2684 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types"); @@ -5908,7 +5891,7 @@ void case_323() } void case_325() -#line 2712 "cs-parser.jay" +#line 2695 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5918,7 +5901,7 @@ void case_325() } void case_327() -#line 2724 "cs-parser.jay" +#line 2707 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); @@ -5926,14 +5909,14 @@ void case_327() } void case_328() -#line 2733 "cs-parser.jay" +#line 2716 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } void case_330() -#line 2745 "cs-parser.jay" +#line 2728 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -5946,14 +5929,14 @@ void case_330() } void case_331() -#line 2756 "cs-parser.jay" +#line 2739 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = new TypeArguments (); } void case_332() -#line 2764 "cs-parser.jay" +#line 2747 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -5962,7 +5945,7 @@ void case_332() } void case_333() -#line 2771 "cs-parser.jay" +#line 2754 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -5971,7 +5954,7 @@ void case_333() } void case_335() -#line 2788 "cs-parser.jay" +#line 2771 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -5979,7 +5962,7 @@ void case_335() } void case_336() -#line 2797 "cs-parser.jay" +#line 2780 "cs-parser.jay" { MemberName mn = (MemberName)yyVals[0+yyTop]; if (mn.TypeParameters != null) @@ -5988,7 +5971,7 @@ void case_336() } void case_338() -#line 2808 "cs-parser.jay" +#line 2791 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5996,21 +5979,21 @@ void case_338() } void case_339() -#line 2817 "cs-parser.jay" +#line 2800 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeContainer.DefaultIndexerName, GetLocation (yyVals[0+yyTop])); } void case_340() -#line 2822 "cs-parser.jay" +#line 2805 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeContainer.DefaultIndexerName, null, (ATypeNameExpression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } void case_341() -#line 2830 "cs-parser.jay" +#line 2813 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location); @@ -6018,7 +6001,7 @@ void case_341() } void case_342() -#line 2836 "cs-parser.jay" +#line 2819 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -6028,7 +6011,7 @@ void case_342() } void case_343() -#line 2844 "cs-parser.jay" +#line 2827 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new MemberAccess ((ATypeNameExpression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location); @@ -6036,7 +6019,7 @@ void case_343() } void case_345() -#line 2854 "cs-parser.jay" +#line 2837 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -6046,7 +6029,7 @@ void case_345() } void case_346() -#line 2865 "cs-parser.jay" +#line 2848 "cs-parser.jay" { var tparams = new TypeParameters (); tparams.Add ((TypeParameter)yyVals[0+yyTop]); @@ -6054,7 +6037,7 @@ void case_346() } void case_347() -#line 2871 "cs-parser.jay" +#line 2854 "cs-parser.jay" { var tparams = (TypeParameters) yyVals[-2+yyTop]; tparams.Add ((TypeParameter)yyVals[0+yyTop]); @@ -6063,14 +6046,14 @@ void case_347() } void case_348() -#line 2881 "cs-parser.jay" +#line 2864 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop]; yyVal = new TypeParameter (new MemberName (lt.Value, lt.Location), (Attributes)yyVals[-2+yyTop], (Variance) yyVals[-1+yyTop]); } void case_349() -#line 2886 "cs-parser.jay" +#line 2869 "cs-parser.jay" { if (GetTokenName (yyToken) == "type") report.Error (81, GetLocation (yyVals[0+yyTop]), "Type parameter declaration must be an identifier not a type"); @@ -6081,28 +6064,28 @@ void case_349() } void case_354() -#line 2920 "cs-parser.jay" +#line 2903 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_356() -#line 2929 "cs-parser.jay" +#line 2912 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_358() -#line 2938 "cs-parser.jay" +#line 2921 "cs-parser.jay" { report.Error (1536, GetLocation (yyVals[0+yyTop]), "Invalid parameter type `void'"); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_361() -#line 2954 "cs-parser.jay" +#line 2937 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { yyVal = new ComposedCast ((ATypeNameExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); @@ -6116,14 +6099,14 @@ void case_361() } void case_363() -#line 2970 "cs-parser.jay" +#line 2953 "cs-parser.jay" { if (yyVals[0+yyTop] != null) yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } void case_366() -#line 2986 "cs-parser.jay" +#line 2969 "cs-parser.jay" { var types = new List (2); types.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6131,7 +6114,7 @@ void case_366() } void case_367() -#line 2992 "cs-parser.jay" +#line 2975 "cs-parser.jay" { var types = (List) yyVals[-2+yyTop]; types.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6140,7 +6123,7 @@ void case_367() } void case_368() -#line 3002 "cs-parser.jay" +#line 2985 "cs-parser.jay" { if (yyVals[0+yyTop] is ComposedCast) { report.Error (1521, GetLocation (yyVals[0+yyTop]), "Invalid base type `{0}'", ((ComposedCast)yyVals[0+yyTop]).GetSignatureForError ()); @@ -6149,35 +6132,35 @@ void case_368() } void case_369() -#line 3009 "cs-parser.jay" +#line 2992 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } void case_406() -#line 3071 "cs-parser.jay" +#line 3054 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } void case_407() -#line 3075 "cs-parser.jay" +#line 3058 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location); } void case_418() -#line 3116 "cs-parser.jay" +#line 3099 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_420() -#line 3128 "cs-parser.jay" +#line 3111 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location) { @@ -6186,7 +6169,7 @@ void case_420() } void case_421() -#line 3135 "cs-parser.jay" +#line 3118 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location) { @@ -6195,7 +6178,7 @@ void case_421() } void case_422() -#line 3142 "cs-parser.jay" +#line 3125 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location) { @@ -6204,7 +6187,7 @@ void case_422() } void case_423() -#line 3149 "cs-parser.jay" +#line 3132 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6214,28 +6197,28 @@ void case_423() } void case_425() -#line 3159 "cs-parser.jay" +#line 3142 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } void case_427() -#line 3167 "cs-parser.jay" +#line 3150 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } void case_428() -#line 3175 "cs-parser.jay" +#line 3158 "cs-parser.jay" { yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_431() -#line 3188 "cs-parser.jay" +#line 3171 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) { yyVal = CollectionOrObjectInitializers.Empty; @@ -6247,14 +6230,14 @@ void case_431() } void case_432() -#line 3198 "cs-parser.jay" +#line 3181 "cs-parser.jay" { yyVal = new CollectionOrObjectInitializers ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_435() -#line 3214 "cs-parser.jay" +#line 3197 "cs-parser.jay" { var a = new List (); a.Add ((Expression) yyVals[0+yyTop]); @@ -6262,7 +6245,7 @@ void case_435() } void case_436() -#line 3220 "cs-parser.jay" +#line 3203 "cs-parser.jay" { var a = (List)yyVals[-2+yyTop]; a.Add ((Expression) yyVals[0+yyTop]); @@ -6271,14 +6254,14 @@ void case_436() } void case_437() -#line 3226 "cs-parser.jay" +#line 3209 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } void case_438() -#line 3234 "cs-parser.jay" +#line 3217 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new ElementInitializer (lt.Value, (Expression)yyVals[0+yyTop], lt.Location); @@ -6286,7 +6269,7 @@ void case_438() } void case_440() -#line 3243 "cs-parser.jay" +#line 3226 "cs-parser.jay" { CompletionSimpleName csn = yyVals[-1+yyTop] as CompletionSimpleName; if (csn == null) @@ -6296,7 +6279,7 @@ void case_440() } void case_441() -#line 3251 "cs-parser.jay" +#line 3234 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) yyVal = null; @@ -6305,14 +6288,14 @@ void case_441() } void case_442() -#line 3258 "cs-parser.jay" +#line 3241 "cs-parser.jay" { report.Error (1920, GetLocation (yyVals[-1+yyTop]), "An element initializer cannot be empty"); yyVal = null; } void case_447() -#line 3276 "cs-parser.jay" +#line 3259 "cs-parser.jay" { Arguments list = new Arguments (4); list.Add ((Argument) yyVals[0+yyTop]); @@ -6320,7 +6303,7 @@ void case_447() } void case_448() -#line 3282 "cs-parser.jay" +#line 3265 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; if (list [list.Count - 1] is NamedArgument) @@ -6332,7 +6315,7 @@ void case_448() } void case_449() -#line 3292 "cs-parser.jay" +#line 3275 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; NamedArgument a = (NamedArgument) yyVals[0+yyTop]; @@ -6349,56 +6332,56 @@ void case_449() } void case_450() -#line 3307 "cs-parser.jay" +#line 3290 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[0+yyTop]), "An argument is missing"); yyVal = yyVals[-1+yyTop]; } void case_451() -#line 3312 "cs-parser.jay" +#line 3295 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing"); yyVal = null; } void case_456() -#line 3333 "cs-parser.jay" +#line 3316 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_457() -#line 3338 "cs-parser.jay" +#line 3321 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_458() -#line 3343 "cs-parser.jay" +#line 3326 "cs-parser.jay" { yyVal = new Argument (new Arglist ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]))); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_459() -#line 3348 "cs-parser.jay" +#line 3331 "cs-parser.jay" { yyVal = new Argument (new Arglist (GetLocation (yyVals[-2+yyTop]))); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_461() -#line 3360 "cs-parser.jay" +#line 3343 "cs-parser.jay" { yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_464() -#line 3376 "cs-parser.jay" +#line 3359 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); @@ -6406,7 +6389,7 @@ void case_464() } void case_465() -#line 3382 "cs-parser.jay" +#line 3365 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6415,14 +6398,14 @@ void case_465() } void case_466() -#line 3388 "cs-parser.jay" +#line 3371 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } void case_467() -#line 3396 "cs-parser.jay" +#line 3379 "cs-parser.jay" { Arguments args = new Arguments (4); args.Add ((Argument) yyVals[0+yyTop]); @@ -6430,7 +6413,7 @@ void case_467() } void case_468() -#line 3402 "cs-parser.jay" +#line 3385 "cs-parser.jay" { Arguments args = (Arguments) yyVals[-2+yyTop]; if (args [args.Count - 1] is NamedArgument && !(yyVals[0+yyTop] is NamedArgument)) @@ -6442,21 +6425,21 @@ void case_468() } void case_472() -#line 3430 "cs-parser.jay" +#line 3413 "cs-parser.jay" { yyVal = new ElementAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_473() -#line 3435 "cs-parser.jay" +#line 3418 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop])); } void case_476() -#line 3457 "cs-parser.jay" +#line 3440 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { if (lang_version <= LanguageVersion.ISO_2) @@ -6471,7 +6454,7 @@ void case_476() } void case_477() -#line 3470 "cs-parser.jay" +#line 3453 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); @@ -6480,7 +6463,7 @@ void case_477() } void case_478() -#line 3482 "cs-parser.jay" +#line 3465 "cs-parser.jay" { yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List) yyVals[-3+yyTop], new ComposedTypeSpecifier (((List) yyVals[-3+yyTop]).Count, GetLocation (yyVals[-4+yyTop])) { @@ -6490,7 +6473,7 @@ void case_478() } void case_479() -#line 3490 "cs-parser.jay" +#line 3473 "cs-parser.jay" { if (yyVals[0+yyTop] == null) report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer"); @@ -6499,7 +6482,7 @@ void case_479() } void case_480() -#line 3497 "cs-parser.jay" +#line 3480 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); @@ -6508,28 +6491,28 @@ void case_480() } void case_481() -#line 3504 "cs-parser.jay" +#line 3487 "cs-parser.jay" { report.Error (178, GetLocation (yyVals[-1+yyTop]), "Invalid rank specifier, expecting `,' or `]'"); yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], null, GetLocation (yyVals[-6+yyTop])); } void case_482() -#line 3509 "cs-parser.jay" +#line 3492 "cs-parser.jay" { Error_SyntaxError (1526, yyToken, "Unexpected symbol"); yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } void case_484() -#line 3520 "cs-parser.jay" +#line 3503 "cs-parser.jay" { --lexer.parsing_type; yyVal = yyVals[0+yyTop]; } void case_485() -#line 3528 "cs-parser.jay" +#line 3511 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); @@ -6541,7 +6524,7 @@ void case_485() } void case_490() -#line 3551 "cs-parser.jay" +#line 3534 "cs-parser.jay" { var a = new List (4); a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6549,7 +6532,7 @@ void case_490() } void case_491() -#line 3557 "cs-parser.jay" +#line 3540 "cs-parser.jay" { var a = (List) yyVals[-2+yyTop]; a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6559,7 +6542,7 @@ void case_491() } void case_492() -#line 3568 "cs-parser.jay" +#line 3551 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop]; yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location); @@ -6567,7 +6550,7 @@ void case_492() } void case_493() -#line 3574 "cs-parser.jay" +#line 3557 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location), @@ -6575,14 +6558,14 @@ void case_493() } void case_494() -#line 3580 "cs-parser.jay" +#line 3563 "cs-parser.jay" { MemberAccess ma = (MemberAccess) yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location); } void case_495() -#line 3585 "cs-parser.jay" +#line 3568 "cs-parser.jay" { report.Error (746, lexer.Location, "Invalid anonymous type member declarator. Anonymous type members must be a member assignment, simple name or member access expression"); @@ -6590,28 +6573,28 @@ void case_495() } void case_499() -#line 3600 "cs-parser.jay" +#line 3583 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_500() -#line 3608 "cs-parser.jay" +#line 3591 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension (1, GetLocation (yyVals[-1+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_501() -#line 3613 "cs-parser.jay" +#line 3596 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension ((int)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_506() -#line 3643 "cs-parser.jay" +#line 3626 "cs-parser.jay" { var ai = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop])); ai.VariableDeclaration = current_variable; @@ -6620,7 +6603,7 @@ void case_506() } void case_507() -#line 3650 "cs-parser.jay" +#line 3633 "cs-parser.jay" { var ai = new ArrayInitializer ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); ai.VariableDeclaration = current_variable; @@ -6633,7 +6616,7 @@ void case_507() } void case_508() -#line 3664 "cs-parser.jay" +#line 3647 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); @@ -6641,7 +6624,7 @@ void case_508() } void case_509() -#line 3670 "cs-parser.jay" +#line 3653 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6650,7 +6633,7 @@ void case_509() } void case_511() -#line 3684 "cs-parser.jay" +#line 3667 "cs-parser.jay" { lexer.TypeOfParsing = false; yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -6658,14 +6641,14 @@ void case_511() } void case_514() -#line 3695 "cs-parser.jay" +#line 3678 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } void case_515() -#line 3703 "cs-parser.jay" +#line 3686 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6673,7 +6656,7 @@ void case_515() } void case_516() -#line 3709 "cs-parser.jay" +#line 3692 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6683,7 +6666,7 @@ void case_516() } void case_517() -#line 3717 "cs-parser.jay" +#line 3700 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -6693,7 +6676,7 @@ void case_517() } void case_518() -#line 3725 "cs-parser.jay" +#line 3708 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6703,7 +6686,7 @@ void case_518() } void case_519() -#line 3733 "cs-parser.jay" +#line 3716 "cs-parser.jay" { var tne = (ATypeNameExpression) yyVals[-3+yyTop]; if (tne.HasTypeArguments) @@ -6716,7 +6699,7 @@ void case_519() } void case_520() -#line 3747 "cs-parser.jay" +#line 3730 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); @@ -6725,7 +6708,7 @@ void case_520() } void case_521() -#line 3757 "cs-parser.jay" +#line 3740 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; if (lang_version == LanguageVersion.ISO_1) @@ -6735,35 +6718,35 @@ void case_521() } void case_522() -#line 3768 "cs-parser.jay" +#line 3751 "cs-parser.jay" { yyVal = new SizeOf ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_523() -#line 3776 "cs-parser.jay" +#line 3759 "cs-parser.jay" { yyVal = new CheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_524() -#line 3784 "cs-parser.jay" +#line 3767 "cs-parser.jay" { yyVal = new UnCheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_525() -#line 3792 "cs-parser.jay" +#line 3775 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberAccess (new Indirection ((Expression) yyVals[-3+yyTop], GetLocation (yyVals[-2+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location); } void case_527() -#line 3804 "cs-parser.jay" +#line 3787 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); if ((ParametersCompiled) yyVals[-2+yyTop] != ParametersCompiled.Undefined) { @@ -6774,7 +6757,7 @@ void case_527() } void case_529() -#line 3817 "cs-parser.jay" +#line 3800 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); @@ -6786,7 +6769,7 @@ void case_529() } void case_533() -#line 3842 "cs-parser.jay" +#line 3825 "cs-parser.jay" { valid_param_mod = 0; yyVal = yyVals[-1+yyTop]; @@ -6795,7 +6778,7 @@ void case_533() } void case_534() -#line 3852 "cs-parser.jay" +#line 3835 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); @@ -6805,14 +6788,14 @@ void case_534() } void case_538() -#line 3872 "cs-parser.jay" +#line 3855 "cs-parser.jay" { yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_539() -#line 3877 "cs-parser.jay" +#line 3860 "cs-parser.jay" { if (!async_block) { report.Error (1992, GetLocation (yyVals[-1+yyTop]), @@ -6825,133 +6808,133 @@ void case_539() } void case_548() -#line 3924 "cs-parser.jay" +#line 3907 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_549() -#line 3929 "cs-parser.jay" +#line 3912 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_550() -#line 3934 "cs-parser.jay" +#line 3917 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_552() -#line 3943 "cs-parser.jay" +#line 3926 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_554() -#line 3952 "cs-parser.jay" +#line 3935 "cs-parser.jay" { /* Shift/Reduce conflict*/ yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_558() -#line 3969 "cs-parser.jay" +#line 3952 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_559() -#line 3974 "cs-parser.jay" +#line 3957 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_561() -#line 3983 "cs-parser.jay" +#line 3966 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_562() -#line 3988 "cs-parser.jay" +#line 3971 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_563() -#line 3993 "cs-parser.jay" +#line 3976 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_564() -#line 3998 "cs-parser.jay" +#line 3981 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_566() -#line 4007 "cs-parser.jay" +#line 3990 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Equality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_567() -#line 4012 "cs-parser.jay" +#line 3995 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Inequality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_569() -#line 4021 "cs-parser.jay" +#line 4004 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_571() -#line 4030 "cs-parser.jay" +#line 4013 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_573() -#line 4039 "cs-parser.jay" +#line 4022 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_575() -#line 4048 "cs-parser.jay" +#line 4031 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_577() -#line 4057 "cs-parser.jay" +#line 4040 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_579() -#line 4066 "cs-parser.jay" +#line 4049 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); @@ -6960,84 +6943,84 @@ void case_579() } void case_581() -#line 4077 "cs-parser.jay" +#line 4060 "cs-parser.jay" { yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-4+yyTop]), (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_583() -#line 4089 "cs-parser.jay" +#line 4072 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_584() -#line 4094 "cs-parser.jay" +#line 4077 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_585() -#line 4099 "cs-parser.jay" +#line 4082 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_586() -#line 4104 "cs-parser.jay" +#line 4087 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_587() -#line 4109 "cs-parser.jay" +#line 4092 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_588() -#line 4114 "cs-parser.jay" +#line 4097 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_589() -#line 4119 "cs-parser.jay" +#line 4102 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_590() -#line 4124 "cs-parser.jay" +#line 4107 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_591() -#line 4129 "cs-parser.jay" +#line 4112 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_592() -#line 4134 "cs-parser.jay" +#line 4117 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } void case_593() -#line 4142 "cs-parser.jay" +#line 4125 "cs-parser.jay" { var pars = new List (4); pars.Add ((Parameter) yyVals[0+yyTop]); @@ -7046,7 +7029,7 @@ void case_593() } void case_594() -#line 4149 "cs-parser.jay" +#line 4132 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter)yyVals[0+yyTop]; @@ -7061,7 +7044,7 @@ void case_594() } void case_595() -#line 4165 "cs-parser.jay" +#line 4148 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -7069,7 +7052,7 @@ void case_595() } void case_596() -#line 4171 "cs-parser.jay" +#line 4154 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -7077,14 +7060,14 @@ void case_596() } void case_597() -#line 4177 "cs-parser.jay" +#line 4160 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location); } void case_599() -#line 4185 "cs-parser.jay" +#line 4168 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); @@ -7092,7 +7075,7 @@ void case_599() } void case_603() -#line 4202 "cs-parser.jay" +#line 4185 "cs-parser.jay" { Block b = end_block (lexer.Location); b.IsCompilerGenerated = true; @@ -7101,14 +7084,14 @@ void case_603() } void case_605() -#line 4213 "cs-parser.jay" +#line 4196 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = EmptyExpression.Null; } void case_606() -#line 4221 "cs-parser.jay" +#line 4204 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); @@ -7116,14 +7099,14 @@ void case_606() } void case_607() -#line 4227 "cs-parser.jay" +#line 4210 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } void case_608() -#line 4232 "cs-parser.jay" +#line 4215 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); @@ -7131,63 +7114,63 @@ void case_608() } void case_609() -#line 4238 "cs-parser.jay" +#line 4221 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_611() -#line 4247 "cs-parser.jay" +#line 4230 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], false, GetLocation (yyVals[-4+yyTop])); } void case_612() -#line 4252 "cs-parser.jay" +#line 4235 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_614() -#line 4261 "cs-parser.jay" +#line 4244 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], true, GetLocation (yyVals[-5+yyTop])); } void case_615() -#line 4266 "cs-parser.jay" +#line 4249 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_622() -#line 4289 "cs-parser.jay" +#line 4272 "cs-parser.jay" { yyVal = new RefValueExpr ((Expression) yyVals[-3+yyTop], (FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_623() -#line 4294 "cs-parser.jay" +#line 4277 "cs-parser.jay" { yyVal = new RefTypeExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_624() -#line 4299 "cs-parser.jay" +#line 4282 "cs-parser.jay" { yyVal = new MakeRefExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_628() -#line 4328 "cs-parser.jay" +#line 4311 "cs-parser.jay" { MemberName name = MakeName ((MemberName) yyVals[0+yyTop]); Class c = new Class (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]); @@ -7196,15 +7179,16 @@ void case_628() } push_current_class (c, yyVals[-3+yyTop]); - lbag.AddMember (current_class, GetModifierLocations (), GetLocation (yyVals[-2+yyTop])); } void case_629() -#line 4340 "cs-parser.jay" +#line 4322 "cs-parser.jay" { lexer.ConstraintsParsing = false; - current_class.SetParameterInfo ((List) yyVals[0+yyTop]); + if (yyVals[0+yyTop] != null) + current_class.SetConstraints ((List) yyVals[0+yyTop]); + lbag.AddMember (current_class, GetModifierLocations (), GetLocation (yyVals[-5+yyTop])); if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); @@ -7215,7 +7199,7 @@ void case_629() } void case_630() -#line 4353 "cs-parser.jay" +#line 4337 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -7223,7 +7207,7 @@ void case_630() } void case_631() -#line 4359 "cs-parser.jay" +#line 4343 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); if (yyVals[0+yyTop] != null) @@ -7232,7 +7216,7 @@ void case_631() } void case_634() -#line 4376 "cs-parser.jay" +#line 4360 "cs-parser.jay" { mod_locations = null; yyVal = ModifierNone; @@ -7240,7 +7224,7 @@ void case_634() } void case_637() -#line 4390 "cs-parser.jay" +#line 4374 "cs-parser.jay" { var m1 = (Modifiers) yyVals[-1+yyTop]; var m2 = (Modifiers) yyVals[0+yyTop]; @@ -7258,7 +7242,7 @@ void case_637() } void case_638() -#line 4409 "cs-parser.jay" +#line 4393 "cs-parser.jay" { yyVal = Modifiers.NEW; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7268,91 +7252,91 @@ void case_638() } void case_639() -#line 4417 "cs-parser.jay" +#line 4401 "cs-parser.jay" { yyVal = Modifiers.PUBLIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_640() -#line 4422 "cs-parser.jay" +#line 4406 "cs-parser.jay" { yyVal = Modifiers.PROTECTED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_641() -#line 4427 "cs-parser.jay" +#line 4411 "cs-parser.jay" { yyVal = Modifiers.INTERNAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_642() -#line 4432 "cs-parser.jay" +#line 4416 "cs-parser.jay" { yyVal = Modifiers.PRIVATE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_643() -#line 4437 "cs-parser.jay" +#line 4421 "cs-parser.jay" { yyVal = Modifiers.ABSTRACT; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_644() -#line 4442 "cs-parser.jay" +#line 4426 "cs-parser.jay" { yyVal = Modifiers.SEALED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_645() -#line 4447 "cs-parser.jay" +#line 4431 "cs-parser.jay" { yyVal = Modifiers.STATIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_646() -#line 4452 "cs-parser.jay" +#line 4436 "cs-parser.jay" { yyVal = Modifiers.READONLY; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_647() -#line 4457 "cs-parser.jay" +#line 4441 "cs-parser.jay" { yyVal = Modifiers.VIRTUAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_648() -#line 4462 "cs-parser.jay" +#line 4446 "cs-parser.jay" { yyVal = Modifiers.OVERRIDE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_649() -#line 4467 "cs-parser.jay" +#line 4451 "cs-parser.jay" { yyVal = Modifiers.EXTERN; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_650() -#line 4472 "cs-parser.jay" +#line 4456 "cs-parser.jay" { yyVal = Modifiers.VOLATILE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_651() -#line 4477 "cs-parser.jay" +#line 4461 "cs-parser.jay" { yyVal = Modifiers.UNSAFE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7361,28 +7345,28 @@ void case_651() } void case_652() -#line 4484 "cs-parser.jay" +#line 4468 "cs-parser.jay" { yyVal = Modifiers.ASYNC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_654() -#line 4493 "cs-parser.jay" +#line 4477 "cs-parser.jay" { lbag.AppendToMember (current_class, GetLocation (yyVals[-1+yyTop])); current_container.AddBasesForPart (current_class, (List) yyVals[0+yyTop]); } void case_657() -#line 4506 "cs-parser.jay" +#line 4490 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_658() -#line 4514 "cs-parser.jay" +#line 4498 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((Constraints) yyVals[0+yyTop]); @@ -7390,7 +7374,7 @@ void case_658() } void case_659() -#line 4520 "cs-parser.jay" +#line 4504 "cs-parser.jay" { var constraints = (List) yyVals[-1+yyTop]; Constraints new_constraint = (Constraints)yyVals[0+yyTop]; @@ -7408,7 +7392,7 @@ void case_659() } void case_660() -#line 4539 "cs-parser.jay" +#line 4523 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); @@ -7416,7 +7400,7 @@ void case_660() } void case_661() -#line 4548 "cs-parser.jay" +#line 4532 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -7424,7 +7408,7 @@ void case_661() } void case_662() -#line 4554 "cs-parser.jay" +#line 4538 "cs-parser.jay" { var constraints = (List) yyVals[-2+yyTop]; var prev = constraints [constraints.Count - 1] as SpecialContraintExpr; @@ -7450,7 +7434,7 @@ void case_662() } void case_663() -#line 4581 "cs-parser.jay" +#line 4565 "cs-parser.jay" { if (yyVals[0+yyTop] is ComposedCast) report.Error (706, GetLocation (yyVals[0+yyTop]), "Invalid constraint type `{0}'", ((ComposedCast)yyVals[0+yyTop]).GetSignatureForError ()); @@ -7459,72 +7443,72 @@ void case_663() } void case_664() -#line 4588 "cs-parser.jay" +#line 4572 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Constructor, GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_668() -#line 4608 "cs-parser.jay" +#line 4592 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (lexer.Location, "generic type variance"); - + yyVal = yyVals[0+yyTop]; } void case_669() -#line 4618 "cs-parser.jay" +#line 4602 "cs-parser.jay" { yyVal = Variance.Covariant; savedLocation = GetLocation (yyVals[0+yyTop]); } void case_670() -#line 4623 "cs-parser.jay" +#line 4607 "cs-parser.jay" { yyVal = Variance.Contravariant; savedLocation = GetLocation (yyVals[0+yyTop]); } void case_671() -#line 4644 "cs-parser.jay" +#line 4628 "cs-parser.jay" { ++lexer.parsing_block; start_block (GetLocation (yyVals[0+yyTop])); } void case_673() -#line 4656 "cs-parser.jay" +#line 4640 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } void case_674() -#line 4661 "cs-parser.jay" +#line 4645 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (lexer.Location); } void case_675() -#line 4670 "cs-parser.jay" +#line 4654 "cs-parser.jay" { ++lexer.parsing_block; current_block.StartLocation = GetLocation (yyVals[0+yyTop]); } void case_676() -#line 4675 "cs-parser.jay" +#line 4659 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } void case_684() -#line 4703 "cs-parser.jay" +#line 4687 "cs-parser.jay" { Error_SyntaxError (yyToken); var lt =(Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -7534,42 +7518,42 @@ void case_684() } void case_685() -#line 4712 "cs-parser.jay" +#line 4696 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_718() -#line 4776 "cs-parser.jay" +#line 4760 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } void case_719() -#line 4781 "cs-parser.jay" +#line 4765 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } void case_720() -#line 4786 "cs-parser.jay" +#line 4770 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } void case_721() -#line 4794 "cs-parser.jay" +#line 4778 "cs-parser.jay" { /* Uses lexer.Location because semicolon location is not kept in quick mode*/ yyVal = new EmptyStatement (lexer.Location); } void case_722() -#line 4802 "cs-parser.jay" +#line 4786 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location); @@ -7579,7 +7563,7 @@ void case_722() } void case_725() -#line 4815 "cs-parser.jay" +#line 4799 "cs-parser.jay" { if (yyVals[-1+yyTop] is VarExpr) yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location); @@ -7588,7 +7572,7 @@ void case_725() } void case_726() -#line 4831 "cs-parser.jay" +#line 4815 "cs-parser.jay" { /* Ok, the above "primary_expression" is there to get rid of*/ /* both reduce/reduce and shift/reduces in the grammar, it should*/ @@ -7620,7 +7604,7 @@ void case_726() } void case_727() -#line 4861 "cs-parser.jay" +#line 4845 "cs-parser.jay" { ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression; @@ -7633,7 +7617,7 @@ void case_727() } void case_728() -#line 4872 "cs-parser.jay" +#line 4856 "cs-parser.jay" { if (yyVals[0+yyTop] == null) yyVal = yyVals[-1+yyTop]; @@ -7642,21 +7626,21 @@ void case_728() } void case_731() -#line 4887 "cs-parser.jay" +#line 4871 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } void case_733() -#line 4896 "cs-parser.jay" +#line 4880 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_736() -#line 4912 "cs-parser.jay" +#line 4896 "cs-parser.jay" { if (async_block) { report.Error (4003, GetLocation (yyVals[0+yyTop]), "`await' cannot be used as an identifier within an async method or lambda expression"); @@ -7665,7 +7649,7 @@ void case_736() } void case_737() -#line 4922 "cs-parser.jay" +#line 4906 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7674,7 +7658,7 @@ void case_737() } void case_738() -#line 4929 "cs-parser.jay" +#line 4913 "cs-parser.jay" { yyVal = current_variable; current_variable = null; @@ -7682,7 +7666,7 @@ void case_738() } void case_739() -#line 4935 "cs-parser.jay" +#line 4919 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7691,7 +7675,7 @@ void case_739() } void case_740() -#line 4942 "cs-parser.jay" +#line 4926 "cs-parser.jay" { if (current_variable.Initializer != null) { lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); @@ -7703,14 +7687,14 @@ void case_740() } void case_742() -#line 4956 "cs-parser.jay" +#line 4940 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } void case_743() -#line 4961 "cs-parser.jay" +#line 4945 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7726,7 +7710,7 @@ void case_743() } void case_744() -#line 4975 "cs-parser.jay" +#line 4959 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7737,7 +7721,7 @@ void case_744() } void case_748() -#line 4993 "cs-parser.jay" +#line 4977 "cs-parser.jay" { foreach (var d in current_variable.Declarators) { if (d.Initializer == null) @@ -7746,7 +7730,7 @@ void case_748() } void case_751() -#line 5008 "cs-parser.jay" +#line 4992 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7757,7 +7741,7 @@ void case_751() } void case_752() -#line 5017 "cs-parser.jay" +#line 5001 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7768,14 +7752,14 @@ void case_752() } void case_754() -#line 5033 "cs-parser.jay" +#line 5017 "cs-parser.jay" { savedLocation = GetLocation (yyVals[-1+yyTop]); current_variable.Initializer = (Expression) yyVals[0+yyTop]; } void case_759() -#line 5051 "cs-parser.jay" +#line 5035 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7786,28 +7770,28 @@ void case_759() } void case_761() -#line 5064 "cs-parser.jay" +#line 5048 "cs-parser.jay" { yyVal = new StackAlloc ((Expression) yyVals[-3+yyTop], (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_762() -#line 5069 "cs-parser.jay" +#line 5053 "cs-parser.jay" { report.Error (1575, GetLocation (yyVals[-1+yyTop]), "A stackalloc expression requires [] after type"); yyVal = new StackAlloc ((Expression) yyVals[0+yyTop], null, GetLocation (yyVals[-1+yyTop])); } void case_763() -#line 5077 "cs-parser.jay" +#line 5061 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_767() -#line 5095 "cs-parser.jay" +#line 5079 "cs-parser.jay" { ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement; if (s == null) { @@ -7819,7 +7803,7 @@ void case_767() } void case_768() -#line 5108 "cs-parser.jay" +#line 5092 "cs-parser.jay" { Expression expr = (Expression) yyVals[0+yyTop]; ExpressionStatement s; @@ -7829,14 +7813,14 @@ void case_768() } void case_769() -#line 5116 "cs-parser.jay" +#line 5100 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } void case_772() -#line 5130 "cs-parser.jay" +#line 5114 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7846,7 +7830,7 @@ void case_772() } void case_773() -#line 5139 "cs-parser.jay" +#line 5123 "cs-parser.jay" { yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); @@ -7858,7 +7842,7 @@ void case_773() } void case_774() -#line 5149 "cs-parser.jay" +#line 5133 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7867,7 +7851,7 @@ void case_774() } void case_776() -#line 5163 "cs-parser.jay" +#line 5147 "cs-parser.jay" { yyVal = new Switch ((Expression) yyVals[-5+yyTop], (ExplicitBlock) current_block.Explicit, (List) yyVals[-1+yyTop], GetLocation (yyVals[-7+yyTop])); end_block (GetLocation (yyVals[0+yyTop])); @@ -7875,7 +7859,7 @@ void case_776() } void case_777() -#line 5169 "cs-parser.jay" +#line 5153 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7884,14 +7868,14 @@ void case_777() } void case_778() -#line 5179 "cs-parser.jay" +#line 5163 "cs-parser.jay" { report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); yyVal = new List (); } void case_780() -#line 5188 "cs-parser.jay" +#line 5172 "cs-parser.jay" { var sections = new List (4); @@ -7900,7 +7884,7 @@ void case_780() } void case_781() -#line 5195 "cs-parser.jay" +#line 5179 "cs-parser.jay" { var sections = (List) yyVals[-1+yyTop]; @@ -7909,14 +7893,14 @@ void case_781() } void case_782() -#line 5202 "cs-parser.jay" +#line 5186 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new List (); } void case_785() -#line 5221 "cs-parser.jay" +#line 5205 "cs-parser.jay" { var labels = new List (2); @@ -7925,7 +7909,7 @@ void case_785() } void case_786() -#line 5228 "cs-parser.jay" +#line 5212 "cs-parser.jay" { var labels = (List) (yyVals[-1+yyTop]); labels.Add ((SwitchLabel) yyVals[0+yyTop]); @@ -7934,14 +7918,14 @@ void case_786() } void case_787() -#line 5238 "cs-parser.jay" +#line 5222 "cs-parser.jay" { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_793() -#line 5257 "cs-parser.jay" +#line 5241 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7951,7 +7935,7 @@ void case_793() } void case_794() -#line 5265 "cs-parser.jay" +#line 5249 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7960,21 +7944,21 @@ void case_794() } void case_795() -#line 5275 "cs-parser.jay" +#line 5259 "cs-parser.jay" { yyVal = new Do ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-2+yyTop], GetLocation (yyVals[-6+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_796() -#line 5280 "cs-parser.jay" +#line 5264 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Do ((Statement) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } void case_797() -#line 5285 "cs-parser.jay" +#line 5269 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7983,7 +7967,7 @@ void case_797() } void case_798() -#line 5295 "cs-parser.jay" +#line 5279 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); current_block.IsCompilerGenerated = true; @@ -7993,7 +7977,7 @@ void case_798() } void case_803() -#line 5323 "cs-parser.jay" +#line 5307 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8006,14 +7990,14 @@ void case_803() } void case_804() -#line 5334 "cs-parser.jay" +#line 5318 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = end_block (current_block.StartLocation); } void case_807() -#line 5347 "cs-parser.jay" +#line 5331 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -8022,14 +8006,14 @@ void case_807() } void case_808() -#line 5354 "cs-parser.jay" +#line 5338 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_816() -#line 5378 "cs-parser.jay" +#line 5362 "cs-parser.jay" { var sl = yyVals[-2+yyTop] as StatementList; if (sl == null) { @@ -8044,7 +8028,7 @@ void case_816() } void case_817() -#line 5394 "cs-parser.jay" +#line 5378 "cs-parser.jay" { report.Error (230, GetLocation (yyVals[-3+yyTop]), "Type and identifier are both required in a foreach statement"); @@ -8059,7 +8043,7 @@ void case_817() } void case_818() -#line 5407 "cs-parser.jay" +#line 5391 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8078,7 +8062,7 @@ void case_818() } void case_819() -#line 5424 "cs-parser.jay" +#line 5408 "cs-parser.jay" { start_block (GetLocation (yyVals[-5+yyTop])); current_block.IsCompilerGenerated = true; @@ -8089,7 +8073,7 @@ void case_819() } void case_820() -#line 5433 "cs-parser.jay" +#line 5417 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8102,7 +8086,7 @@ void case_820() } void case_821() -#line 5444 "cs-parser.jay" +#line 5428 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); current_block.IsCompilerGenerated = true; @@ -8117,7 +8101,7 @@ void case_821() } void case_822() -#line 5457 "cs-parser.jay" +#line 5441 "cs-parser.jay" { Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, GetLocation (yyVals[-3+yyTop])); current_block.AddStatement (f); @@ -8127,21 +8111,21 @@ void case_822() } void case_829() -#line 5477 "cs-parser.jay" +#line 5461 "cs-parser.jay" { yyVal = new Break (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_830() -#line 5485 "cs-parser.jay" +#line 5469 "cs-parser.jay" { yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_831() -#line 5493 "cs-parser.jay" +#line 5477 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new Goto (lt.Value, GetLocation (yyVals[-2+yyTop])); @@ -8149,35 +8133,35 @@ void case_831() } void case_832() -#line 5499 "cs-parser.jay" +#line 5483 "cs-parser.jay" { yyVal = new GotoCase ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_833() -#line 5504 "cs-parser.jay" +#line 5488 "cs-parser.jay" { yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_834() -#line 5512 "cs-parser.jay" +#line 5496 "cs-parser.jay" { yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_835() -#line 5520 "cs-parser.jay" +#line 5504 "cs-parser.jay" { yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } void case_836() -#line 5528 "cs-parser.jay" +#line 5512 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; string s = lt.Value; @@ -8195,7 +8179,7 @@ void case_836() } void case_837() -#line 5544 "cs-parser.jay" +#line 5528 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -8211,28 +8195,28 @@ void case_837() } void case_841() -#line 5570 "cs-parser.jay" +#line 5554 "cs-parser.jay" { yyVal = new TryFinally ((Statement) yyVals[-2+yyTop], (Block) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_842() -#line 5575 "cs-parser.jay" +#line 5559 "cs-parser.jay" { yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]), true), (Block) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_843() -#line 5580 "cs-parser.jay" +#line 5564 "cs-parser.jay" { Error_SyntaxError (1524, yyToken); yyVal = new TryCatch ((Block) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]), false); } void case_844() -#line 5588 "cs-parser.jay" +#line 5572 "cs-parser.jay" { var l = new List (2); @@ -8241,7 +8225,7 @@ void case_844() } void case_845() -#line 5595 "cs-parser.jay" +#line 5579 "cs-parser.jay" { var l = (List) yyVals[-1+yyTop]; @@ -8255,7 +8239,7 @@ void case_845() } void case_849() -#line 5619 "cs-parser.jay" +#line 5603 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop])); @@ -8272,7 +8256,7 @@ void case_849() } void case_851() -#line 5638 "cs-parser.jay" +#line 5622 "cs-parser.jay" { if (yyToken == Token.CLOSE_PARENS) { report.Error (1015, lexer.Location, @@ -8285,14 +8269,14 @@ void case_851() } void case_854() -#line 5666 "cs-parser.jay" +#line 5650 "cs-parser.jay" { if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } void case_856() -#line 5676 "cs-parser.jay" +#line 5660 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8302,7 +8286,7 @@ void case_856() } void case_857() -#line 5684 "cs-parser.jay" +#line 5668 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8311,7 +8295,7 @@ void case_857() } void case_858() -#line 5694 "cs-parser.jay" +#line 5678 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8323,14 +8307,14 @@ void case_858() } void case_859() -#line 5704 "cs-parser.jay" +#line 5688 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_860() -#line 5709 "cs-parser.jay" +#line 5693 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8342,7 +8326,7 @@ void case_860() } void case_861() -#line 5722 "cs-parser.jay" +#line 5706 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8354,14 +8338,14 @@ void case_861() } void case_862() -#line 5732 "cs-parser.jay" +#line 5716 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } void case_863() -#line 5737 "cs-parser.jay" +#line 5721 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8373,7 +8357,7 @@ void case_863() } void case_864() -#line 5747 "cs-parser.jay" +#line 5731 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8383,7 +8367,7 @@ void case_864() } void case_865() -#line 5755 "cs-parser.jay" +#line 5739 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8392,14 +8376,14 @@ void case_865() } void case_867() -#line 5766 "cs-parser.jay" +#line 5750 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); } void case_869() -#line 5778 "cs-parser.jay" +#line 5762 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); @@ -8407,7 +8391,7 @@ void case_869() } void case_870() -#line 5790 "cs-parser.jay" +#line 5774 "cs-parser.jay" { lexer.query_parsing = false; @@ -8421,7 +8405,7 @@ void case_870() } void case_871() -#line 5802 "cs-parser.jay" +#line 5786 "cs-parser.jay" { Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause; @@ -8433,7 +8417,7 @@ void case_871() } void case_872() -#line 5813 "cs-parser.jay" +#line 5797 "cs-parser.jay" { lexer.query_parsing = false; yyVal = yyVals[-1+yyTop]; @@ -8443,7 +8427,7 @@ void case_872() } void case_873() -#line 5820 "cs-parser.jay" +#line 5804 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; current_block.SetEndLocation (lexer.Location); @@ -8451,7 +8435,7 @@ void case_873() } void case_874() -#line 5829 "cs-parser.jay" +#line 5813 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8461,7 +8445,7 @@ void case_874() } void case_875() -#line 5837 "cs-parser.jay" +#line 5821 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8475,7 +8459,7 @@ void case_875() } void case_876() -#line 5852 "cs-parser.jay" +#line 5836 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8485,7 +8469,7 @@ void case_876() } void case_877() -#line 5860 "cs-parser.jay" +#line 5844 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8499,7 +8483,7 @@ void case_877() } void case_879() -#line 5879 "cs-parser.jay" +#line 5863 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8512,7 +8496,7 @@ void case_879() } void case_881() -#line 5894 "cs-parser.jay" +#line 5878 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8528,7 +8512,7 @@ void case_881() } void case_882() -#line 5911 "cs-parser.jay" +#line 5895 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop]; @@ -8545,14 +8529,14 @@ void case_882() } void case_884() -#line 5927 "cs-parser.jay" +#line 5911 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_886() -#line 5939 "cs-parser.jay" +#line 5923 "cs-parser.jay" { yyVal = new Linq.Select ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8561,7 +8545,7 @@ void case_886() } void case_887() -#line 5946 "cs-parser.jay" +#line 5930 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8571,7 +8555,7 @@ void case_887() } void case_888() -#line 5954 "cs-parser.jay" +#line 5938 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8580,7 +8564,7 @@ void case_888() } void case_889() -#line 5961 "cs-parser.jay" +#line 5945 "cs-parser.jay" { yyVal = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)yyVals[-3+yyTop], linq_clause_blocks.Pop (), (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); @@ -8590,14 +8574,14 @@ void case_889() } void case_893() -#line 5978 "cs-parser.jay" +#line 5962 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } void case_900() -#line 5998 "cs-parser.jay" +#line 5982 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8611,7 +8595,7 @@ void case_900() } void case_902() -#line 6017 "cs-parser.jay" +#line 6001 "cs-parser.jay" { yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8620,7 +8604,7 @@ void case_902() } void case_903() -#line 6027 "cs-parser.jay" +#line 6011 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8630,7 +8614,7 @@ void case_903() } void case_904() -#line 6035 "cs-parser.jay" +#line 6019 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8640,7 +8624,7 @@ void case_904() } void case_905() -#line 6043 "cs-parser.jay" +#line 6027 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8650,7 +8634,7 @@ void case_905() } void case_906() -#line 6051 "cs-parser.jay" +#line 6035 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8690,7 +8674,7 @@ void case_906() } void case_907() -#line 6089 "cs-parser.jay" +#line 6073 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8700,7 +8684,7 @@ void case_907() } void case_908() -#line 6097 "cs-parser.jay" +#line 6081 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8710,7 +8694,7 @@ void case_908() } void case_909() -#line 6105 "cs-parser.jay" +#line 6089 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8720,7 +8704,7 @@ void case_909() } void case_910() -#line 6113 "cs-parser.jay" +#line 6097 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8762,7 +8746,7 @@ void case_910() } void case_914() -#line 6168 "cs-parser.jay" +#line 6152 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8771,7 +8755,7 @@ void case_914() } void case_916() -#line 6179 "cs-parser.jay" +#line 6163 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8780,14 +8764,14 @@ void case_916() } void case_917() -#line 6186 "cs-parser.jay" +#line 6170 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } void case_919() -#line 6195 "cs-parser.jay" +#line 6179 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8796,42 +8780,42 @@ void case_919() } void case_920() -#line 6202 "cs-parser.jay" +#line 6186 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } void case_922() -#line 6214 "cs-parser.jay" +#line 6198 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_923() -#line 6219 "cs-parser.jay" +#line 6203 "cs-parser.jay" { yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_925() -#line 6231 "cs-parser.jay" +#line 6215 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_926() -#line 6236 "cs-parser.jay" +#line 6220 "cs-parser.jay" { yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } void case_928() -#line 6246 "cs-parser.jay" +#line 6230 "cs-parser.jay" { /* query continuation block is not linked with query block but with block*/ /* before. This means each query can use same range variable names for*/ @@ -8849,7 +8833,7 @@ void case_928() } void case_929() -#line 6262 "cs-parser.jay" +#line 6246 "cs-parser.jay" { var current_block = linq_clause_blocks.Pop (); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -8860,7 +8844,7 @@ void case_929() } void case_932() -#line 6289 "cs-parser.jay" +#line 6273 "cs-parser.jay" { current_container = new Class (current_namespace, current_class, new MemberName (""), Modifiers.PUBLIC, null); current_class = current_container; @@ -8877,7 +8861,6 @@ void case_932() current_local_parameters = pars; Method method = new Method ( current_class, - null, /* generic*/ new TypeExpression (compiler.BuiltinTypes.Void, Location.Null), mods, new MemberName ("Host"), @@ -8892,7 +8875,7 @@ void case_932() } void case_933() -#line 6319 "cs-parser.jay" +#line 6302 "cs-parser.jay" { --lexer.parsing_block; Method method = (Method) oob_stack.Pop (); @@ -8904,7 +8887,7 @@ void case_933() } void case_943() -#line 6362 "cs-parser.jay" +#line 6345 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -8912,7 +8895,7 @@ void case_943() } void case_944() -#line 6368 "cs-parser.jay" +#line 6351 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -8921,14 +8904,14 @@ void case_944() } void case_947() -#line 6383 "cs-parser.jay" +#line 6366 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], MemberCache.IndexerNameAlias, Location.Null); } void case_948() -#line 6388 "cs-parser.jay" +#line 6371 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8938,7 +8921,7 @@ void case_948() } void case_949() -#line 6396 "cs-parser.jay" +#line 6379 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8948,7 +8931,7 @@ void case_949() } void case_950() -#line 6404 "cs-parser.jay" +#line 6387 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); module.DocumentationBuilder.ParsedParameters = p; @@ -8957,7 +8940,7 @@ void case_950() } void case_958() -#line 6442 "cs-parser.jay" +#line 6425 "cs-parser.jay" { var parameters = new List (); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); @@ -8965,7 +8948,7 @@ void case_958() } void case_959() -#line 6448 "cs-parser.jay" +#line 6431 "cs-parser.jay" { var parameters = yyVals[-2+yyTop] as List; parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); @@ -8973,7 +8956,7 @@ void case_959() } void case_960() -#line 6457 "cs-parser.jay" +#line 6440 "cs-parser.jay" { if (yyVals[-1+yyTop] != null) yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]); @@ -12368,7 +12351,7 @@ void case_960() -1, -1, -1, -1, -1, -1, -1, -1, -1, 362, }; -#line 6466 "cs-parser.jay" +#line 6449 "cs-parser.jay" // // A class used to hold info about an operator declarator @@ -12451,9 +12434,9 @@ void push_current_class (TypeContainer tc, object partial_token) ubag.PushTypeDeclaration (tc); } -DeclSpace pop_current_class () +TypeContainer pop_current_class () { - DeclSpace retval = current_class; + var retval = current_class; current_class = current_class.Parent; current_container = current_class.PartialContainer; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay index c13a9bb0ff..3c49f3270e 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay @@ -47,7 +47,7 @@ namespace Mono.CSharp NamespaceContainer current_namespace; TypeContainer current_container; - DeclSpace current_class; + TypeContainer current_class; PropertyBase current_property; EventProperty current_event; EventField current_event_field; @@ -946,7 +946,8 @@ struct_declaration { lexer.ConstraintsParsing = false; - current_class.SetParameterInfo ((List) $9); + if ($9 != null) + current_class.SetConstraints ((List) $9); if (doc_support) current_container.DocComment = Lexer.consume_doc_comment (); @@ -1284,19 +1285,11 @@ method_header MemberName name = (MemberName) $4; current_local_parameters = (ParametersCompiled) $7; - GenericMethod generic = null; - if (name.TypeParameters != null) { - generic = new GenericMethod (current_namespace, current_class, name, - (FullNamedExpression) $3, current_local_parameters); - - generic.SetParameterInfo ((List) $10); - } else if ($10 != null) { - report.Error (80, GetLocation ($10), - "Constraints are not allowed on non-generic declarations"); - } - - var method = Method.Create (current_class, generic, (FullNamedExpression) $3, (Modifiers) $2, + var method = Method.Create (current_class, (FullNamedExpression) $3, (Modifiers) $2, name, current_local_parameters, (Attributes) $1, $10 != null); + + if ($10 != null) + method.SetConstraints ((List) $10); if (doc_support) method.DocComment = Lexer.consume_doc_comment (); @@ -1329,25 +1322,15 @@ method_header MemberName name = (MemberName) $6; current_local_parameters = (ParametersCompiled) $9; - if ($11 != null && name.TypeParameters == null) - report.Error (80, lexer.Location, - "Constraints are not allowed on non-generic declarations"); - - GenericMethod generic = null; - if (name.TypeParameters != null) { - generic = new GenericMethod (current_namespace, current_class, name, - new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)), - current_local_parameters); - - generic.SetParameterInfo ((List) $11); - } - var modifiers = (Modifiers) $2; modifiers |= Modifiers.PARTIAL; - var method = Method.Create (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)), + var method = Method.Create (current_class, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($4)), modifiers, name, current_local_parameters, (Attributes) $1, $11 != null); + if ($11 != null) + method.SetConstraints ((List) $11); + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); @@ -1364,7 +1347,7 @@ method_header report.Error (1585, name.Location, "Member modifier `{0}' must precede the member type and name", ModifiersExtensions.Name ((Modifiers) $4)); - var method = Method.Create (current_class, null, (FullNamedExpression) $3, + var method = Method.Create (current_class, (FullNamedExpression) $3, 0, name, (ParametersCompiled) $7, (Attributes) $1, false); current_local_parameters = (ParametersCompiled) $7; @@ -1919,7 +1902,8 @@ interface_declaration { lexer.ConstraintsParsing = false; - current_class.SetParameterInfo ((List) $9); + if ($9 != null) + current_class.SetConstraints ((List) $9); if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); @@ -2177,8 +2161,6 @@ constructor_declaration if (doc_support) c.DocComment = ConsumeStoredComment (); - current_container.AddConstructor (c); - current_local_parameters = null; if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -2216,6 +2198,7 @@ constructor_declarator } } + current_container.AddConstructor (c); lbag.AddMember (c, GetModifierLocations (), GetLocation ($5), GetLocation ($7)); $$ = c; @@ -2236,7 +2219,6 @@ constructor_declarator "`{0}': static constructor cannot have an explicit `this' or `base' constructor call", c.GetSignatureForError ()); } - lbag.AddMember (c, GetModifierLocations (), GetLocation ($5), GetLocation ($7)); } $$ = $8; @@ -2686,7 +2668,8 @@ delegate_declaration Lexer.doc_state = XmlCommentState.Allowed; } - current_delegate.SetParameterInfo ((List) $11); + if ($11 != null) + current_delegate.SetConstraints ((List) $11); lbag.AddMember (current_delegate, GetModifierLocations (), GetLocation ($3), GetLocation ($6), GetLocation ($9), GetLocation ($13)); $$ = current_delegate; @@ -4333,14 +4316,15 @@ class_declaration } push_current_class (c, $3); - lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($4)); } opt_class_base opt_type_parameter_constraints_clauses { lexer.ConstraintsParsing = false; - current_class.SetParameterInfo ((List) $9); + if ($9 != null) + current_class.SetConstraints ((List) $9); + lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($4)); if (doc_support) { current_container.DocComment = Lexer.consume_doc_comment (); @@ -4608,7 +4592,7 @@ opt_type_parameter_variance { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (lexer.Location, "generic type variance"); - + $$ = $1; } ; @@ -6302,7 +6286,6 @@ interactive_parsing current_local_parameters = pars; Method method = new Method ( current_class, - null, // generic new TypeExpression (compiler.BuiltinTypes.Void, Location.Null), mods, new MemberName ("Host"), @@ -6545,9 +6528,9 @@ void push_current_class (TypeContainer tc, object partial_token) ubag.PushTypeDeclaration (tc); } -DeclSpace pop_current_class () +TypeContainer pop_current_class () { - DeclSpace retval = current_class; + var retval = current_class; current_class = current_class.Parent; current_container = current_class.PartialContainer; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs index 2d36bf18f8..6e2c2d081c 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs @@ -220,20 +220,6 @@ namespace Mono.CSharp { [System.Diagnostics.DebuggerDisplay ("{GetSignatureForError()}")] public abstract class MemberCore : Attributable, IMemberContext, IMemberDefinition { - /// - /// Public name - /// - - protected string cached_name; - // TODO: Remove in favor of MemberName - public string Name { - get { - if (cached_name == null) - cached_name = MemberName.GetName (!(this is GenericMethod) && !(this is Method)); - return cached_name; - } - } - string IMemberDefinition.Name { get { return member_name.Name; @@ -312,9 +298,9 @@ namespace Mono.CSharp { /// internal Flags caching_flags; - public MemberCore (DeclSpace parent, MemberName name, Attributes attrs) + public MemberCore (TypeContainer parent, MemberName name, Attributes attrs) { - this.Parent = parent as TypeContainer; + this.Parent = parent; member_name = name; caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected; AddAttributes (attrs, this); @@ -323,7 +309,6 @@ namespace Mono.CSharp { protected virtual void SetMemberName (MemberName new_name) { member_name = new_name; - cached_name = null; } public virtual void Accept (StructuralVisitor visitor) @@ -467,6 +452,26 @@ namespace Mono.CSharp { caching_flags |= Flags.IsAssigned; } + public void SetConstraints (List constraints_list) + { + var tparams = member_name.TypeParameters; + if (tparams == null) { + Report.Error (80, Location, "Constraints are not allowed on non-generic declarations"); + return; + } + + foreach (var c in constraints_list) { + var tp = tparams.Find (c.TypeParameter.Value); + if (tp == null) { + Report.Error (699, c.Location, "`{0}': A constraint references nonexistent type parameter `{1}'", + GetSignatureForError (), c.TypeParameter.Value); + continue; + } + + tp.Constraints = c; + } + } + /// /// Returns instance of ObsoleteAttribute for this MemberCore /// @@ -640,7 +645,7 @@ namespace Mono.CSharp { if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0) return false; - DeclSpace parentContainer = Parent.PartialContainer; + var parentContainer = Parent.PartialContainer; while (parentContainer != null && parentContainer.ModFlags != 0) { if ((parentContainer.ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0) return false; @@ -769,6 +774,9 @@ namespace Mono.CSharp { Report.Warning (3008, 1, Location, "Identifier `{0}' is not CLS-compliant", GetSignatureForError () ); } + if (member_name.TypeParameters != null) + member_name.TypeParameters.VerifyClsCompliance (); + return true; } @@ -1054,7 +1062,13 @@ namespace Mono.CSharp { public virtual string GetSignatureForError () { var bf = MemberDefinition as Property.BackingField; - var name = bf == null ? Name : bf.OriginalName; + string name; + if (bf == null) { + name = Name; + } else { + name = bf.OriginalProperty.MemberName.Name; + } + return DeclaringType.GetSignatureForError () + "." + name; } @@ -1197,259 +1211,4 @@ namespace Mono.CSharp { { TypeSpec MemberType { get; } } - - // - // Base type container declaration. It exists to handle partial types - // which share same definition (PartialContainer) but have different - // resolve scopes - // - public abstract class DeclSpace : MemberCore { - /// - /// This points to the actual definition that is being - /// created with System.Reflection.Emit - /// - public TypeBuilder TypeBuilder; - - // - // This is the namespace in which this typecontainer - // was declared. We use this to resolve names. - // - public NamespaceContainer NamespaceEntry; - - public readonly string Basename; - - protected Dictionary defined_names; - - public TypeContainer PartialContainer; - - protected readonly bool is_generic; - - // - // Whether we are Generic - // - public bool IsGeneric { - get { - if (is_generic) - return true; - else if (Parent != null) - return Parent.IsGeneric; - else - return false; - } - } - - static readonly string[] attribute_targets = new string [] { "type" }; - - public DeclSpace (NamespaceContainer ns, DeclSpace parent, MemberName name, - Attributes attrs) - : base (parent, name, attrs) - { - NamespaceEntry = ns; - Basename = name.Basename; - defined_names = new Dictionary (); - PartialContainer = null; - if (name.TypeParameters != null) { - is_generic = true; - } - } - - /// - /// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts - /// - protected virtual bool AddToContainer (MemberCore symbol, string name) - { - MemberCore mc; - if (!defined_names.TryGetValue (name, out mc)) { - defined_names.Add (name, symbol); - return true; - } - - if (((mc.ModFlags | symbol.ModFlags) & Modifiers.COMPILER_GENERATED) != 0) - return true; - - if (symbol.EnableOverloadChecks (mc)) - return true; - - InterfaceMemberBase im = mc as InterfaceMemberBase; - if (im != null && im.IsExplicitImpl) - return true; - - Report.SymbolRelatedToPreviousError (mc); - if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (symbol is ClassOrStruct || symbol is Interface)) { - Error_MissingPartialModifier (symbol); - return false; - } - - if (symbol is TypeParameter) { - Report.Error (692, symbol.Location, - "Duplicate type parameter `{0}'", symbol.GetSignatureForError ()); - } else { - Report.Error (102, symbol.Location, - "The type `{0}' already contains a definition for `{1}'", - GetSignatureForError (), name); - } - - return false; - } - - protected void RemoveFromContainer (string name) - { - defined_names.Remove (name); - } - - /// - /// Returns the MemberCore associated with a given name in the declaration - /// space. It doesn't return method based symbols !! - /// - /// - public MemberCore GetDefinition (string name) - { - MemberCore mc = null; - defined_names.TryGetValue (name, out mc); - return mc; - } - - // - // root_types contains all the types. All TopLevel types - // hence have a parent that points to `root_types', that is - // why there is a non-obvious test down here. - // - public bool IsTopLevel { - get { return (Parent != null && Parent.Parent == null); } - } - - public virtual bool IsUnmanagedType () - { - return false; - } - - protected abstract TypeAttributes TypeAttr { get; } - - /// - /// Should be overriten by the appropriate declaration space - /// - public abstract void DefineType (); - - protected void Error_MissingPartialModifier (MemberCore type) - { - Report.Error (260, type.Location, - "Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists", - type.GetSignatureForError ()); - } - - public override string GetSignatureForDocumentation () - { - return Name; - } - - public override string GetSignatureForError () - { - return MemberName.GetSignatureForError (); - } - -#if FULL_AST - public List PlainConstraints { - get; - private set; - } - - public bool HasOptionalSemicolon { - get; - private set; - } - Location optionalSemicolon; - public Location OptionalSemicolon { - get { - return optionalSemicolon; - } - set { - optionalSemicolon = value; - HasOptionalSemicolon = true; - } - } -#endif - public List Constraints { - get; - private set; - } - - public virtual void SetParameterInfo (List constraints_list) - { -#if FULL_AST - if (constraints_list != null) { - this.PlainConstraints = constraints_list; - constraints_list = this.Constraints = new List (constraints_list); - } -#else - this.Constraints = constraints_list; -#endif - if (!is_generic) { - if (constraints_list != null) { - Report.Error ( - 80, Location, "Constraints are not allowed " + - "on non-generic declarations"); - } - - return; - } - - // - // Register all the names - // - for (int i = 0; i < MemberName.TypeParameters.Count; i++) { - var name = MemberName.TypeParameters [i]; - - Constraints constraints = null; - if (constraints_list != null) { - int total = constraints_list.Count; - for (int ii = 0; ii < total; ++ii) { - Constraints constraints_at = constraints_list[ii]; - // TODO: it is used by iterators only - if (constraints_at == null) { - constraints_list.RemoveAt (ii); - --total; - continue; - } - if (constraints_at.TypeParameter.Value == name.MemberName.Name) { - constraints = constraints_at; - constraints_list.RemoveAt(ii); - break; - } - } - } - - if (name.Variance != Variance.None && !(this is Delegate || this is Interface)) { - Report.Error (1960, name.Location, "Variant type parameters can only be used with interfaces and delegates"); - } - - MemberName.TypeParameters[i].Constraints = constraints; - if (name.MemberName != null) - AddToContainer (name, name.MemberName.Name); - } - - if (constraints_list != null && constraints_list.Count > 0) { - foreach (Constraints constraint in constraints_list) { - Report.Error(699, constraint.Location, "`{0}': A constraint references nonexistent type parameter `{1}'", - GetSignatureForError (), constraint.TypeParameter.Value); - } - } - } - - public override string[] ValidAttributeTargets { - get { return attribute_targets; } - } - - protected override bool VerifyClsCompliance () - { - if (!base.VerifyClsCompliance ()) { - return false; - } - - if (CurrentTypeParameters != null) { - CurrentTypeParameters.VerifyClsCompliance (); - } - - return true; - } - } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs index a7bd0b178b..7730fa4c79 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs @@ -55,8 +55,7 @@ namespace Mono.CSharp { Modifiers.UNSAFE | Modifiers.PRIVATE; - public Delegate (NamespaceContainer ns, DeclSpace parent, FullNamedExpression type, - Modifiers mod_flags, MemberName name, ParametersCompiled param_list, + public Delegate (NamespaceContainer ns, TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, ParametersCompiled param_list, Attributes attrs) : base (ns, parent, name, attrs, MemberKind.Delegate) @@ -185,7 +184,7 @@ namespace Mono.CSharp { TypeManager.CheckTypeVariance (ret_type, Variance.Covariant, this); var resolved_rt = new TypeExpression (ret_type, Location); - InvokeBuilder = new Method (this, null, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null); + InvokeBuilder = new Method (this, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null); InvokeBuilder.Define (); // @@ -239,7 +238,7 @@ namespace Mono.CSharp { } ); - BeginInvokeBuilder = new Method (this, null, + BeginInvokeBuilder = new Method (this, new TypeExpression (iasync_result.TypeSpec, Location), MethodModifiers, new MemberName ("BeginInvoke"), async_parameters, null); BeginInvokeBuilder.Define (); @@ -289,7 +288,7 @@ namespace Mono.CSharp { // // Create method, define parameters, register parameters with type system // - EndInvokeBuilder = new Method (this, null, returnType, MethodModifiers, new MemberName ("EndInvoke"), end_parameters, null); + EndInvokeBuilder = new Method (this, returnType, MethodModifiers, new MemberName ("EndInvoke"), end_parameters, null); EndInvokeBuilder.Define (); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs index 7fa6bceda1..40edc1c929 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs @@ -141,7 +141,7 @@ namespace Mono.CSharp } // FIXME: it could be done with XmlReader - DeclSpace ds_target = mc as DeclSpace; + var ds_target = mc as TypeContainer; if (ds_target == null) ds_target = mc.Parent; @@ -213,7 +213,7 @@ namespace Mono.CSharp // // Handles elements. // - void HandleSee (MemberCore mc, DeclSpace ds, XmlElement see) + void HandleSee (MemberCore mc, TypeContainer ds, XmlElement see) { HandleXrefCommon (mc, ds, see); } @@ -221,7 +221,7 @@ namespace Mono.CSharp // // Handles elements. // - void HandleSeeAlso (MemberCore mc, DeclSpace ds, XmlElement seealso) + void HandleSeeAlso (MemberCore mc, TypeContainer ds, XmlElement seealso) { HandleXrefCommon (mc, ds, seealso); } @@ -229,7 +229,7 @@ namespace Mono.CSharp // // Handles elements. // - void HandleException (MemberCore mc, DeclSpace ds, XmlElement seealso) + void HandleException (MemberCore mc, TypeContainer ds, XmlElement seealso) { HandleXrefCommon (mc, ds, seealso); } @@ -304,7 +304,7 @@ namespace Mono.CSharp // // Processes "see" or "seealso" elements from cref attribute. // - void HandleXrefCommon (MemberCore mc, DeclSpace ds, XmlElement xref) + void HandleXrefCommon (MemberCore mc, TypeContainer ds, XmlElement xref) { string cref = xref.GetAttribute ("cref"); // when, XmlReader, "if (cref == null)" diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs index d84a828337..8b0268ed18 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs @@ -164,8 +164,7 @@ namespace Mono.CSharp { readonly TypeExpr underlying_type_expr; - public Enum (NamespaceContainer ns, DeclSpace parent, TypeExpression type, - Modifiers mod_flags, MemberName name, Attributes attrs) + public Enum (NamespaceContainer ns, TypeContainer parent, TypeExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base (ns, parent, name, attrs, MemberKind.Enum) { underlying_type_expr = type; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs index 61afbbe559..66cfb3b0d5 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs @@ -695,7 +695,7 @@ namespace Mono.CSharp // work from MethodBuilders. Retarded, I know. // var tt = assembly.Builder.GetType (host.TypeBuilder.Name); - var mi = tt.GetMethod (expression_method.Name); + var mi = tt.GetMethod (expression_method.MemberName.Name); if (host.Fields != null) { // diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs index e26f022fc0..9178571e78 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs @@ -62,10 +62,8 @@ namespace Mono.CSharp static readonly string[] attribute_targets = new string [] { "field" }; - protected FieldBase (DeclSpace parent, FullNamedExpression type, Modifiers mod, - Modifiers allowed_mod, MemberName name, Attributes attrs) - : base (parent, null, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, - name, attrs) + protected FieldBase (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs) + : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, name, attrs) { if ((mod & Modifiers.ABSTRACT) != 0) Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead"); @@ -88,6 +86,12 @@ namespace Mono.CSharp } } + public string Name { + get { + return MemberName.Name; + } + } + public FieldSpec Spec { get { return spec; @@ -371,7 +375,7 @@ namespace Mono.CSharp Modifiers.PRIVATE | Modifiers.UNSAFE; - public FixedField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) + public FixedField (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base (parent, type, mod, AllowedModifiers, name, attrs) { } @@ -573,8 +577,7 @@ namespace Mono.CSharp Modifiers.UNSAFE | Modifiers.READONLY; - public Field (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, - Attributes attrs) + public Field (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base (parent, type, mod, AllowedModifiers, name, attrs) { } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs index be3b6a03fc..81f9665bc1 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs @@ -382,7 +382,7 @@ namespace Mono.CSharp { this.spec = new TypeParameterSpec (null, -1, this, SpecialConstraint.None, variance, null); } - public TypeParameter (TypeParameterSpec spec, DeclSpace parent, TypeSpec parentSpec, MemberName name, Attributes attrs) + public TypeParameter (TypeParameterSpec spec, TypeSpec parentSpec, MemberName name, Attributes attrs) : base (null, name, attrs) { this.spec = new TypeParameterSpec (parentSpec, spec.DeclaredPosition, spec.MemberDefinition, spec.SpecialConstraint, spec.Variance, null) { @@ -428,6 +428,12 @@ namespace Mono.CSharp { } } + public string Name { + get { + return MemberName.Name; + } + } + public string Namespace { get { return null; @@ -511,9 +517,9 @@ namespace Mono.CSharp { constraints.CheckGenericConstraints (this, obsoleteCheck); } - public TypeParameter CreateHoistedCopy (TypeContainer declaringType, TypeSpec declaringSpec) + public TypeParameter CreateHoistedCopy (TypeSpec declaringSpec) { - return new TypeParameter (spec, declaringType, declaringSpec, MemberName, null); + return new TypeParameter (spec, declaringSpec, MemberName, null); } public override bool Define () @@ -2057,9 +2063,15 @@ namespace Mono.CSharp { { types = new TypeParameterSpec[Count]; for (int i = 0; i < types.Length; ++i) { - names[i].Define (buiders[i + parentOffset], declaringType, parent); - types[i] = names[i].Type; + var tp = names[i]; + + tp.Define (buiders[i + parentOffset], declaringType, parent); + types[i] = tp.Type; types[i].DeclaredPosition = i + parentOffset; + + if (tp.Variance != Variance.None && !(declaringType != null && (declaringType.Kind == MemberKind.Interface || declaringType.Kind == MemberKind.Delegate))) { + parent.Compiler.Report.Error (1960, tp.Location, "Variant type parameters can only be used with interfaces and delegates"); + } } } @@ -2506,120 +2518,6 @@ namespace Mono.CSharp { } } - /// - /// A generic method definition. - /// - public class GenericMethod : DeclSpace - { - ParametersCompiled parameters; - - public GenericMethod (NamespaceContainer ns, DeclSpace parent, MemberName name, - FullNamedExpression return_type, ParametersCompiled parameters) - : base (ns, parent, name, null) - { - this.parameters = parameters; - } - - public override TypeParameters CurrentTypeParameters { - get { - return MemberName.TypeParameters; - } - } - - protected override TypeAttributes TypeAttr { - get { - throw new NotSupportedException (); - } - } - - public override void DefineType () - { - throw new Exception (); - } - - public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) - { - throw new NotSupportedException (); - } - - public override bool Define () - { - throw new NotSupportedException (); - } - - /// - /// Define and resolve the type parameters. - /// We're called from Method.Define(). - /// - public bool Define (MethodOrOperator m) - { - var tparams = MemberName.TypeParameters; - string[] snames = new string[MemberName.Arity]; - var block = m.Block; - var parent_tparams = Parent.TypeParametersAll; - - for (int i = 0; i < snames.Length; i++) { - string type_argument_name = tparams[i].MemberName.Name; - - if (block == null) { - int idx = parameters.GetParameterIndexByName (type_argument_name); - if (idx >= 0) { - var b = m.Block; - if (b == null) - b = new ToplevelBlock (Compiler, Location); - - b.Error_AlreadyDeclaredTypeParameter (type_argument_name, parameters[i].Location); - } - } else { - INamedBlockVariable variable = null; - block.GetLocalName (type_argument_name, m.Block, ref variable); - if (variable != null) - variable.Block.Error_AlreadyDeclaredTypeParameter (type_argument_name, variable.Location); - } - - if (parent_tparams != null) { - var tp = parent_tparams.Find (type_argument_name); - if (tp != null) { - tparams[i].WarningParentNameConflict (tp); - } - } - - snames[i] = type_argument_name; - } - - GenericTypeParameterBuilder[] gen_params = m.MethodBuilder.DefineGenericParameters (snames); - tparams.Define (gen_params, null, 0, Parent); - - return true; - } - - public void EmitAttributes () - { - if (OptAttributes != null) - OptAttributes.Emit (); - } - - public override string GetSignatureForError () - { - return base.GetSignatureForError () + parameters.GetSignatureForError (); - } - - public override AttributeTargets AttributeTargets { - get { - return AttributeTargets.Method | AttributeTargets.ReturnValue; - } - } - - public override string DocCommentHeader { - get { return "M:"; } - } - - public new void VerifyClsCompliance () - { - MemberName.TypeParameters.VerifyClsCompliance (); - } - } - public partial class TypeManager { public static Variance CheckTypeVariance (TypeSpec t, Variance expected, IMemberContext member) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs index b28d1cf578..848caae65d 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs @@ -394,7 +394,7 @@ namespace Mono.CSharp public IteratorStorey (Iterator iterator) : base (iterator.Container.ParametersBlock, iterator.Host, - iterator.OriginalMethod as MemberBase, iterator.GenericMethod == null ? null : iterator.GenericMethod.CurrentTypeParameters, "Iterator") + iterator.OriginalMethod as MemberBase, iterator.OriginalMethod.CurrentTypeParameters, "Iterator") { this.Iterator = iterator; } @@ -532,7 +532,7 @@ namespace Mono.CSharp void Define_Reset () { Method reset = new Method ( - this, null, new TypeExpression (Compiler.BuiltinTypes.Void, Location), + this, new TypeExpression (Compiler.BuiltinTypes.Void, Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Reset", Location), ParametersCompiled.EmptyReadOnlyParameters, null); @@ -564,7 +564,7 @@ namespace Mono.CSharp readonly StateMachineInitializer expr; public StateMachineMethod (StateMachine host, StateMachineInitializer expr, FullNamedExpression returnType, Modifiers mod, MemberName name) - : base (host, null, returnType, mod | Modifiers.COMPILER_GENERATED, + : base (host, returnType, mod | Modifiers.COMPILER_GENERATED, name, ParametersCompiled.EmptyReadOnlyParameters, null) { this.expr = expr; @@ -910,10 +910,6 @@ namespace Mono.CSharp get { return OriginalMethod.Block; } } - public GenericMethod GenericMethod { - get { return OriginalMethod.GenericMethod; } - } - public override string ContainerType { get { return "iterator"; } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs index 825ca37dbf..a25916d742 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs @@ -47,10 +47,9 @@ namespace Mono.CSharp { protected ToplevelBlock block; protected MethodSpec spec; - public MethodCore (DeclSpace parent, GenericMethod generic, - FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, + public MethodCore (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs, ParametersCompiled parameters) - : base (parent, generic, type, mod, allowed_mod, name, attrs) + : base (parent, type, mod, allowed_mod, name, attrs) { this.parameters = parameters; } @@ -518,11 +517,9 @@ namespace Mono.CSharp { static readonly string[] attribute_targets = new string [] { "method", "return" }; - protected MethodOrOperator (DeclSpace parent, GenericMethod generic, FullNamedExpression type, Modifiers mod, - Modifiers allowed_mod, MemberName name, + protected MethodOrOperator (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs, ParametersCompiled parameters) - : base (parent, generic, type, mod, allowed_mod, name, - attrs, parameters) + : base (parent, type, mod, allowed_mod, name, attrs, parameters) { } @@ -612,7 +609,7 @@ namespace Mono.CSharp { } MethodData = new MethodData ( - this, ModFlags, flags, this, MethodBuilder, GenericMethod, base_method); + this, ModFlags, flags, this, MethodBuilder, base_method); if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName))) return false; @@ -777,12 +774,6 @@ namespace Mono.CSharp { return conditions; } - GenericMethod IMethodData.GenericMethod { - get { - return GenericMethod; - } - } - public virtual void EmitExtraSymbolInfo (SourceMethod source) { } @@ -795,7 +786,7 @@ namespace Mono.CSharp { MethodBase method; SourceMethodBuilder builder; - protected SourceMethod (DeclSpace parent, MethodBase method, ICompileUnit file) + protected SourceMethod (TypeContainer parent, MethodBase method, ICompileUnit file) { this.method = method; @@ -833,7 +824,7 @@ namespace Mono.CSharp { builder.SetRealMethodName (name); } - public static SourceMethod Create (DeclSpace parent, MethodBase method, Block block) + public static SourceMethod Create (TypeContainer parent, MethodBase method, Block block) { if (!SymbolWriter.HasSymbolWriter) return null; @@ -856,10 +847,8 @@ namespace Mono.CSharp { { Method partialMethodImplementation; - public Method (DeclSpace parent, GenericMethod generic, - FullNamedExpression return_type, Modifiers mod, - MemberName name, ParametersCompiled parameters, Attributes attrs) - : base (parent, generic, return_type, mod, + public Method (TypeContainer parent, FullNamedExpression return_type, Modifiers mod, MemberName name, ParametersCompiled parameters, Attributes attrs) + : base (parent, return_type, mod, parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface : parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct | Modifiers.ASYNC : AllowedModifiersClass | Modifiers.ASYNC, @@ -867,9 +856,9 @@ namespace Mono.CSharp { { } - protected Method (DeclSpace parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod, + protected Method (TypeContainer parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod, MemberName name, ParametersCompiled parameters, Attributes attrs) - : base (parent, null, return_type, mod, amod, name, attrs, parameters) + : base (parent, return_type, mod, amod, name, attrs, parameters) { } @@ -877,10 +866,7 @@ namespace Mono.CSharp { public override TypeParameters CurrentTypeParameters { get { - if (GenericMethod != null) - return GenericMethod.CurrentTypeParameters; - - return null; + return MemberName.TypeParameters; } } @@ -903,10 +889,10 @@ namespace Mono.CSharp { visitor.Visit (this); } - public static Method Create (DeclSpace parent, GenericMethod generic, FullNamedExpression returnType, Modifiers mod, + public static Method Create (TypeContainer parent, FullNamedExpression returnType, Modifiers mod, MemberName name, ParametersCompiled parameters, Attributes attrs, bool hasConstraints) { - var m = new Method (parent, generic, returnType, mod, name, parameters, attrs); + var m = new Method (parent, returnType, mod, name, parameters, attrs); if (hasConstraints && ((mod & Modifiers.OVERRIDE) != 0 || m.IsExplicitImpl)) { m.Report.Error (460, m.Location, @@ -1027,6 +1013,45 @@ namespace Mono.CSharp { base.ApplyAttributeBuilder (a, ctor, cdata, pa); } + void CreateTypeParameters () + { + var tparams = MemberName.TypeParameters; + string[] snames = new string[MemberName.Arity]; + var parent_tparams = Parent.TypeParametersAll; + + for (int i = 0; i < snames.Length; i++) { + string type_argument_name = tparams[i].MemberName.Name; + + if (block == null) { + int idx = parameters.GetParameterIndexByName (type_argument_name); + if (idx >= 0) { + var b = block; + if (b == null) + b = new ToplevelBlock (Compiler, Location); + + b.Error_AlreadyDeclaredTypeParameter (type_argument_name, parameters[i].Location); + } + } else { + INamedBlockVariable variable = null; + block.GetLocalName (type_argument_name, block, ref variable); + if (variable != null) + variable.Block.Error_AlreadyDeclaredTypeParameter (type_argument_name, variable.Location); + } + + if (parent_tparams != null) { + var tp = parent_tparams.Find (type_argument_name); + if (tp != null) { + tparams[i].WarningParentNameConflict (tp); + } + } + + snames[i] = type_argument_name; + } + + GenericTypeParameterBuilder[] gen_params = MethodBuilder.DefineGenericParameters (snames); + tparams.Define (gen_params, null, 0, Parent); + } + protected virtual void DefineTypeParameters () { var tparams = CurrentTypeParameters; @@ -1201,10 +1226,10 @@ namespace Mono.CSharp { } if (CurrentTypeParameters == null) { - if (base_method != null) { - if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && Name == "Equals") + if (base_method != null && !IsExplicitImpl) { + if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && MemberName.Name == "Equals") Parent.PartialContainer.Mark_HasEquals (); - else if (parameters.IsEmpty && Name == "GetHashCode") + else if (parameters.IsEmpty && MemberName.Name == "GetHashCode") Parent.PartialContainer.Mark_HasGetHashCode (); } @@ -1237,7 +1262,7 @@ namespace Mono.CSharp { return true; if (parameters.HasExtensionMethodType) { - if (Parent.PartialContainer.IsStatic && !Parent.IsGeneric) { + if (Parent.PartialContainer.IsStatic && !Parent.IsGenericOrParentIsGeneric) { if (!Parent.IsTopLevel) Report.Error (1109, Location, "`{0}': Extension methods cannot be defined in a nested class", GetSignatureForError ()); @@ -1263,10 +1288,10 @@ namespace Mono.CSharp { // This is used to track the Entry Point, // var settings = Compiler.Settings; - if (settings.NeedsEntryPoint && Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) { + if (settings.NeedsEntryPoint && MemberName.Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) { if (IsEntryPoint ()) { if (Parent.DeclaringAssembly.EntryPoint == null) { - if (Parent.IsGeneric || MemberName.IsGeneric) { + if (Parent.IsGenericOrParentIsGeneric || MemberName.IsGeneric) { Report.Warning (402, 4, Location, "`{0}': an entry point cannot be generic or in a generic type", GetSignatureForError ()); } else if ((ModFlags & Modifiers.ASYNC) != 0) { @@ -1349,10 +1374,9 @@ namespace Mono.CSharp { protected override bool ResolveMemberType () { - if (GenericMethod != null) { + if (CurrentTypeParameters != null) { MethodBuilder = Parent.TypeBuilder.DefineMethod (GetFullName (MemberName), flags); - if (!GenericMethod.Define (this)) - return false; + CreateTypeParameters (); } return base.ResolveMemberType (); @@ -1527,9 +1551,8 @@ namespace Mono.CSharp { public static readonly string ConstructorName = ".ctor"; public static readonly string TypeConstructorName = ".cctor"; - public Constructor (DeclSpace parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args, Location loc) - : base (parent, null, null, mod, AllowedModifiers, - new MemberName (name, loc), attrs, args) + public Constructor (TypeContainer parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args, Location loc) + : base (parent, null, mod, AllowedModifiers, new MemberName (name, loc), attrs, args) { } @@ -1802,12 +1825,6 @@ namespace Mono.CSharp { return false; } - GenericMethod IMethodData.GenericMethod { - get { - return null; - } - } - void IMethodData.EmitExtraSymbolInfo (SourceMethod source) { } @@ -1823,7 +1840,6 @@ namespace Mono.CSharp { Location Location { get; } MemberName MethodName { get; } TypeSpec ReturnType { get; } - GenericMethod GenericMethod { get; } ParametersCompiled ParameterInfo { get; } MethodSpec Spec { get; } bool IsAccessor { get; } @@ -1846,8 +1862,6 @@ namespace Mono.CSharp { public readonly IMethodData method; - public readonly GenericMethod GenericMethod; - // // Are we implementing an interface ? // @@ -1888,11 +1902,12 @@ namespace Mono.CSharp { public MethodData (InterfaceMemberBase member, Modifiers modifiers, MethodAttributes flags, IMethodData method, MethodBuilder builder, - GenericMethod generic, MethodSpec parent_method) + //GenericMethod generic, + MethodSpec parent_method) : this (member, modifiers, flags, method) { this.builder = builder; - this.GenericMethod = generic; + //this.GenericMethod = generic; this.parent_method = parent_method; } @@ -2104,11 +2119,8 @@ namespace Mono.CSharp { // // Emits the code // - public void Emit (DeclSpace parent) + public void Emit (TypeContainer parent) { - if (GenericMethod != null) - GenericMethod.EmitAttributes (); - var mc = (IMemberContext) method; method.ParameterInfo.ApplyAttributes (mc, MethodBuilder); @@ -2142,9 +2154,8 @@ namespace Mono.CSharp { public static readonly string MetadataName = "Finalize"; - public Destructor (DeclSpace parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l) - : base (parent, null, null, mod, AllowedModifiers, - new MemberName (MetadataName, l), attrs, parameters) + public Destructor (TypeContainer parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l) + : base (parent, null, mod, AllowedModifiers, new MemberName (MetadataName, l), attrs, parameters) { ModFlags &= ~Modifiers.PRIVATE; ModFlags |= Modifiers.PROTECTED | Modifiers.OVERRIDE; @@ -2280,12 +2291,6 @@ namespace Mono.CSharp { return false; } - GenericMethod IMethodData.GenericMethod { - get { - return null; - } - } - public MemberName MethodName { get { return MemberName; @@ -2344,7 +2349,7 @@ namespace Mono.CSharp { throw new NotSupportedException (); } - public virtual void Emit (DeclSpace parent) + public virtual void Emit (TypeContainer parent) { method_data.Emit (parent); @@ -2500,11 +2505,9 @@ namespace Mono.CSharp { names [(int) OpType.Explicit] = new string [] { "explicit", "op_Explicit" }; } - public Operator (DeclSpace parent, OpType type, FullNamedExpression ret_type, - Modifiers mod_flags, ParametersCompiled parameters, + public Operator (TypeContainer parent, OpType type, FullNamedExpression ret_type, Modifiers mod_flags, ParametersCompiled parameters, ToplevelBlock block, Attributes attrs, Location loc) - : base (parent, null, ret_type, mod_flags, AllowedModifiers, - new MemberName (GetMetadataName (type), loc), attrs, parameters) + : base (parent, ret_type, mod_flags, AllowedModifiers, new MemberName (GetMetadataName (type), loc), attrs, parameters) { OperatorType = type; Block = block; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs index 307dd45ef2..9f4ba6a771 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs @@ -593,7 +593,6 @@ namespace Mono.CSharp { readonly CompilationSourceFile file; readonly MemberName name; - NamespaceContainer implicit_parent; int symfile_id; List clauses; @@ -603,7 +602,6 @@ namespace Mono.CSharp { bool resolved; - public readonly bool IsImplicit; public readonly TypeContainer SlaveDeclSpace; Namespace[] namespace_using_table; @@ -626,16 +624,6 @@ namespace Mono.CSharp { SlaveDeclSpace = new RootDeclSpace (module, this); } - private NamespaceContainer (ModuleContainer module, NamespaceContainer parent, CompilationSourceFile file, Namespace ns, bool slave) - { - this.module = module; - this.parent = parent; - this.file = file; - this.IsImplicit = true; - this.ns = ns; - this.SlaveDeclSpace = slave ? new RootDeclSpace (module, this) : null; - } - #region Properties public Location Location { @@ -650,6 +638,12 @@ namespace Mono.CSharp { } } + public Namespace NS { + get { + return ns; + } + } + public NamespaceContainer Parent { get { return parent; @@ -670,23 +664,6 @@ namespace Mono.CSharp { #endregion - public Namespace NS { - get { return ns; } - } - - public NamespaceContainer ImplicitParent { - get { - if (parent == null) - return null; - if (implicit_parent == null) { - implicit_parent = (parent.ns == ns.Parent) - ? parent - : new NamespaceContainer (module, parent, file, ns.Parent, false); - } - return implicit_parent; - } - } - public void AddUsing (UsingNamespace un) { if (DeclarationFound){ @@ -767,21 +744,35 @@ namespace Mono.CSharp { public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc) { - // Precondition: Only simple names (no dots) will be looked up with this function. - FullNamedExpression resolved = null; - for (NamespaceContainer curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent) { - if ((resolved = curr_ns.Lookup (name, arity, mode, loc)) != null) - break; + // + // Only simple names (no dots) will be looked up with this function + // + FullNamedExpression resolved; + for (NamespaceContainer container = this; container != null; container = container.parent) { + resolved = container.Lookup (name, arity, mode, loc); + if (resolved != null) + return resolved; + + var container_ns = container.ns.Parent; + var mn = container.MemberName.Left; + while (mn != null) { + resolved = container_ns.LookupTypeOrNamespace (this, name, arity, mode, loc); + if (resolved != null) + return resolved; + + mn = mn.Left; + container_ns = container_ns.Parent; + } } - return resolved; + return null; } public IList CompletionGetTypesStartingWith (string prefix) { IEnumerable all = Enumerable.Empty (); - for (NamespaceContainer curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent){ + for (NamespaceContainer curr_ns = this; curr_ns != null; curr_ns = curr_ns.parent){ foreach (Namespace using_ns in namespace_using_table){ if (prefix.StartsWith (using_ns.Name)){ int ld = prefix.LastIndexOf ('.'); @@ -819,7 +810,7 @@ namespace Mono.CSharp { // public FullNamedExpression LookupNamespaceAlias (string name) { - for (NamespaceContainer n = this; n != null; n = n.ImplicitParent) { + for (NamespaceContainer n = this; n != null; n = n.parent) { if (n.aliases == null) continue; @@ -860,9 +851,6 @@ namespace Mono.CSharp { if (fne != null) return fne; - if (IsImplicit) - return null; - // // Check using entries. // @@ -1241,8 +1229,19 @@ namespace Mono.CSharp { if (fne != null) return fne; - if (ns.ImplicitParent != null) - return ns.ImplicitParent.LookupNamespaceOrType (name, arity, mode, loc); + var container_ns = ns.NS.Parent; + var mn = ns.MemberName.Left; + while (mn != null) { + fne = container_ns.LookupTypeOrNamespace (this, name, arity, mode, loc); + if (fne != null) + return fne; + + mn = mn.Left; + container_ns = container_ns.Parent; + } + + if (ns.Parent != null) + return ns.Parent.LookupNamespaceOrType (name, arity, mode, loc); return null; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs index e451167dc5..c2cdd700ea 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs @@ -1014,7 +1014,7 @@ namespace Mono.CSharp.Nullable } } - public Expression Right { + public Expression RightExpression { get { return right; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs index a4ce92af7f..3093e061dd 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs @@ -34,10 +34,8 @@ namespace Mono.CSharp // This includes properties, indexers, and events public abstract class PropertyBasedMember : InterfaceMemberBase { - public PropertyBasedMember (DeclSpace parent, GenericMethod generic, - FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, - MemberName name, Attributes attrs) - : base (parent, generic, type, mod, allowed_mod, name, attrs) + public PropertyBasedMember (TypeContainer parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs) + : base (parent, type, mod, allowed_mod, name, attrs) { } @@ -198,7 +196,7 @@ namespace Mono.CSharp { } - public override MethodBuilder Define (DeclSpace parent) + public override MethodBuilder Define (TypeContainer parent) { base.Define (parent); @@ -263,7 +261,7 @@ namespace Mono.CSharp } } - public override MethodBuilder Define (DeclSpace parent) + public override MethodBuilder Define (TypeContainer parent) { parameters.Resolve (this); @@ -335,7 +333,7 @@ namespace Mono.CSharp return method.IsClsComplianceRequired (); } - public virtual MethodBuilder Define (DeclSpace parent) + public virtual MethodBuilder Define (TypeContainer parent) { TypeContainer container = parent.PartialContainer; @@ -404,9 +402,8 @@ namespace Mono.CSharp PropertyMethod get, set, first; PropertyBuilder PropertyBuilder; - public PropertyBase (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, - Modifiers allowed_mod, MemberName name, Attributes attrs) - : base (parent, null, type, mod_flags, allowed_mod, name, attrs) + public PropertyBase (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, Modifiers allowed_mod, MemberName name, Attributes attrs) + : base (parent, type, mod_flags, allowed_mod, name, attrs) { } @@ -711,9 +708,9 @@ namespace Mono.CSharp this.property = p; } - public string OriginalName { + public Property OriginalProperty { get { - return property.Name; + return property; } } @@ -723,7 +720,7 @@ namespace Mono.CSharp } } - public Property (DeclSpace parent, FullNamedExpression type, Modifiers mod, + public Property (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base (parent, type, mod, parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface : @@ -823,7 +820,7 @@ namespace Mono.CSharp { } - public override MethodBuilder Define (DeclSpace ds) + public override MethodBuilder Define (TypeContainer ds) { CheckAbstractAndExtern (block != null); return base.Define (ds); @@ -853,7 +850,7 @@ namespace Mono.CSharp static readonly string[] attribute_targets = new string [] { "event" }; - public EventProperty (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) + public EventProperty (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base (parent, type, mod_flags, name, attrs) { } @@ -893,7 +890,7 @@ namespace Mono.CSharp protected abstract MethodSpec GetOperation (Location loc); - public override void Emit (DeclSpace parent) + public override void Emit (TypeContainer parent) { if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0) { block = new ToplevelBlock (Compiler, ParameterInfo, Location); @@ -992,7 +989,7 @@ namespace Mono.CSharp Field backing_field; List declarators; - public EventField (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) + public EventField (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base (parent, type, mod_flags, name, attrs) { Add = new AddDelegateMethod (this); @@ -1169,7 +1166,7 @@ namespace Mono.CSharp return method.IsClsComplianceRequired (); } - public virtual MethodBuilder Define (DeclSpace parent) + public virtual MethodBuilder Define (TypeContainer parent) { // Fill in already resolved event type to speed things up and // avoid confusing duplicate errors @@ -1218,8 +1215,8 @@ namespace Mono.CSharp EventBuilder EventBuilder; protected EventSpec spec; - protected Event (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) - : base (parent, null, type, mod_flags, + protected Event (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) + : base (parent, type, mod_flags, parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface : parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct : AllowedModifiersClass, @@ -1420,7 +1417,7 @@ namespace Mono.CSharp this.parameters = parameters; } - public override MethodBuilder Define (DeclSpace parent) + public override MethodBuilder Define (TypeContainer parent) { parameters.Resolve (this); return base.Define (parent); @@ -1491,8 +1488,7 @@ namespace Mono.CSharp readonly ParametersCompiled parameters; - public Indexer (DeclSpace parent, FullNamedExpression type, MemberName name, Modifiers mod, - ParametersCompiled parameters, Attributes attrs) + public Indexer (TypeContainer parent, FullNamedExpression type, MemberName name, Modifiers mod, ParametersCompiled parameters, Attributes attrs) : base (parent, type, mod, parent.PartialContainer.Kind == MemberKind.Interface ? AllowedInterfaceModifiers : AllowedModifiers, name, attrs) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs index 84c71fddc0..a368473f2f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/roottypes.cs @@ -301,7 +301,7 @@ namespace Mono.CSharp public override TypeContainer AddPartial (TypeContainer nextPart) { - return AddPartial (nextPart, nextPart.Name); + return AddPartial (nextPart, nextPart.MemberName.GetName (true)); } public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) @@ -516,7 +516,7 @@ namespace Mono.CSharp { if (AddTypesContainer (tc)) { if ((tc.ModFlags & Modifiers.PARTIAL) != 0) - defined_names.Add (tc.Name, tc); + defined_names.Add (tc.MemberName.GetName (true), tc); tc.NamespaceEntry.NS.AddType (this, tc.Definition); return true; @@ -605,11 +605,6 @@ namespace Mono.CSharp get { throw new InternalErrorException ("should not be called"); } } - public override void DefineType () - { - throw new InternalErrorException ("should not be called"); - } - public override ModuleContainer Module { get { return PartialContainer.Module; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs index aebd05d8db..fa642d394e 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs @@ -292,7 +292,7 @@ namespace Mono.CSharp if (IsPointer) return ((ElementTypeSpec) this).Element.IsUnmanaged; - var ds = MemberDefinition as DeclSpace; + var ds = MemberDefinition as TypeContainer; if (ds != null) return ds.IsUnmanagedType ();