96 lines
2.7 KiB
C
96 lines
2.7 KiB
C
#ifndef MK_MOKA_H
|
|
#define MK_MOKA_H
|
|
|
|
#include "commons.h"
|
|
#include "vec.h"
|
|
#include "value.h"
|
|
#include "symtable.h"
|
|
|
|
struct frame
|
|
{
|
|
struct vec stack;
|
|
struct vec local_values;
|
|
};
|
|
|
|
struct moka_mod
|
|
{
|
|
char* name;
|
|
struct module* module;
|
|
};
|
|
|
|
struct moka
|
|
{
|
|
struct status* status;
|
|
struct symtable symtable;
|
|
struct vec frame_stack;
|
|
struct vec global_values;
|
|
struct vec modules;
|
|
};
|
|
|
|
void moka_mod_init(struct moka_mod* self,
|
|
char const* name,
|
|
struct module* new_module);
|
|
void moka_mod_free(struct moka_mod* self);
|
|
|
|
void moka_init(struct moka* self, struct status* status);
|
|
void frame_init(struct frame* self);
|
|
void frame_free(struct frame* self);
|
|
void moka_free(struct moka* self);
|
|
|
|
|
|
void moka_import_module(struct moka* self,
|
|
char const* name,
|
|
struct module* module);
|
|
|
|
struct module* moka_try_get_module(struct moka* self,
|
|
char const* name);
|
|
|
|
void moka_decl_var(struct moka* self,
|
|
char* name,
|
|
MOKA value);
|
|
|
|
void moka_decl_native(struct moka* self,
|
|
char* name,
|
|
native_fun_t fun);
|
|
|
|
struct frame* moka_frame(struct moka* self);
|
|
bool moka_has_top(struct moka* self);
|
|
MOKA moka_top(struct moka* self);
|
|
MOKA moka_pop(struct moka* self);
|
|
|
|
bool moka_is(struct moka* self, MOKA value, TypeKind type);
|
|
TypeKind moka_type_of(struct moka* self, MOKA value);
|
|
|
|
void moka_dump(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_make_array(struct moka* self, int elements_count);
|
|
MOKA moka_call(struct moka* self, int arg_count);
|
|
|
|
MOKA moka_push(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_push_int(struct moka* self, int value, int line);
|
|
int moka_get_int(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_push_float(struct moka* self, float value, int line);
|
|
float moka_get_float(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_push_bool(struct moka* self, bool value, int line);
|
|
float moka_get_bool(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_push_string(struct moka* self, char const* value, int line);
|
|
char* moka_get_string(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_push_symbol(struct moka* self, char const* value, int line);
|
|
char* moka_get_symbol(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_push_ref(struct moka* self, size_t value, int line);
|
|
size_t moka_get_ref(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_push_native(struct moka* self, native_fun_t value, int line);
|
|
native_fun_t moka_get_native(struct moka* self, MOKA value);
|
|
|
|
MOKA moka_eval_lazy(struct moka* self, MOKA lazy_value);
|
|
MOKA moka_push_lazy(struct moka* self, struct node* value, int line);
|
|
struct node* moka_get_lazy(struct moka* self, MOKA value);
|
|
#endif
|