Skip to content

Commit

Permalink
Move global-ctx to bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhanshuguptagit committed Feb 23, 2024
1 parent f859f29 commit ea420ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
11 changes: 9 additions & 2 deletions src/bean/grid.cljs
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
(ns bean.grid
(:require [bean.area :as area]
[bean.tables :as tables]
[bean.code-errors :as code-errors]
[bean.deps :as deps]
[bean.errors :as errors]
[bean.functions :as functions]
[bean.interpreter :as interpreter]
[bean.parser.parser :as parser]
[bean.parser.trellis-parser :as trellis-parser]
[bean.tables :as tables]
[bean.util :as util]
[bean.value :as value]
[clojure.set :as set]
[clojure.string]))

(def default-bindings
{"concat" {:scalar functions/bean-concat
:representation "f"}
"error" {:scalar functions/bean-error
:representation "f"}})

(defn- offset [[start-r start-c] [offset-rows offset-cols]]
[(+ start-r offset-rows) (+ start-c offset-cols)])

Expand Down Expand Up @@ -145,7 +152,7 @@
{:grid parsed-grid
:code code
:tests tests
:bindings {}
:bindings default-bindings
:depgraph (deps/make-depgraph parsed-grid)})))

(defn- escalate-bindings-errors [sheet]
Expand Down
9 changes: 1 addition & 8 deletions src/bean/interpreter.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns bean.interpreter
(:require [bean.functions :as functions]
[bean.util :as util]
(:require [bean.util :as util]
[bean.errors :as errors]
[bean.operators :as operators]))

Expand Down Expand Up @@ -70,11 +69,6 @@
rmatrix (apply-results #(apply %1 [%3 %2]) [op left] rmatrix)
:else (apply-results #(apply %1 [%2 %3]) [op left right]))))

(def global-ctx
{"concat" {:scalar functions/bean-concat
:representation "f"}
"error" {:scalar functions/bean-error
:representation "f"}})

(declare apply-f)

Expand All @@ -97,7 +91,6 @@
(apply util/matrix-bounds)
(apply eval-matrix*))}
:Name (or (get bindings arg)
(get global-ctx arg)
(errors/undefined-named-ref arg))
:FunctionDefinition (fn-result arg)
:FunctionInvocation (apply-f sheet
Expand Down

0 comments on commit ea420ab

Please sign in to comment.