2019-01-09 10:17:42 +03:00
|
|
|
package ast
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
"github.com/d5/tengo/source"
|
2019-01-09 10:17:42 +03:00
|
|
|
"github.com/d5/tengo/token"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AssignStmt struct {
|
|
|
|
Lhs []Expr
|
|
|
|
Rhs []Expr
|
|
|
|
Token token.Token
|
2019-01-11 12:16:34 +03:00
|
|
|
TokenPos source.Pos
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AssignStmt) stmtNode() {}
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
func (s *AssignStmt) Pos() source.Pos {
|
2019-01-09 10:17:42 +03:00
|
|
|
return s.Lhs[0].Pos()
|
|
|
|
}
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
func (s *AssignStmt) End() source.Pos {
|
2019-01-09 10:17:42 +03:00
|
|
|
return s.Rhs[len(s.Rhs)-1].End()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AssignStmt) String() string {
|
|
|
|
var lhs, rhs []string
|
|
|
|
for _, e := range s.Lhs {
|
|
|
|
lhs = append(lhs, e.String())
|
|
|
|
}
|
|
|
|
for _, e := range s.Rhs {
|
|
|
|
rhs = append(rhs, e.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
return strings.Join(lhs, ", ") + " " + s.Token.String() + " " + strings.Join(rhs, ", ")
|
|
|
|
}
|