public virtual void Visit (Operator o) { }
public override void Visit (Operator o) { OperatorDeclaration newOperator = new OperatorDeclaration (); newOperator.OperatorType = (OperatorType)o.OperatorType; var location = LocationsBag.GetMemberLocation (o); AddAttributeSection (newOperator, o); AddModifiers (newOperator, location); if (o.OperatorType == Operator.OpType.Implicit) { if (location != null && location.Count > 0) { newOperator.AddChild (new CSharpTokenNode (Convert (location [0]), OperatorDeclaration.ImplicitRole), OperatorDeclaration.ImplicitRole); if (location.Count > 1) newOperator.AddChild (new CSharpTokenNode (Convert (location [1]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole); } newOperator.AddChild (ConvertToType (o.TypeExpression), Roles.Type); } else if (o.OperatorType == Operator.OpType.Explicit) { if (location != null && location.Count > 0) { newOperator.AddChild (new CSharpTokenNode (Convert (location [0]), OperatorDeclaration.ExplicitRole), OperatorDeclaration.ExplicitRole); if (location.Count > 1) newOperator.AddChild (new CSharpTokenNode (Convert (location [1]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole); } newOperator.AddChild (ConvertToType (o.TypeExpression), Roles.Type); } else { newOperator.AddChild (ConvertToType (o.TypeExpression), Roles.Type); if (location != null && location.Count > 0) newOperator.AddChild (new CSharpTokenNode (Convert (location [0]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole); if (location != null && location.Count > 1) { var r = OperatorDeclaration.GetRole(newOperator.OperatorType); newOperator.AddChild(new CSharpTokenNode(Convert(location [1]), r), r); } } if (location != null && location.Count > 2) newOperator.AddChild (new CSharpTokenNode (Convert (location [2]), Roles.LPar), Roles.LPar); AddParameter (newOperator, o.ParameterInfo); if (location != null && location.Count > 3) newOperator.AddChild (new CSharpTokenNode (Convert (location [3]), Roles.RPar), Roles.RPar); if (o.Block != null) { newOperator.AddChild ((BlockStatement)o.Block.Accept (this), Roles.Body); } else { if (location != null && location.Count >= 5) newOperator.AddChild (new CSharpTokenNode (Convert (location [4]), Roles.Semicolon), Roles.Semicolon); } typeStack.Peek ().AddChild (newOperator, Roles.TypeMemberRole); }
public void AddOperator (Operator op) { PartialContainer.HasOperators = true; AddMember (op); }
void case_233() #line 2046 "cs-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { Operator op = new Operator ( current_type, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop], current_local_parameters, (ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location); if (op.Block == null) op.ParameterInfo.CheckParameters (op); if (doc_support) { op.DocComment = tmpComment; Lexer.doc_state = XmlCommentState.Allowed; } /* Note again, checking is done in semantic analysis*/ current_type.AddOperator (op); lbag.AddMember (op, GetModifierLocations (), lbag.GetLocations (decl)); if (yyVals[0+yyTop] == null) { /* Semicolon*/ lbag.AppendTo (op, savedLocation); } } current_local_parameters = null; }
static bool IsUnaryOperator (Operator.OpType op) { switch (op) { case Operator.OpType.LogicalNot: case Operator.OpType.OnesComplement: case Operator.OpType.Increment: case Operator.OpType.Decrement: case Operator.OpType.True: case Operator.OpType.False: case Operator.OpType.UnaryPlus: case Operator.OpType.UnaryNegation: return true; } return false; }
public OperatorDeclaration (Operator.OpType op, FullNamedExpression ret_type, Location location) { optype = op; this.ret_type = ret_type; this.location = location; }
void case_261() #line 2556 "ps-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { var modifiers = (Modifiers) yyVals[-3+yyTop]; /* if (current_container.Kind == MemberKind.Class && */ /* (modifiers & (Modifiers.NEW | Modifiers.SEALED | Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) == 0)*/ /* modifiers |= Modifiers.VIRTUAL; */ if (current_local_parameters.Count < 1) { report.Error (7037, GetLocation (yyVals[-4+yyTop]), "Invalid number of parameters for operator."); } else { Operator op = new Operator ( current_type, decl.optype, decl.ret_type, modifiers, current_local_parameters, (ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location); if (op.Block == null) op.ParameterInfo.CheckParameters (op); if (doc_support) { op.DocComment = tmpComment; Lexer.doc_state = XmlCommentState.Allowed; } /* Note again, checking is done in semantic analysis*/ if (is_config_enabled) { current_type.AddOperator (op); } is_config_enabled = true; lbag.AddMember (op, GetModifierLocations (), lbag.GetLocations (decl)); if (yyVals[0+yyTop] == null) { /* Semicolon*/ lbag.AppendTo (op, savedLocation); } } } current_local_parameters = null; }