Start removing old cursed stack frame scope code.
It never really worked anyway.
This commit is contained in:
parent
3e80f6430d
commit
c2f2658e9c
15
src/exec.c
15
src/exec.c
@ -15,7 +15,7 @@ AST* exec_find(char* name);
|
|||||||
|
|
||||||
AST* exec_start(AST* ast) {
|
AST* exec_start(AST* ast) {
|
||||||
log_dbg("Started execution.");
|
log_dbg("Started execution.");
|
||||||
scope = stack_init();
|
Stack* scope = stack_init();
|
||||||
|
|
||||||
HTab* global = htab_init();
|
HTab* global = htab_init();
|
||||||
|
|
||||||
@ -47,13 +47,13 @@ AST* exec_block(AST* ast) {
|
|||||||
ASTBlockData* block = (ASTBlockData*)ast->data;
|
ASTBlockData* block = (ASTBlockData*)ast->data;
|
||||||
|
|
||||||
HTab* local = htab_init();
|
HTab* local = htab_init();
|
||||||
stack_push(scope, local);
|
//stack_push(scope, local);
|
||||||
|
|
||||||
// Loop through all but last ast.
|
// Loop through all but last ast.
|
||||||
for (int i = 0; i < block->ln - 1; i++) exec_exp(block->inside[i]);
|
for (int i = 0; i < block->ln - 1; i++) exec_exp(block->inside[i]);
|
||||||
AST* last = exec_exp(block->inside[block->ln - 1]);
|
AST* last = exec_exp(block->inside[block->ln - 1]);
|
||||||
|
|
||||||
stack_pop(scope);
|
//stack_pop(scope);
|
||||||
htab_destroy(local);
|
htab_destroy(local);
|
||||||
|
|
||||||
return last;
|
return last;
|
||||||
@ -88,7 +88,7 @@ AST* exec_cf(AST* ast, size_t argc, AST** argv) {
|
|||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
char* key = ((ASTArgData*)fdef->argv[i]->data)->name;
|
char* key = ((ASTArgData*)fdef->argv[i]->data)->name;
|
||||||
AST* val = argv[i];
|
AST* val = argv[i];
|
||||||
htab_ins(scope->buf[scope->ln - 1], key, val);
|
//htab_ins(scope->buf[scope->ln - 1], key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
return exec_exp(fdef->body);
|
return exec_exp(fdef->body);
|
||||||
@ -97,11 +97,12 @@ AST* exec_cf(AST* ast, size_t argc, AST** argv) {
|
|||||||
AST* exec_find(char* name) {
|
AST* exec_find(char* name) {
|
||||||
AST* val = NULL;
|
AST* val = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
for (int i = scope->ln - 1; i >= 0; i--) {
|
for (int i = scope->ln - 1; i >= 0; i--) {
|
||||||
HTab* lvl = scope->buf[i];
|
HTab* lvl = scope->buf[i];
|
||||||
val = htab_get(lvl, name);
|
val = htab_get(lvl, name);
|
||||||
if (val != NULL) return val;
|
if (val != NULL) return val;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -110,7 +111,7 @@ AST* exec_vdef(AST* ast) {
|
|||||||
ASTVDefData* data = (ASTVDefData*)ast->data;
|
ASTVDefData* data = (ASTVDefData*)ast->data;
|
||||||
AST* val = data->val;
|
AST* val = data->val;
|
||||||
char* key = data->name;
|
char* key = data->name;
|
||||||
htab_ins(scope->buf[scope->ln - 1], key, val);
|
//htab_ins(scope->buf[scope->ln - 1], key, val);
|
||||||
return exec_exp(val);
|
return exec_exp(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ AST* exec_fdef(AST* ast) {
|
|||||||
ASTFDefData* fdef = (ASTFDefData*)ast->data;
|
ASTFDefData* fdef = (ASTFDefData*)ast->data;
|
||||||
AST* val = fdef->body;
|
AST* val = fdef->body;
|
||||||
char* key = fdef->name;
|
char* key = fdef->name;
|
||||||
htab_ins(scope->buf[scope->ln - 1], key, val);
|
//htab_ins(scope->buf[scope->ln - 1], key, val);
|
||||||
return val; // Function definitions return function body.
|
return val; // Function definitions return function body.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
|
|
||||||
// The `Stack` of `HTab` that makes up the scope of any given `AST`.
|
|
||||||
extern Stack* scope;
|
|
||||||
|
|
||||||
// Start executing at the root of the AST. Initialize the `scope`.
|
// Start executing at the root of the AST. Initialize the `scope`.
|
||||||
AST* exec_start(AST* ast);
|
AST* exec_start(AST* ast);
|
||||||
// Execute an expression. Delegates to the other executor functions.
|
// Execute an expression. Delegates to the other executor functions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user