Skip to content
Snippets Groups Projects
ast_interpreter.h 1.25 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include "parser.h"
    
      struct Value * extends;
      size_t member_cnt;
      SimpleEntry members [];
    } Object;
    
    typedef struct Array {
      i32 length;
      Value * members [];
    
    typedef struct EnvironmentEntry {
      struct EnvironmentEntry * next;
      Str name;
    
    } 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 );