Command gencodec generates marshaling methods for Go struct types.
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.
gencodec/vendor/github.com/garslo/gogen/for.go

41 lines
631 B

package gogen
import "go/ast"
type For struct {
Init Statement
Condition Expression
Post Statement
Body []Statement
}
func (me For) Statement() ast.Stmt {
body := make([]ast.Stmt, len(me.Body))
for i, bodyPart := range me.Body {
body[i] = bodyPart.Statement()
}
var (
init ast.Stmt
cond ast.Expr
post ast.Stmt
)
if me.Init != nil {
init = me.Init.Statement()
}
if me.Condition != nil {
cond = me.Condition.Expression()
}
if me.Post != nil {
post = me.Post.Statement()
}
return &ast.ForStmt{
Init: init,
Cond: cond,
Post: post,
Body: &ast.BlockStmt{
List: body,
},
}
}