diff options
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -11,8 +11,7 @@ sym_t* eval(sym_t* symbol, hashtable_t* parentScope) { return init_sym_int(*((int*)symbol->name)); } else if (symbol->litType == FLOAT) { - /* TODO: float */ - return NULL; + return init_sym_float*((float*)symbol->name); } else if (symbol->litType == STRING) { return init_sym_str((char*)symbol->name); @@ -32,7 +31,6 @@ sym_t* eval(sym_t* symbol, hashtable_t* parentScope) { else { /* not an internal function, search hashtable for next symbol */ - /* TODO: scope */ pair_t p = hashtable_get_pair_recurse(parentScope, (char*)symbol->name); if (p.key != NULL) { sym_t* nextSym = (sym_t*)p.value; @@ -98,7 +96,6 @@ 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); sym_t* v; if (symbol->argCount > 1) { v = eval_with_args(eval(symbol->args[0], symbolScope), symbol->args + 1, symbol->argCount - 1, symbolScope); @@ -106,12 +103,10 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { else { v = eval(eval(symbol->args[0], symbolScope), symbolScope); } - //destroy_hashtable(newScope); return v; } else if (hash == get_hash("store")) { - /* first arg is value, remaining args are names */ - /* TODO: recursion for multiple pairs */ + /* first arg is value, second arg is key */ sym_t* v = eval(symbol->args[1], symbolScope); char* k = symtos(v); destroy_sym(v); @@ -122,8 +117,7 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { return init_sym_int(1); } else if (hash == get_hash("update")) { - /* first arg is value, remaining args are names */ - /* TODO: recursion for multiple pairs */ + /* first arg is value, second arg is key */ sym_t* v = eval(symbol->args[1], symbolScope); char* k = symtos(v); destroy_sym(v); @@ -133,7 +127,6 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { hashtable_update_pair_recurse(symbolScope->parent, p); return init_sym_int(1); } - /* TODO: release()/free() method? */ else if (hash == get_hash("eq")) { litType_t type = NO_TYPE; int firstInt = 0; @@ -195,7 +188,6 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { exec_all(symbol->args + 1, symbol->argCount - 1, symbolScope); return init_sym_int(1); } - /* TODO: free other args if condition fails */ return init_sym_int(0); } else if (hash == get_hash("not")) { |
