parent
bbb2cb471e
commit
011ed937fe
|
@ -195,6 +195,14 @@ void deleteEnv(struct Environment* e)
|
|||
if (e->outer) {
|
||||
deleteEnv(e->outer);
|
||||
}
|
||||
|
||||
for (int i = 0; i < e->structCount; i++) {
|
||||
free(e->structDefs[i].name);
|
||||
for (int j = 0; j < e->structDefs[i].fieldCount; j++) {
|
||||
free(e->structDefs[j].names);
|
||||
}
|
||||
}
|
||||
|
||||
if (e->strings) {
|
||||
int i = 0;
|
||||
while (e->strings[i]) {
|
||||
|
@ -208,6 +216,7 @@ void deleteEnv(struct Environment* e)
|
|||
free(e->objects);
|
||||
e->objects = NULL;
|
||||
}
|
||||
free(e->structDefs);
|
||||
}
|
||||
|
||||
struct symFunc {
|
||||
|
|
|
@ -541,8 +541,8 @@ void cleanObject(Object* target)
|
|||
break;
|
||||
case TYPE_ERROR:
|
||||
#ifndef SIMPLE_ERRORS
|
||||
//free(target->error->context);
|
||||
//free(target->error);
|
||||
free(target->error->context);
|
||||
free(target->error);
|
||||
target->error = NULL;
|
||||
#endif
|
||||
break;
|
||||
|
|
|
@ -70,9 +70,9 @@ Object evalStructArgs(const Object* symbol, const Object* fields, struct Environ
|
|||
}
|
||||
|
||||
struct StructDef def;
|
||||
//def.name = name;
|
||||
def.name = malloc(sizeof(char) * (strlen(name) + 1));
|
||||
strcpy(def.name, name);
|
||||
|
||||
def.fieldCount = listLength(fields);
|
||||
def.names = malloc(sizeof(char*) * def.fieldCount);
|
||||
|
||||
|
@ -88,7 +88,6 @@ Object evalStructArgs(const Object* symbol, const Object* fields, struct Environ
|
|||
}
|
||||
|
||||
env->structDefs[env->structCount] = def;
|
||||
//printStructDef(&env->structDefs[env->structCount]);
|
||||
env->structCount += 1;
|
||||
if (env->structCount == env->structCapacity) {
|
||||
struct StructDef* prev = env->structDefs;
|
||||
|
@ -96,8 +95,6 @@ Object evalStructArgs(const Object* symbol, const Object* fields, struct Environ
|
|||
env->structCapacity *= 2;
|
||||
env->structDefs = malloc(sizeof(struct StructDef) * env->structCapacity);
|
||||
printf("Can malloc\n");
|
||||
//memcpy(env->structDefs, prev, sizeof(struct StructDef) * prevCapacity);
|
||||
//printf("Can memcpy\n");
|
||||
for (int i = 0; i < prevCapacity; i++) {
|
||||
env->structDefs[i] = prev[i];
|
||||
}
|
||||
|
@ -319,7 +316,6 @@ Object evalList(const Object* obj, struct Environment* env)
|
|||
cleanObject(&builtIn);
|
||||
}
|
||||
|
||||
//struct StructDef *def = NULL;
|
||||
int def = -1;
|
||||
if (first_form->type == TYPE_SYMBOL) {
|
||||
struct Environment* outerEnv = env;
|
||||
|
@ -423,7 +419,7 @@ Object reduce(const Object listInitial, const Object func, struct Environment* e
|
|||
//Object oldTotal = total;
|
||||
total = eval(&funcList, env);
|
||||
//cleanObject(&oldTotal);
|
||||
//cleanObject(&funcList);
|
||||
cleanObject(&funcList);
|
||||
//cleanObject(¤t);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue