You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
631 B
38 lines
631 B
8 years ago
|
package gogen
|
||
|
|
||
|
import "go/ast"
|
||
|
|
||
|
type CallFunction struct {
|
||
|
Func Expression
|
||
|
Params []Expression
|
||
|
}
|
||
|
|
||
|
func (me CallFunction) Statement() ast.Stmt {
|
||
|
return &ast.ExprStmt{
|
||
|
X: me.Expression(),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (me CallFunction) Expression() ast.Expr {
|
||
|
params := make([]ast.Expr, len(me.Params))
|
||
|
for i, param := range me.Params {
|
||
|
params[i] = param.Expression()
|
||
|
}
|
||
|
return &ast.CallExpr{
|
||
|
Fun: me.Func.Expression(),
|
||
|
Args: params,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// TODO: Bad name, change it
|
||
|
type Functor struct {
|
||
|
Func Expression
|
||
|
}
|
||
|
|
||
|
func (me Functor) Call(params ...Expression) CallFunction {
|
||
|
return CallFunction{
|
||
|
Func: me.Func,
|
||
|
Params: params,
|
||
|
}
|
||
|
}
|