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
|
|
|
|
|
2016-02-20 11:13:16 -05:00
|
|
|
#include "picrin/private/khash.h"
|
|
|
|
#include "picrin/private/file.h"
|
2016-02-14 10:50:02 -05:00
|
|
|
|
2016-02-21 05:53:31 -05:00
|
|
|
#include "picrin/private/vm.h"
|
2016-02-20 11:13:16 -05:00
|
|
|
#include "picrin/private/gc.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-21 06:32:00 -05:00
|
|
|
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-21 06:32:00 -05:00
|
|
|
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-21 06:32:00 -05:00
|
|
|
struct list_head ireps; /* chain */
|
2016-02-14 10:50:02 -05:00
|
|
|
|
|
|
|
xFILE files[XOPEN_MAX];
|
2016-02-21 06:32:00 -05:00
|
|
|
struct code iseq[2]; /* for pic_apply_trampoline */
|
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-21 04:59:18 -05:00
|
|
|
pic_panicf panicf;
|
2016-02-14 10:50:02 -05:00
|
|
|
|
|
|
|
char *native_stack_start;
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|