xgo/ast/call_expr.go

34 lines
504 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"strings"
"github.com/d5/tengo/source"
2019-01-09 10:17:42 +03:00
)
type CallExpr struct {
Func Expr
LParen source.Pos
2019-01-09 10:17:42 +03:00
Args []Expr
RParen source.Pos
2019-01-09 10:17:42 +03:00
}
func (e *CallExpr) exprNode() {}
func (e *CallExpr) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return e.Func.Pos()
}
func (e *CallExpr) End() source.Pos {
2019-01-09 10:17:42 +03:00
return e.RParen + 1
}
func (e *CallExpr) String() string {
var args []string
for _, e := range e.Args {
args = append(args, e.String())
}
return e.Func.String() + "(" + strings.Join(args, ", ") + ")"
}