From 730c9462f0d0cfc18678fee06efc8ac5533c9437 Mon Sep 17 00:00:00 2001 From: k1LoW Date: Wed, 25 Dec 2024 15:24:44 +0900 Subject: [PATCH 1/2] Move eval to internal/eval --- alias.go | 32 ++++++++++++++++++++++ eval.go => internal/eval/eval.go | 4 +-- eval_test.go => internal/eval/eval_test.go | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 alias.go rename eval.go => internal/eval/eval.go (99%) rename eval_test.go => internal/eval/eval_test.go (99%) diff --git a/alias.go b/alias.go new file mode 100644 index 00000000..56127c0b --- /dev/null +++ b/alias.go @@ -0,0 +1,32 @@ +package runn + +import ( + "github.com/k1LoW/runn/internal/eval" + "github.com/k1LoW/runn/internal/exprtrace" +) + +func EvalWithTrace(e string, store exprtrace.EvalEnv) (*exprtrace.EvalResult, error) { + return eval.EvalWithTrace(e, store) +} + +func Eval(e string, store exprtrace.EvalEnv) (any, error) { + return eval.Eval(e, store) +} + +// EvalAny evaluate any type. but, EvalAny do not evaluate map key. +func EvalAny(e any, store exprtrace.EvalEnv) (any, error) { + return eval.EvalAny(e, store) +} + +func EvalCond(cond string, store exprtrace.EvalEnv) (bool, error) { + return eval.EvalCond(cond, store) +} + +func EvalCount(count string, store exprtrace.EvalEnv) (int, error) { + return eval.EvalCount(count, store) +} + +// EvalExpand evaluates `in` and expand `{{ }}` in `in` using `store`. +func EvalExpand(in any, store exprtrace.EvalEnv) (any, error) { + return eval.EvalExpand(in, store) +} diff --git a/eval.go b/internal/eval/eval.go similarity index 99% rename from eval.go rename to internal/eval/eval.go index bb812be0..3e7a5464 100644 --- a/eval.go +++ b/internal/eval/eval.go @@ -1,4 +1,4 @@ -package runn +package eval import ( "fmt" @@ -15,8 +15,8 @@ import ( "github.com/goccy/go-yaml" "github.com/k1LoW/expand" "github.com/k1LoW/runn/builtin" - "github.com/k1LoW/runn/internal/exprtrace" "github.com/k1LoW/runn/internal/deprecation" + "github.com/k1LoW/runn/internal/exprtrace" "github.com/xlab/treeprint" ) diff --git a/eval_test.go b/internal/eval/eval_test.go similarity index 99% rename from eval_test.go rename to internal/eval/eval_test.go index fb97ff17..cb315088 100644 --- a/eval_test.go +++ b/internal/eval/eval_test.go @@ -1,4 +1,4 @@ -package runn +package eval import ( "fmt" From c5b716b1a4bc3c49c9888605c86d9c46553fce22 Mon Sep 17 00:00:00 2001 From: k1LoW Date: Mon, 30 Dec 2024 15:36:38 +0900 Subject: [PATCH 2/2] bonsai --- operator.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/operator.go b/operator.go index 81c3c954..541f2dde 100644 --- a/operator.go +++ b/operator.go @@ -21,8 +21,8 @@ import ( "github.com/k1LoW/concgroup" "github.com/k1LoW/donegroup" "github.com/k1LoW/maskedio" - "github.com/k1LoW/runn/internal/exprtrace" "github.com/k1LoW/runn/internal/deprecation" + "github.com/k1LoW/runn/internal/exprtrace" "github.com/k1LoW/runn/internal/kv" "github.com/k1LoW/stopw" "github.com/k1LoW/waitmap" @@ -980,11 +980,7 @@ func (op *operator) run(ctx context.Context) error { select { case <-ctx.Done(): case v := <-op.nm.Chan(n.path): - if len(v.bindVars) > 0 { - op.store.needsVars[k] = v.bindVars - } else { - op.store.needsVars[k] = nil - } + op.store.needsVars[k] = v.bindVars } } var err error