Updated for Scope.
This commit is contained in:
parent
c2f2658e9c
commit
ff68b756ef
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "include/ast.h"
|
#include "include/ast.h"
|
||||||
#include "include/dstr.h"
|
#include "include/dstr.h"
|
||||||
#include "include/htab.h"
|
#include "include/scope.h"
|
||||||
#include "include/util.h"
|
#include "include/util.h"
|
||||||
|
|
||||||
extern AST* root;
|
extern AST* root;
|
||||||
@ -28,7 +28,7 @@ AST* ast_init(ASTType type, void* data) {
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST* ast_init_scope(ASTType type, void* data, HTab* scope) {
|
AST* ast_init_scope(ASTType type, void* data, Scope* scope) {
|
||||||
AST* ast = malloc(sizeof(AST));
|
AST* ast = malloc(sizeof(AST));
|
||||||
|
|
||||||
ast->type = type;
|
ast->type = type;
|
||||||
@ -53,8 +53,8 @@ void ast_destroy(AST* ast) {
|
|||||||
log_dbgf("Unknown ast type %d (max: %d)", ast->type, AST_TYPE_MAX);
|
log_dbgf("Unknown ast type %d (max: %d)", ast->type, AST_TYPE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope_destroy_psv(ast->scope);
|
||||||
free(ast);
|
free(ast);
|
||||||
htab_destroy(ast->scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_print(AST* ast) { ast_print_i(ast, 0); }
|
void ast_print(AST* ast) { ast_print_i(ast, 0); }
|
||||||
|
@ -9,12 +9,11 @@
|
|||||||
#include "include/stack.h"
|
#include "include/stack.h"
|
||||||
#include "include/util.h"
|
#include "include/util.h"
|
||||||
|
|
||||||
extern AST* root;
|
|
||||||
|
|
||||||
AST* exec_find(char* name);
|
AST* exec_find(char* name);
|
||||||
|
|
||||||
AST* exec_start(AST* ast) {
|
AST* exec_start(AST* ast) {
|
||||||
log_dbg("Started execution.");
|
log_dbg("Started execution.");
|
||||||
|
|
||||||
Stack* scope = stack_init();
|
Stack* scope = stack_init();
|
||||||
|
|
||||||
HTab* global = htab_init();
|
HTab* global = htab_init();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define AST_H
|
#define AST_H
|
||||||
|
|
||||||
#include "htab.h"
|
#include "htab.h"
|
||||||
|
#include "scope.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// The type of an `AST`.
|
// The type of an `AST`.
|
||||||
@ -32,13 +33,13 @@ typedef enum {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
ASTType type; // The type of the `AST`.
|
ASTType type; // The type of the `AST`.
|
||||||
void* data; // The data of the `AST`.
|
void* data; // The data of the `AST`.
|
||||||
HTab* scope; // The scope of the `AST`.
|
Scope* scope; // The scope of the `AST`.
|
||||||
} AST;
|
} AST;
|
||||||
|
|
||||||
// Create a new `AST`.
|
// Create a new `AST`.
|
||||||
AST* ast_init(ASTType type, void* data);
|
AST* ast_init(ASTType type, void* data);
|
||||||
// Create a new `AST` with a specified scope.
|
// Create a new `AST` with a specified scope.
|
||||||
AST* ast_init_scope(ASTType type, void* data, HTab* scope);
|
AST* ast_init_scope(ASTType type, void* data, Scope* scope);
|
||||||
// Destroy an `AST`, recursively.
|
// Destroy an `AST`, recursively.
|
||||||
void ast_destroy(AST* ast);
|
void ast_destroy(AST* ast);
|
||||||
// Print an `AST`, recursively.
|
// Print an `AST`, recursively.
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit cdf1d0297effc2736ee847e557b4275b4f02310b
|
Subproject commit 73237c5d224169c7b4d2ec8321f9ac92e8071708
|
Loading…
x
Reference in New Issue
Block a user