Skip to content

Commit 23bbeeb

Browse files
committed
fix: rename $expand-macro to $eval
1 parent 82ba9e9 commit 23bbeeb

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

_docs/json-dsl.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ Macros are not saved in transaction log (expanded before saving).
334334
* What value is returned depends on each operator's `InvertExpr()`
335335
implementation.
336336

337-
* `["$expand-macro", expr Value] Value`
337+
* `["$eval", expr Value] Value`
338338
* Evaluate `expr` at parsing time.
339339
This is useful to save evaluated value to transaction log,
340340
instead of its expression.
@@ -416,9 +416,9 @@ Macros are not saved in transaction log (expanded before saving).
416416
{target_hash}`
417417
* It does nothing for bare git repository.
418418
* e.g.
419-
* `["repos/git/update", "github.com/tyru/caw.vim", ["$expand-macro", ["repos/git/rev-parse", "HEAD", "github.com/tyru/caw.vim"]], ["$expand-macro", ["repos/git/fetch", "github.com/tyru/caw.vim"]]]`
419+
* `["repos/git/update", "github.com/tyru/caw.vim", ["$eval", ["repos/git/rev-parse", "HEAD", "github.com/tyru/caw.vim"]], ["$eval", ["repos/git/fetch", "github.com/tyru/caw.vim"]]]`
420420
* To save evaluated hash string in transaction log instead of its
421-
expression, apply `$expand-macro` to `repos/git/fetch` expression.
421+
expression, apply `$eval` to `repos/git/fetch` expression.
422422
* `["$invert", ["repos/git/update", path, target_hash, prev_hash]]` = `["repos/git/update", ["$invert", path], ["$invert", prev_hash], ["$invert", target_hash]]`
423423
424424
* `["repos/git/rev-parse", str string, path ReposPath] hash string`

dsl/op/eval.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package op
2+
3+
import (
4+
"context"
5+
6+
"github.com/vim-volt/volt/dsl/types"
7+
)
8+
9+
func init() {
10+
s := evalOp("$eval")
11+
EvalOp = &s
12+
macroMap[string(*EvalOp)] = EvalOp
13+
}
14+
15+
type evalOp string
16+
17+
// EvalOp is "$eval" operation
18+
var EvalOp *evalOp
19+
20+
// String returns "$eval"
21+
func (*evalOp) String() string {
22+
return string(*EvalOp)
23+
}
24+
25+
// Execute executes "$eval" operation
26+
func (*evalOp) Expand(args []types.Value) (types.Value, func(), error) {
27+
if err := signature(types.AnyValue).check(args); err != nil {
28+
return nil, NoRollback, err
29+
}
30+
return args[0].Eval(context.Background())
31+
}

dsl/op/expand_macro.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)