@@ -273,7 +273,7 @@ func (o *StmtBase) stmtNode() {}
273
273
type FunctionDef struct {
274
274
StmtBase
275
275
Name Identifier
276
- Args Arguments
276
+ Args * Arguments
277
277
Body []Stmt
278
278
DecoratorList []Expr
279
279
Returns Expr
@@ -283,7 +283,7 @@ type ClassDef struct {
283
283
StmtBase
284
284
Name Identifier
285
285
Bases []Expr
286
- Keywords []Keyword
286
+ Keywords []* Keyword
287
287
Starargs Expr
288
288
Kwargs Expr
289
289
Body []Stmt
@@ -498,7 +498,7 @@ type Call struct {
498
498
ExprBase
499
499
Function Expr
500
500
Args []Expr
501
- Keywords []Keyword
501
+ Keywords []* Keyword
502
502
Starargs Expr
503
503
Kwargs Expr
504
504
}
@@ -534,37 +534,76 @@ type Attribute struct {
534
534
Ctx ExprContext
535
535
}
536
536
537
+ // ExprNodes which have a settable context implement this
538
+ type SetCtxer interface {
539
+ SetCtx (ExprContext )
540
+ }
541
+
542
+ func (o * Attribute ) SetCtx (Ctx ExprContext ) { o .Ctx = Ctx }
543
+
544
+ var _ = SetCtxer ((* Attribute )(nil ))
545
+
537
546
type Subscript struct {
538
547
ExprBase
539
548
Value Expr
540
549
Slice Slicer
541
550
Ctx ExprContext
542
551
}
543
552
553
+ func (o * Subscript ) SetCtx (Ctx ExprContext ) { o .Ctx = Ctx }
554
+
555
+ var _ = SetCtxer ((* Subscript )(nil ))
556
+
544
557
type Starred struct {
545
558
ExprBase
546
559
Value Expr
547
560
Ctx ExprContext
548
561
}
549
562
563
+ func (o * Starred ) SetCtx (Ctx ExprContext ) { o .Ctx = Ctx }
564
+
565
+ var _ = SetCtxer ((* Starred )(nil ))
566
+
550
567
type Name struct {
551
568
ExprBase
552
569
Id Identifier
553
570
Ctx ExprContext
554
571
}
555
572
573
+ func (o * Name ) SetCtx (Ctx ExprContext ) { o .Ctx = Ctx }
574
+
575
+ var _ = SetCtxer ((* Name )(nil ))
576
+
556
577
type List struct {
557
578
ExprBase
558
579
Elts []Expr
559
580
Ctx ExprContext
560
581
}
561
582
583
+ func (o * List ) SetCtx (Ctx ExprContext ) {
584
+ o .Ctx = Ctx
585
+ for i := range o .Elts {
586
+ o .Elts [i ].(SetCtxer ).SetCtx (Ctx )
587
+ }
588
+ }
589
+
590
+ var _ = SetCtxer ((* List )(nil ))
591
+
562
592
type Tuple struct {
563
593
ExprBase
564
594
Elts []Expr
565
595
Ctx ExprContext
566
596
}
567
597
598
+ func (o * Tuple ) SetCtx (Ctx ExprContext ) {
599
+ o .Ctx = Ctx
600
+ for i := range o .Elts {
601
+ o .Elts [i ].(SetCtxer ).SetCtx (Ctx )
602
+ }
603
+ }
604
+
605
+ var _ = SetCtxer ((* Tuple )(nil ))
606
+
568
607
// ------------------------------------------------------------
569
608
// Slicer nodes
570
609
// ------------------------------------------------------------
0 commit comments