diff --git a/expr.go b/expr.go index ef095c0..1d94ef8 100644 --- a/expr.go +++ b/expr.go @@ -5,12 +5,10 @@ import ( "io/fs" "os" "path/filepath" - "reflect" "code.dny.dev/gopherxlr/dbus" "code.dny.dev/gopherxlr/websocket" "github.com/expr-lang/expr" - "github.com/expr-lang/expr/ast" "github.com/expr-lang/expr/vm" ) @@ -48,7 +46,7 @@ func LoadPrograms(dir string) ([]Program, error) { if err != nil { return err } - prog, err := expr.Compile(string(src), expr.Env(Env{}), expr.Patch(patcher{})) + prog, err := expr.Compile(string(src), expr.Env(Env{}), expr.WithContext("ctx")) if err != nil { return err } @@ -61,38 +59,3 @@ func LoadPrograms(dir string) ([]Program, error) { } return res, nil } - -type patcher struct{} - -// Until https://github.com/expr-lang/expr/pull/602 is merged -func (patcher) Visit(node *ast.Node) { - switch call := (*node).(type) { - case *ast.CallNode: - fn := call.Callee.Type() - if fn == nil { - return - } - if fn.Kind() != reflect.Func { - return - } - switch fn.NumIn() { - case 0: - return - case 1: - if fn.In(0).String() != "context.Context" { - return - } - default: - if fn.In(0).String() != "context.Context" && - fn.In(1).String() != "context.Context" { - return - } - } - ast.Patch(node, &ast.CallNode{ - Callee: call.Callee, - Arguments: append([]ast.Node{ - &ast.IdentifierNode{Value: "ctx"}, - }, call.Arguments...), - }) - } -} diff --git a/go.mod b/go.mod index 3bdd623..2244122 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.0 require ( github.com/evanphx/json-patch/v5 v5.9.0 - github.com/expr-lang/expr v1.16.1 + github.com/expr-lang/expr v1.16.5 github.com/godbus/dbus/v5 v5.1.0 golang.org/x/net v0.24.0 ) diff --git a/go.sum b/go.sum index f02c575..1386765 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= -github.com/expr-lang/expr v1.16.1 h1:Na8CUcMdyGbnNpShY7kzcHCU7WqxuL+hnxgHZ4vaz/A= -github.com/expr-lang/expr v1.16.1/go.mod h1:uCkhfG+x7fcZ5A5sXHKuQ07jGZRl6J0FCAaf2k4PtVQ= +github.com/expr-lang/expr v1.16.5 h1:m2hvtguFeVaVNTHj8L7BoAyt7O0PAIBaSVbjdHgRXMs= +github.com/expr-lang/expr v1.16.5/go.mod h1:uCkhfG+x7fcZ5A5sXHKuQ07jGZRl6J0FCAaf2k4PtVQ= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=