File tree Expand file tree Collapse file tree 1 file changed +21
-21
lines changed
Expand file tree Collapse file tree 1 file changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,27 @@ func expandMacro(expr types.Expr) (types.Expr, error) {
6666 return result , nil
6767}
6868
69+ // doExpandMacro expands macro's expression recursively
70+ func doExpandMacro (expr types.Expr ) (types.Value , error ) {
71+ op := expr .Op ()
72+ if ! op .IsMacro () {
73+ return expr , nil
74+ }
75+ args := expr .Args ()
76+ for i := range args {
77+ if inner , ok := args [i ].(types.Expr ); ok {
78+ v , err := doExpandMacro (inner )
79+ if err != nil {
80+ return nil , err
81+ }
82+ args [i ] = v
83+ }
84+ }
85+ // XXX: should we care rollback function?
86+ val , _ , err := op .EvalExpr (context .Background (), args )
87+ return val , err
88+ }
89+
6990func writeTrxLog (ctx context.Context , expr types.Expr ) error {
7091 deparsed , err := Deparse (expr )
7192 if err != nil {
@@ -101,24 +122,3 @@ func writeTrxLog(ctx context.Context, expr types.Expr) error {
101122 }
102123 return nil
103124}
104-
105- // doExpandMacro expands macro's expression recursively
106- func doExpandMacro (expr types.Expr ) (types.Value , error ) {
107- op := expr .Op ()
108- if ! op .IsMacro () {
109- return expr , nil
110- }
111- args := expr .Args ()
112- for i := range args {
113- if inner , ok := args [i ].(types.Expr ); ok {
114- v , err := doExpandMacro (inner )
115- if err != nil {
116- return nil , err
117- }
118- args [i ] = v
119- }
120- }
121- // XXX: should we care rollback function?
122- val , _ , err := op .EvalExpr (context .Background (), args )
123- return val , err
124- }
You can’t perform that action at this time.
0 commit comments