File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
src/main/clojure/cljs/repl Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 21
21
[cljs.stacktrace :as st])
22
22
(:import [javax.script ScriptEngine ScriptException]))
23
23
24
- (defn create-engine []
24
+ (defn- js-opt-key? [k]
25
+ (and (string? k)
26
+ (string/starts-with? k " js." )))
27
+
28
+ (defn- form-js-opts [opts]
29
+ (for [[k v] opts
30
+ :when (js-opt-key? k)]
31
+ `(.option ~k ~v)))
32
+
33
+ (defn create-engine [opts]
25
34
; ; In order to support AOT compilation by JVMs that don't have
26
35
; ; GraalVM available, we load and execute engine creation code
27
36
; ; here at runtime.
28
37
(import '(com.oracle.truffle.js.scriptengine GraalJSScriptEngine))
29
38
(import '(org.graalvm.polyglot Context))
30
- (let [engine (eval ' (GraalJSScriptEngine/create nil
39
+ (let [engine (eval ` (GraalJSScriptEngine/create nil
31
40
(-> (Context/newBuilder (make-array String 0 ))
41
+ ~@(form-js-opts opts)
32
42
(.allowHostAccess true )
33
43
(.allowCreateThread true )
34
44
(.allowNativeAccess true ))))
172
182
(fn [st]
173
183
(string/join " \n " (drop 1 (string/split st #"\n " )))))))
174
184
185
+ (def ^:private default-js-opts
186
+ {" js.precise-time" " true" })
187
+
175
188
(defn repl-env* [{:keys [debug] :as opts}]
176
- (let [engine (create-engine )]
189
+ (let [opts (merge default-js-opts opts)
190
+ engine (create-engine opts)]
177
191
(merge
178
192
(GraalJSEnv. engine debug)
179
193
opts)))
You can’t perform that action at this time.
0 commit comments