File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ func (l *Lifter) convert(node bast.Node) hast.Node {
4242 return & hast.Ident {Name : node .Name }
4343 case * bast.Word :
4444 return & hast.Ident {Name : node .Val }
45+ case * bast.FuncDecl :
46+ return l .convertFuncDecl (node )
47+ case * bast.AssignStmt :
48+ return l .convertAssignStmt (node )
4549 default :
4650 panic (fmt .Sprintf ("unknown node type: %T" , node ))
4751 }
@@ -72,3 +76,21 @@ func (l *Lifter) convertCmdExpr(cmd *bast.CmdExpr) hast.Node {
7276 Recv : args ,
7377 }
7478}
79+
80+ func (l * Lifter ) convertFuncDecl (decl * bast.FuncDecl ) hast.Node {
81+ body := & hast.BlockStmt {}
82+ for _ , stmt := range decl .Body .List {
83+ body .List = append (body .List , l .convert (stmt ).(hast.Stmt ))
84+ }
85+ return & hast.FuncDecl {
86+ Name : & hast.Ident {Name : decl .Name .Name },
87+ Body : body ,
88+ }
89+ }
90+
91+ func (l * Lifter ) convertAssignStmt (stmt * bast.AssignStmt ) hast.Node {
92+ return & hast.AssignStmt {
93+ Lhs : l .convert (stmt .Lhs ).(hast.Expr ),
94+ Rhs : l .convert (stmt .Rhs ).(hast.Expr ),
95+ }
96+ }
You can’t perform that action at this time.
0 commit comments