mirror of
https://github.com/janet-lang/janet
synced 2025-06-11 19:14:13 +00:00
Add :fiber-flags options to run-context.
This also improves eval-string error behavior.
This commit is contained in:
parent
adaa014d7c
commit
0ee2ff1b05
@ -1477,7 +1477,8 @@ value, one key will be ignored."
|
|||||||
:env - the environment to compile against - default is *env*\n\t
|
:env - the environment to compile against - default is *env*\n\t
|
||||||
:source - string path of source for better errors - default is \"<anonymous>\"\n\t
|
:source - string path of source for better errors - default is \"<anonymous>\"\n\t
|
||||||
:on-compile-error - callback when compilation fails - default is bad-compile\n\t
|
:on-compile-error - callback when compilation fails - default is bad-compile\n\t
|
||||||
:on-status - callback when a value is evaluated - default is debug/stacktrace"
|
:on-status - callback when a value is evaluated - default is debug/stacktrace\n\t
|
||||||
|
:fiber-flags - what flags to wrap the compilation fiber with. Default is :a."
|
||||||
[opts]
|
[opts]
|
||||||
|
|
||||||
(def {:env env
|
(def {:env env
|
||||||
@ -1485,6 +1486,7 @@ value, one key will be ignored."
|
|||||||
:on-status onstatus
|
:on-status onstatus
|
||||||
:on-compile-error on-compile-error
|
:on-compile-error on-compile-error
|
||||||
:on-parse-error on-parse-error
|
:on-parse-error on-parse-error
|
||||||
|
:fiber-flags guard
|
||||||
:source where} opts)
|
:source where} opts)
|
||||||
(default env *env*)
|
(default env *env*)
|
||||||
(default chunks getline)
|
(default chunks getline)
|
||||||
@ -1516,7 +1518,7 @@ value, one key will be ignored."
|
|||||||
(string err " at (" start ":" end ")")
|
(string err " at (" start ":" end ")")
|
||||||
err))
|
err))
|
||||||
(on-compile-error msg errf where))))
|
(on-compile-error msg errf where))))
|
||||||
:a))
|
(or guard :a)))
|
||||||
(def res (resume f nil))
|
(def res (resume f nil))
|
||||||
(when good (if going (onstatus f res))))
|
(when good (if going (onstatus f res))))
|
||||||
|
|
||||||
@ -1563,14 +1565,18 @@ value, one key will be ignored."
|
|||||||
(buffer/push-string buf str)
|
(buffer/push-string buf str)
|
||||||
(buffer/push-string buf "\n")))
|
(buffer/push-string buf "\n")))
|
||||||
(var returnval nil)
|
(var returnval nil)
|
||||||
|
(defn error1 [x &] (error x))
|
||||||
(run-context {:env env
|
(run-context {:env env
|
||||||
:chunks chunks
|
:chunks chunks
|
||||||
:on-compile-error error
|
:on-compile-error (fn [msg errf &]
|
||||||
:on-parse-error error
|
(error (string "compile error: " msg)))
|
||||||
|
:on-parse-error (fn [p x]
|
||||||
|
(error (string "parse error: " (parser/error p))))
|
||||||
|
:fiber-flags :
|
||||||
:on-status (fn [f val]
|
:on-status (fn [f val]
|
||||||
(set returnval val)
|
|
||||||
(if-not (= (fiber/status f) :dead)
|
(if-not (= (fiber/status f) :dead)
|
||||||
(debug/stacktrace f val)))
|
(error val))
|
||||||
|
(set returnval val))
|
||||||
:source "eval"})
|
:source "eval"})
|
||||||
returnval)
|
returnval)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user