1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-18 17:27:40 +00:00

symbolslots now use janet_v vectors, flat structure

This commit is contained in:
Jona Ekenberg
2023-02-01 11:06:33 +01:00
parent 88813c4f87
commit 587aa87d28
9 changed files with 91 additions and 106 deletions

View File

@@ -106,4 +106,3 @@
(assert (= ((f 10) 37) 47) "asm environment tables")
(end-suite)

View File

@@ -3,25 +3,40 @@
(import ./helper :prefix "" :exit true)
(start-suite 15)
(assert (deep= (in (disasm (defn a [] (def x 10) x)) :slotsyms)
(assert (deep= (in (disasm (defn a [] (def x 10) x)) :symbolslots)
@[])
"no slotsyms when *debug* is false")
"no symbolslots when *debug* is false")
(setdyn *debug* true)
(assert (deep= (in (disasm (defn a [] (def x 10) x)) :slotsyms)
@[[:top :top @{"a" @[[0 0]] "x" @[[1 1]]}]])
"slotsyms when *debug* is true")
(assert (deep= (in (disasm (defn a [] (def x 10) x)) :symbolslots)
@[[0 2147483647 0 "a"] [1 2147483647 1 "x"]])
"symbolslots when *debug* is true")
(setdyn *debug* false)
# need to fix assembling functions
(comment
(setdyn *debug* true)
(def f (asm (disasm (fn [x] (fn [y] (+ x y))))))
(assert (deep= (in (disasm f) :symbolslots)
@[[0 2147483647 0 "a"] [1 2147483647 1 "x"]])
"symbolslots survive disasm/asm")
(setdyn *debug* false)
)
(setdyn *debug* true)
(assert (deep= (in (disasm (defn a []
(assert (deep= (in (disasm (defn a [arg]
(def x 10)
(do
(def y 20)
(+ x y)))) :slotsyms)
@[[:top :top @{"a" @[[0 0]] "x" @[[1 1]]}]
[2 5 @{"y" @[[2 2]]}]])
"inner slotsyms")
(def z 30)
(+ x y z)))) :symbolslots)
@[[-1 2147483647 0 "arg"]
[0 2147483647 1 "a"]
[1 2147483647 2 "x"]
[2 7 3 "y"]
[3 7 4 "z"]])
"arg & inner symbolslots")
(setdyn *debug* false)
(end-suite)