xgo/compiler/ast/call_expr.go

37 lines
709 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"strings"
2019-01-11 13:27:28 +03:00
"github.com/d5/tengo/compiler/source"
2019-01-09 10:17:42 +03:00
)
// CallExpr represents a function call expression.
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() {}
// Pos returns the position of first character belonging to the node.
func (e *CallExpr) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return e.Func.Pos()
}
// End returns the position of first character immediately after the node.
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, ", ") + ")"
}