summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2023-02-18 23:27:30 -0800
committerKai Stevenson <kai@kaistevenson.com>2023-02-18 23:27:30 -0800
commit51659aa7b33baa490a614255996f3e372e86a67c (patch)
tree594fdd6abe4f28cff477d63af37933fdb90a6005
parente8df5cd395569ddd944900ec7f22236db491b5a8 (diff)
fixed eval() scoping
-rw-r--r--examples/helloworld1.pcdt1
-rw-r--r--examples/helloworld2.pcdt2
-rw-r--r--examples/recursion.pcdt2
-rw-r--r--examples/scopetest.pcdt2
-rw-r--r--src/eval.c8
5 files changed, 6 insertions, 9 deletions
diff --git a/examples/helloworld1.pcdt b/examples/helloworld1.pcdt
deleted file mode 100644
index a52e207..0000000
--- a/examples/helloworld1.pcdt
+++ /dev/null
@@ -1 +0,0 @@
-store(hello world; hlVar;)
diff --git a/examples/helloworld2.pcdt b/examples/helloworld2.pcdt
deleted file mode 100644
index 084ce45..0000000
--- a/examples/helloworld2.pcdt
+++ /dev/null
@@ -1,2 +0,0 @@
-@helloworld1.pcdt
-store(print(hlVar()) HelloWorldFunc;)
diff --git a/examples/recursion.pcdt b/examples/recursion.pcdt
index 88b81f5..3f57a6e 100644
--- a/examples/recursion.pcdt
+++ b/examples/recursion.pcdt
@@ -1,2 +1,2 @@
-store( (print(arg0()) incFunc(sum(1; arg0())) ) incFunc;)
+store( ref((print(arg0()) incFunc(sum(1; arg0())))) incFunc;)
incFunc(0;)
diff --git a/examples/scopetest.pcdt b/examples/scopetest.pcdt
index 2aeb6ad..78418e2 100644
--- a/examples/scopetest.pcdt
+++ b/examples/scopetest.pcdt
@@ -1,2 +1,2 @@
-store(ref(print(hello;)) myFunc;)
+store(ref(ref(print(hello;))) myFunc;)
eval(myFunc())
diff --git a/src/eval.c b/src/eval.c
index 8319676..1f87bf5 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -98,15 +98,15 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) {
return symbol->args[0];
}
else if (hash == get_hash("eval")) {
- hashtable_t* newScope = init_hashtable(50, symbolScope);
+ //hashtable_t* newScope = init_hashtable(50, symbolScope);
sym_t* v;
if (symbol->argCount > 1) {
- v = eval_with_args(eval(symbol->args[0], symbolScope), symbol->args + 1, symbol->argCount - 1, newScope);
+ v = eval_with_args(eval(symbol->args[0], symbolScope), symbol->args + 1, symbol->argCount - 1, symbolScope);
}
else {
- v = eval(eval(symbol->args[0], symbolScope), newScope);
+ v = eval(eval(symbol->args[0], symbolScope), symbolScope);
}
- destroy_hashtable(newScope);
+ //destroy_hashtable(newScope);
return v;
}
else if (hash == get_hash("store")) {