summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library.c8
-rw-r--r--src/runtime.c9
2 files changed, 10 insertions, 7 deletions
diff --git a/src/library.c b/src/library.c
index 9a40646..5b04e51 100644
--- a/src/library.c
+++ b/src/library.c
@@ -325,13 +325,7 @@ void pit_install_library_io(pit_runtime *rt) {
static pit_value impl_plist_get(pit_runtime *rt, pit_value args) {
pit_value k = pit_car(rt, args);
pit_value vs = pit_car(rt, pit_cdr(rt, args));
- while (vs != PIT_NIL) {
- if (pit_eq(k, pit_car(rt, vs))) {
- return pit_car(rt, pit_cdr(rt, vs));
- }
- vs = pit_cdr(rt, vs);
- }
- return PIT_NIL;
+ return pit_plist_get(rt, k, vs);
}
void pit_install_library_plist(pit_runtime *rt) {
/* property lists / keyword arguments */
diff --git a/src/runtime.c b/src/runtime.c
index fcfe81a..86c5fea 100644
--- a/src/runtime.c
+++ b/src/runtime.c
@@ -701,6 +701,15 @@ pit_value pit_contains_eq(pit_runtime *rt, pit_value needle, pit_value haystack)
}
return PIT_NIL;
}
+pit_value pit_plist_get(pit_runtime *rt, pit_value k, pit_value vs) {
+ while (vs != PIT_NIL) {
+ if (pit_eq(k, pit_car(rt, vs))) {
+ return pit_car(rt, pit_cdr(rt, vs));
+ }
+ vs = pit_cdr(rt, vs);
+ }
+ return PIT_NIL;
+}
pit_value pit_free_vars(pit_runtime *rt, pit_value bound, pit_value body) {
i64 expr_stack_reset = rt->expr_stack->top;