2016-02-14 10:50:02 -05:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PICRIN_STATE_H
|
|
|
|
#define PICRIN_STATE_H
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-03-28 10:09:40 -04:00
|
|
|
#include "khash.h"
|
|
|
|
#include "vm.h"
|
2016-02-14 10:50:02 -05:00
|
|
|
|
2016-02-21 06:32:00 -05:00
|
|
|
struct lib {
|
|
|
|
struct string *name;
|
|
|
|
struct env *env;
|
|
|
|
struct dict *exports;
|
2016-02-18 03:39:32 -05:00
|
|
|
};
|
2016-02-14 10:50:02 -05:00
|
|
|
|
2016-02-21 06:32:00 -05:00
|
|
|
struct callinfo {
|
2016-02-14 10:50:02 -05:00
|
|
|
int argc, retc;
|
2016-02-29 13:14:18 -05:00
|
|
|
const struct code *ip;
|
2016-02-14 10:50:02 -05:00
|
|
|
pic_value *fp;
|
2016-02-21 06:32:00 -05:00
|
|
|
struct irep *irep;
|
|
|
|
struct context *cxt;
|
2016-02-14 10:50:02 -05:00
|
|
|
int regc;
|
|
|
|
pic_value *regs;
|
2016-02-21 06:32:00 -05:00
|
|
|
struct context *up;
|
2016-02-21 06:18:31 -05:00
|
|
|
};
|
2016-02-14 10:50:02 -05:00
|
|
|
|
2016-02-21 06:32:00 -05:00
|
|
|
KHASH_DECLARE(oblist, struct string *, struct identifier *)
|
|
|
|
KHASH_DECLARE(ltable, const char *, struct lib)
|
2016-02-18 03:39:32 -05:00
|
|
|
|
2016-02-14 10:50:02 -05:00
|
|
|
struct pic_state {
|
|
|
|
pic_allocf allocf;
|
|
|
|
void *userdata;
|
|
|
|
|
2016-02-21 06:32:00 -05:00
|
|
|
struct checkpoint *cp;
|
2016-02-23 08:48:06 -05:00
|
|
|
struct cont *cc;
|
2016-02-14 10:50:02 -05:00
|
|
|
|
|
|
|
pic_value *sp;
|
|
|
|
pic_value *stbase, *stend;
|
|
|
|
|
2016-02-21 06:32:00 -05:00
|
|
|
struct callinfo *ci;
|
|
|
|
struct callinfo *cibase, *ciend;
|
2016-02-14 10:50:02 -05:00
|
|
|
|
2016-02-29 13:14:18 -05:00
|
|
|
const struct code *ip;
|
2016-02-14 10:50:02 -05:00
|
|
|
|
2016-02-23 13:59:51 -05:00
|
|
|
const char *lib;
|
2016-02-14 10:50:02 -05:00
|
|
|
|
|
|
|
pic_value features;
|
|
|
|
|
2016-02-14 22:59:58 -05:00
|
|
|
khash_t(oblist) oblist; /* string to symbol */
|
2016-02-14 10:50:02 -05:00
|
|
|
int ucnt;
|
2016-02-19 14:35:15 -05:00
|
|
|
pic_value globals; /* weak */
|
|
|
|
pic_value macros; /* weak */
|
2016-02-18 03:39:32 -05:00
|
|
|
khash_t(ltable) ltable;
|
2016-02-24 02:32:24 -05:00
|
|
|
struct list_head ireps;
|
2016-02-14 10:50:02 -05:00
|
|
|
|
|
|
|
bool gc_enable;
|
2016-02-21 06:32:00 -05:00
|
|
|
struct heap *heap;
|
|
|
|
struct object **arena;
|
2016-02-14 10:50:02 -05:00
|
|
|
size_t arena_size, arena_idx;
|
|
|
|
|
|
|
|
pic_value err;
|
|
|
|
|
2016-02-24 02:32:24 -05:00
|
|
|
pic_panicf panicf;
|
2016-02-14 10:50:02 -05:00
|
|
|
};
|
|
|
|
|
2017-03-28 10:09:40 -04:00
|
|
|
struct heap *pic_heap_open(pic_state *);
|
|
|
|
void pic_heap_close(pic_state *, struct heap *);
|
|
|
|
|
2017-03-28 11:03:23 -04:00
|
|
|
pic_value pic_global_ref(pic_state *pic, pic_value uid);
|
|
|
|
void pic_global_set(pic_state *pic, pic_value uid, pic_value value);
|
|
|
|
|
2016-02-14 10:50:02 -05:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|