First working object tests!

This commit is contained in:
Nathan Braswell
2020-05-10 19:29:28 -04:00
parent 3f501a5c2f
commit f10630c66c
2 changed files with 24 additions and 9 deletions

23
bf.kp
View File

@@ -73,6 +73,18 @@
(def! to_be_saved (with-meta [1] [2]))
(def! to_be_saved_s "asdfasdf")
(let* ( a [0]
b (with-meta a (fn* () (set-nth! b 0 (+ 1 (nth b 0))))))
(do
(println "testing meta stuff!")
(println b)
((meta b))
(println b)
((meta b))
(println b)))
(def! our_obj (with-meta [0] (fn* () (set-nth! our_obj 0 (+ 1 (nth our_obj 0))))))
(def! main (fn* () (let* ( a 7
b [1]
c (with-meta b "yolo") )
@@ -88,6 +100,12 @@
(println to_be_saved)
(println (meta to_be_saved))
(println to_be_saved_s)
(println "Here in main testing our_obj")
(println our_obj)
((meta our_obj))
(println our_obj)
((meta our_obj))
(println our_obj)
a)))
)))))
(do
@@ -98,8 +116,3 @@

View File

@@ -1594,8 +1594,10 @@ fun find_closed_vars(defined: set<str>, env: *Env, ast: MalValue): set<str> {
MalValue_int::Symbol(s) {
if !defined.contains(s) {
var scope = env->find(s)
// null scope should mean top level var
if scope == null<Env>() {
error("Can't find " + s + " in env when trying to find closed_vars\n" + env->to_string())
/*error("Can't find " + s + " in env when trying to find closed_vars\n" + env->to_string())*/
return set<str>()
}
// don't do for top level vars
if scope->outer != null<Env>() {
@@ -1645,9 +1647,9 @@ fun compile_value(top_decs: *str, top_defs: *str, main_init: *str, defs: *str, e
return str("0x1F")
}
MalValue_int::Function(f) {
if quoted {
error("cannot compile quoted function - does this even make sense?")
}
/*if quoted {*/
/*error("cannot compile quoted function - does this even make sense?")*/
/*}*/
var fun_name = "fun_" + new_tmp()
*top_decs += "size_t " + fun_name + "(size_t*, size_t, size_t*);\n"