Forked from
Michal Vlasák / ni-run-template
10 commits behind, 31 commits ahead of the upstream repository.
-
Michal Štěpánek authoredMichal Štěpánek authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ast_interpreter.h 1.25 KiB
#pragma once
#include "parser.h"
#include "heap.h"
/*typedef struct Object {
struct Value * extends;
size_t member_cnt;
SimpleEntry members [];
} Object;
typedef struct Array {
i32 length;
Value * members [];
} Array;*/
typedef struct EnvironmentEntry {
struct EnvironmentEntry * next;
Str name;
Value * value;
} EnvironmentEntry;
typedef struct Environment {
struct Environment * prev;
EnvironmentEntry * start;
} Environment;
typedef struct ASTInterpreterState {
Heap * heap;
Environment global_env;
Environment * current_env;
} ASTInterpreterState;
void env_push ( ASTInterpreterState * state );
void env_pop ( ASTInterpreterState * state );
Value * env_get ( ASTInterpreterState * state, Str name );
void env_put ( ASTInterpreterState * state, Str name, Value * value );
void env_def ( ASTInterpreterState * state, Str name, Value * value );
void state_init ( ASTInterpreterState * state, Heap * heap );
void state_destroy ( ASTInterpreterState * state );
Value * function_call ( ASTInterpreterState * state, Value * callee, bool is_function, Ast ** arguments, size_t argc, Str * name );
void print_value ( Value * value );
void fml_print ( Str format, Value ** args, size_t argc );
Value * evaluate ( ASTInterpreterState * state, Ast * ast );