void case_271() #line 2255 "cs-parser.jay" { valid_param_mod = 0; current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; var lt = (Tokenizer.LocatedToken) yyVals[-4+yyTop]; var mods = (Modifiers) yyVals[-5+yyTop]; var c = new Constructor (current_type, lt.Value, mods, (Attributes) yyVals[-6+yyTop], current_local_parameters, lt.Location); if (lt.Value != current_container.MemberName.Name) { report.Error (1520, c.Location, "Class, struct, or interface method must have a return type"); } else if ((mods & Modifiers.STATIC) != 0) { if ((mods & Modifiers.AccessibilityMask) != 0){ report.Error (515, c.Location, "`{0}': static constructor cannot have an access modifier", c.GetSignatureForError ()); } } current_type.AddConstructor (c); lbag.AddMember (c, GetModifierLocations (), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); yyVal = c; /**/ /* start block here, so possible anonymous methods inside*/ /* constructor initializer can get correct parent block*/ /**/ start_block (lexer.Location); } void case_272() #line 2284 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { var c = (Constructor) yyVals[-1+yyTop]; c.Initializer = (ConstructorInitializer) yyVals[0+yyTop]; if (c.IsStatic) { report.Error (514, c.Location, "`{0}': static constructor cannot have an explicit `this' or `base' constructor call", c.GetSignatureForError ()); } } yyVal = yyVals[-1+yyTop]; } void case_278() #line 2316 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorBaseInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_280() #line 2326 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorThisInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } void case_281() #line 2332 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ConstructorThisInitializer (null, GetLocation (yyVals[0+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_282() #line 2338 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_283() #line 2346 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.NotAllowed; } current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; } void case_284() #line 2355 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lt.Value != current_container.MemberName.Name){ report.Error (574, lt.Location, "Name of destructor must match name of class"); } else if (current_container.Kind != MemberKind.Class){ report.Error (575, lt.Location, "Only class types can contain destructor"); } Destructor d = new Destructor (current_type, (Modifiers) yyVals[-6+yyTop], ParametersCompiled.EmptyReadOnlyParameters, (Attributes) yyVals[-7+yyTop], lt.Location); d.Identifier = lt.Value; if (doc_support) d.DocComment = ConsumeStoredComment (); d.Block = (ToplevelBlock) yyVals[0+yyTop]; current_type.AddMember (d); lbag.AddMember (d, GetModifierLocations (), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[-1+yyTop])); current_local_parameters = null; } void case_285() #line 2381 "cs-parser.jay" { current_event_field = new EventField (current_type, (FullNamedExpression) yyVals[-1+yyTop], (Modifiers) yyVals[-3+yyTop], (MemberName) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop]); current_type.AddMember (current_event_field); if (current_event_field.MemberName.ExplicitInterface != null) { report.Error (71, current_event_field.Location, "`{0}': An explicit interface implementation of an event must use property syntax", current_event_field.GetSignatureForError ()); } yyVal = current_event_field; } void case_286() #line 2395 "cs-parser.jay" { if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } if (current_event_field.Initializer != null) { lbag.AddMember (current_event_field, GetModifierLocations (), GetLocation (yyVals[-6+yyTop]), savedEventAssignLocation, GetLocation (yyVals[0+yyTop])); } else { lbag.AddMember (current_event_field, GetModifierLocations (), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[0+yyTop])); } current_event_field = null; } void case_287() #line 2411 "cs-parser.jay" { current_event = new EventProperty (current_type, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-4+yyTop], (MemberName) yyVals[-1+yyTop], (Attributes) yyVals[-5+yyTop]); current_type.AddMember (current_event); lbag.AddMember (current_event, GetModifierLocations (), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); lexer.EventParsing = true; } void case_288() #line 2419 "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"); lexer.EventParsing = false; } void case_289() #line 2426 "cs-parser.jay" { if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); Lexer.doc_state = XmlCommentState.Allowed; } lbag.AppendToMember (current_event, GetLocation (yyVals[-1+yyTop])); current_event = null; current_local_parameters = null; } void case_290() #line 2439 "cs-parser.jay" { Error_SyntaxError (yyToken); current_type.AddMember (new EventField (current_type, (FullNamedExpression) yyVals[-1+yyTop], (Modifiers) yyVals[-3+yyTop], MemberName.Null, (Attributes) yyVals[-4+yyTop])); } void case_293() #line 2453 "cs-parser.jay" { --lexer.parsing_block; savedEventAssignLocation = GetLocation (yyVals[-2+yyTop]); current_event_field.Initializer = (Expression) yyVals[0+yyTop]; } void case_298() #line 2478 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_300() #line 2488 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } void case_301() #line 2497 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) { report.Error (68, lexer.Location, "`{0}': event in interface cannot have an initializer", current_event_field.GetSignatureForError ()); } if ((current_event_field.ModFlags & Modifiers.ABSTRACT) != 0) { report.Error (74, lexer.Location, "`{0}': abstract event cannot have an initializer", current_event_field.GetSignatureForError ()); } } void case_305() #line 2518 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } void case_306() #line 2523 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } void case_307() #line 2528 "cs-parser.jay" { report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected"); yyVal = null; } void case_308() #line 2536 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); } current_event.Add = new EventProperty.AddDelegateMethod (current_event, (Attributes) yyVals[-2+yyTop], GetLocation (yyVals[0+yyTop])); current_local_parameters = current_event.Add.ParameterInfo; lbag.AddMember (current_event.Add, GetModifierLocations ()); lexer.EventParsing = false; } void case_309() #line 2548 "cs-parser.jay" { lexer.EventParsing = true; current_event.Add.Block = (ToplevelBlock) yyVals[0+yyTop]; if (current_container.Kind == MemberKind.Interface) { report.Error (531, current_event.Add.Block.StartLocation, "`{0}': interface members cannot have a definition", current_event.Add.GetSignatureForError ()); } current_local_parameters = null; } void case_310() #line 2564 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); } current_event.Remove = new EventProperty.RemoveDelegateMethod (current_event, (Attributes) yyVals[-2+yyTop], GetLocation (yyVals[0+yyTop])); current_local_parameters = current_event.Remove.ParameterInfo; lbag.AddMember (current_event.Remove, GetModifierLocations ()); lexer.EventParsing = false; } void case_311() #line 2576 "cs-parser.jay" { lexer.EventParsing = true; current_event.Remove.Block = (ToplevelBlock) yyVals[0+yyTop]; if (current_container.Kind == MemberKind.Interface) { report.Error (531, current_event.Remove.Block.StartLocation, "`{0}': interface members cannot have a definition", current_event.Remove.GetSignatureForError ()); } current_local_parameters = null; } void case_312() #line 2592 "cs-parser.jay" { report.Error (73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } void case_314() #line 2601 "cs-parser.jay" { current_type.UnattachedAttributes = (Attributes) yyVals[-1+yyTop]; report.Error (1519, GetLocation (yyVals[-1+yyTop]), "An attribute is missing member declaration"); lexer.putback ('}'); } void case_315() #line 2614 "cs-parser.jay" { if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } void case_316() #line 2619 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; MemberName name = (MemberName) yyVals[-3+yyTop]; if (name.IsGeneric) { report.Error (1675, name.Location, "Enums cannot have type parameters"); } push_current_container (new Enum (current_container, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-5+yyTop], name, (Attributes) yyVals[-6+yyTop]), null); if (yyVals[-2+yyTop] != null) { lbag.AddMember (current_container, GetModifierLocations (), GetLocation (yyVals[-4+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); } else { lbag.AddMember (current_container, GetModifierLocations (), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[0+yyTop])); } } void case_317() #line 2636 "cs-parser.jay" { /* here will be evaluated after CLOSE_BLACE is consumed.*/ if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; }
void case_180() #line 1605 "ps-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; MemberName name = (MemberName) yyVals[-7+yyTop]; current_local_parameters = (ParametersCompiled) yyVals[-4+yyTop]; var modifiers = (Modifiers) yyVals[-9+yyTop]; if (is_package_function) { modifiers |= Modifiers.STATIC; } if (current_type != null && name.Name == current_type.MemberName.Name) { var c = new Constructor (current_type, name.Name, modifiers, (Attributes) yyVals[-10+yyTop], current_local_parameters, name.Location); if (yyVals[0+yyTop] != null) { report.Error (7011, c.Location, "`{0}': constructor can not have type constraints.", c.GetSignatureForError ()); } if ((modifiers & Modifiers.STATIC) != 0) { if ((modifiers & Modifiers.AccessibilityMask) != 0){ report.Error (515, c.Location, "`{0}': static constructor cannot have an access modifier", c.GetSignatureForError ()); } } if (doc_support) c.DocComment = Lexer.consume_doc_comment (); lbag.AddMember (c, GetModifierLocations (), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop])); yyVal = c; } else { if (current_container.Kind == MemberKind.Class && name.ExplicitInterface == null && (modifiers & (Modifiers.NEW | Modifiers.SEALED | Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) == 0) modifiers |= Modifiers.VIRTUAL; var ret_type = yyVals[-2+yyTop] as FullNamedExpression; if (ret_type == null) { report.Error (7012, GetLocation(yyVals[-3+yyTop]), "Method must specify a return type."); ret_type = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-3+yyTop])); } var method = Method.Create (current_type, ret_type, modifiers, name, current_local_parameters, (Attributes) yyVals[-10+yyTop]); if (yyVals[0+yyTop] != null) method.SetConstraints ((List<Constraints>) yyVals[0+yyTop]); if (doc_support) method.DocComment = Lexer.consume_doc_comment (); lbag.AddMember (method, GetModifierLocations (), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop])); yyVal = method; } }