picrin/lib/state.h

68 lines
1.1 KiB
C
Raw Normal View History

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"
2017-04-14 10:40:07 -04:00
#include "object.h"
2016-02-14 10:50:02 -05:00
2017-04-14 10:40:07 -04:00
KHASH_DECLARE(oblist, struct string *, struct symbol *)
struct context {
PIC_JMPBUF jmp;
2017-04-20 16:22:28 -04:00
size_t ai;
2017-04-14 10:40:07 -04:00
/* vm */
const code_t *pc;
struct frame *sp;
struct frame *fp;
2016-02-21 06:32:00 -05:00
struct irep *irep;
2016-02-14 10:50:02 -05:00
2017-04-14 10:40:07 -04:00
code_t tmpcode[2];
struct context *prev;
};
2016-02-14 10:50:02 -05:00
struct pic_state {
pic_allocf allocf;
void *userdata;
2017-04-14 10:40:07 -04:00
struct context *cxt, default_cxt;
2016-02-14 10:50:02 -05:00
2017-04-15 16:20:55 -04:00
size_t ai;
2017-03-31 01:39:01 -04:00
pic_value dyn_env;
2017-04-09 02:05:59 -04:00
pic_value features; /* list of symbols */
2016-02-14 22:59:58 -05:00
khash_t(oblist) oblist; /* string to symbol */
2017-04-02 09:19:11 -04:00
pic_value globals; /* dict */
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;
2017-04-14 10:40:07 -04:00
size_t arena_size;
2016-02-14 10:50:02 -05:00
2017-04-14 10:40:07 -04:00
pic_value halt; /* top continuation */
2016-02-14 10:50:02 -05:00
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);
void pic_vm_tear_off(pic_state *pic);
2016-02-14 10:50:02 -05:00
#if defined(__cplusplus)
}
#endif
#endif