No matching definitions.

myplugin/core

stdlib/turi/eval.tur
defn

Env/new

(Env/new :ptr<void>)

create a new unrestricted evaluation environment.

Opaque TuriEnv handle as ptr<void>.

(let [env (Env/new)] ... (Env/free env))

Since: Phase S2

defn

Env/new-sandboxed

(Env/new-sandboxed :ptr<void>)

create a sandboxed environment with I/O and FFI disabled.

Opaque TuriEnv handle as ptr<void>.

Since: Phase S2

defn

Env/free

(Env/free [env :ptr<void>] :void)

free all resources owned by an environment.

envTuriEnv handle returned by Env/new or Env/new-sandboxed

Since: Phase S2

defn

eval

(eval [env :ptr<void> src :cstr] :ptr<void>)

evaluate a Turmeric source string and return a boxed result.

envTuriEnv evaluation environment
srcTurmeric source code string

Boxed TuriValue as ptr<void>; free with eval-free when done.

(eval env "(+ 40 2)")

Since: Phase S2

defn

eval-file

(eval-file [env :ptr<void> path :cstr] :ptr<void>)

evaluate a file's contents in the given environment.

envTuriEnv evaluation environment
pathpath to the .tur file to evaluate

Boxed TuriValue as ptr<void>; free with eval-free when done.

Since: Phase S2

defn

eval!

(eval! [env :ptr<void> src :cstr] :ptr<void>)

evaluate a source string and panic on error.

envTuriEnv evaluation environment
srcTurmeric source code string

Boxed TuriValue as ptr<void>; free with eval-free when done.

Since: Phase S2

defn

eval-free

(eval-free [result :ptr<void>] :void)

free a boxed TuriValue returned by eval or eval-file.

resultptr<void> previously returned by eval, eval-file, or eval!

Since: Phase S2

defn

eval-ok?

(eval-ok? [result :ptr<void>] :bool)

return true if the eval result is not an error.

resultboxed TuriValue

true if the result has a non-error tag.

(when (eval-ok? r) (eval-as-int r))

Since: Phase S2

defn

eval-err?

(eval-err? [result :ptr<void>] :bool)

return true if the eval result is an error.

resultboxed TuriValue

true if the result has the TURI_ERROR tag or is NULL.

Since: Phase S2

defn

eval-err-msg

(eval-err-msg [result :ptr<void>] :cstr)

extract the error message from an error result.

resultboxed TuriValue (should satisfy eval-err?)

Error message string, or "<not-an-error>" if result is not an error.

Since: Phase S2

defn

eval-as-int

(eval-as-int [result :ptr<void>] :int)

extract the integer value from a TURI_INT result.

resultboxed TuriValue with TURI_INT tag

Integer value, or 0 if result is not TURI_INT.

(eval-as-int (eval env "(+ 40 2)"))  ; => 42

Since: Phase S2

defn

eval-as-bool

(eval-as-bool [result :ptr<void>] :bool)

extract the boolean value from a TURI_BOOL result.

resultboxed TuriValue with TURI_BOOL tag

Boolean value, or false if result is not TURI_BOOL.

Since: Phase S2

defn

eval-as-cstr

(eval-as-cstr [result :ptr<void>] :cstr)

extract the string value from a TURI_CSTR result.

resultboxed TuriValue with TURI_CSTR tag

C string value, or "" if result is not TURI_CSTR.

Since: Phase S2

defn

eval-tag

(eval-tag [result :ptr<void>] :int)

return the numeric tag of a TuriValue result.

resultboxed TuriValue

Integer tag: 0=nil 1=bool 2=int 3=float 4=cstr 5=closure 6=error.

Since: Phase S2