From 55c64a7d1cb3f1ddc18646b1d456de3606dded7c Mon Sep 17 00:00:00 2001 From: Elijah Cohen Date: Wed, 14 Aug 2024 14:43:55 -0500 Subject: [PATCH] committing now to run on different machine --- ideas.org | 13 +++++++++++++ src/eval.c | 2 +- src/test.c | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/ideas.org b/ideas.org index fdf7d0d..1f8dd50 100644 --- a/ideas.org +++ b/ideas.org @@ -1,3 +1,16 @@ +MEMORY MANAGEMENT +okay gonna start with making sure the parser is good... how? + +let's think about every single allocation needed for some statements: +(+ 4 6) +eval structure: + + + +================== + + + rewrite eq for quote? perhaps how do i deal with when/where things get unquoted? really hard to say... diff --git a/src/eval.c b/src/eval.c index cb99014..f5f2563 100644 --- a/src/eval.c +++ b/src/eval.c @@ -10,7 +10,7 @@ Sexpr* apply_builtin(Sexpr* func, Sexpr* arg, Sexpr* env); Sexpr* eval(Sexpr* s, Sexpr* dict) { - printf("s: %s\n", sprint_sexpr(s)); + //printf("s: %s\n", sprint_sexpr(s)); // non-null s // generally assumes that a sexpr passed to this is well-formed (ie no inapt NULLS) // question: does a completed builtin get evaluated here? diff --git a/src/test.c b/src/test.c index 52ade20..268d79e 100644 --- a/src/test.c +++ b/src/test.c @@ -7,7 +7,7 @@ #include "parser.h" #include "dict.h" #include "eval.h" - +#include "builtins.h" void test_basics() { @@ -83,18 +83,40 @@ void test_dict() { d = append_to_dict(d, from_sym("asdf"), from_uint(544)); printf("lookup hello: %s\n", sprint_sexpr(lookup(d, from_sym("hello")))); printf("lookup asdf: %s\n", sprint_sexpr(lookup(d, from_sym("asdf")))); +} - +void mem_parser() { + printf("starting parser memory testing\n"); + char* toparse = "(car (cons 1 (cons 2 nil)))"; + Sexpr* parsed; + while(1) { + parsed = parse(toparse); + sexpr_free(parsed); + } } +void mem_hammer() { + unsigned long i = 0; + Sexpr* env = init_dict(); + load_env(env); + char* eternalcmd = "(car (cons 1 (cons 2 nil)))"; + while(true) { + Sexpr* p = parse(eternalcmd); + eval(car(p), env); + printf("%lu\n", i); + i++; + } +} void run_tests(){ - test_basics(); - test2(); - test_parsing(); - test_parser(); - test_eq(); - test_dict(); + mem_parser(); + //mem_hammer(); + //test_basics(); + //test2(); + //test_parsing(); + //test_parser(); + //test_eq(); + //test_dict(); } int main() { -- 2.39.2