58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
|
|
#ifndef APFL_CONTEXT_H
|
||
|
|
#define APFL_CONTEXT_H
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
#include "bytecode.h"
|
||
|
|
#include "hashmap.h"
|
||
|
|
#include "gc.h"
|
||
|
|
#include "value.h"
|
||
|
|
|
||
|
|
struct stack {
|
||
|
|
struct apfl_value *items;
|
||
|
|
size_t len;
|
||
|
|
size_t cap;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct scope {
|
||
|
|
struct apfl_hashmap map;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct apfl_ctx_data {
|
||
|
|
struct gc gc;
|
||
|
|
|
||
|
|
struct scope *scope;
|
||
|
|
struct stack *stack;
|
||
|
|
|
||
|
|
int execution_line;
|
||
|
|
};
|
||
|
|
|
||
|
|
void apfl_stack_deinit(struct apfl_allocator, struct stack *);
|
||
|
|
void apfl_gc_stack_traverse(struct stack *, gc_visitor, void *);
|
||
|
|
|
||
|
|
void apfl_scope_deinit(struct apfl_allocator, struct scope *);
|
||
|
|
|
||
|
|
bool apfl_scope_get(struct scope *, struct apfl_string *name, struct apfl_value *out);
|
||
|
|
bool apfl_scope_set(struct gc *, struct scope *, struct apfl_string *name, struct apfl_value value);
|
||
|
|
bool apfl_scope_create_var(struct gc *, struct scope *, struct apfl_string *name);
|
||
|
|
|
||
|
|
|
||
|
|
void apfl_gc_var_traverse(struct apfl_value *, gc_visitor, void *);
|
||
|
|
void apfl_gc_scope_traverse(struct scope *, gc_visitor, void *);
|
||
|
|
|
||
|
|
bool apfl_stack_push(apfl_ctx, struct apfl_value);
|
||
|
|
bool apfl_stack_check_index(apfl_ctx, apfl_stackidx *);
|
||
|
|
bool apfl_stack_pop(apfl_ctx, struct apfl_value *value, apfl_stackidx);
|
||
|
|
bool apfl_stack_get(apfl_ctx, struct apfl_value *value, apfl_stackidx);
|
||
|
|
bool apfl_stack_drop(apfl_ctx, apfl_stackidx);
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif
|