-
Notifications
You must be signed in to change notification settings - Fork 0
/
send_stmt.go
45 lines (36 loc) · 1.01 KB
/
send_stmt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package goastutil
import (
"fmt"
"go/ast"
)
type SendStmt struct {
parent Stmt
*ast.SendStmt
}
func NewSendStmt(parent Stmt, stmt *ast.SendStmt) *SendStmt {
return &SendStmt{SendStmt: stmt, parent: parent}
}
func (s *SendStmt) PrependStmt(st string) error {
return prependStmt(st, s.parent, s.SendStmt)
}
func (s *SendStmt) AppendStmt(st string) error {
return appendStmt(st, s.parent, s.SendStmt)
}
func (send *SendStmt) StmtType() StmtType {
return SendStmtType
}
func (send *SendStmt) Chan() Expr {
return NewExpr(send.SendStmt.Chan)
}
func (send *SendStmt) Value() Expr {
return NewExpr(send.SendStmt.Value)
}
// String returns a string representation of the SendStmt.
//
// It returns a string containing the channel and value being sent.
// The channel is obtained by calling the Chan() method, and the value
// is obtained by calling the Value() method.
// The resulting string is formatted as "%v <- %v".
func (send *SendStmt) String() string {
return fmt.Sprintf("%v <- %v", send.Chan(), send.Value())
}