+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...
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?
#include "parser.h"
#include "dict.h"
#include "eval.h"
-
+#include "builtins.h"
void test_basics() {
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() {