2013-10-10 03:15:41 -04:00
|
|
|
#ifndef PICRIN_H__
|
|
|
|
#define PICRIN_H__
|
|
|
|
|
2013-10-10 04:54:35 -04:00
|
|
|
#include <stddef.h>
|
2013-10-11 04:36:51 -04:00
|
|
|
#include <stdbool.h>
|
2013-10-10 04:54:35 -04:00
|
|
|
|
2013-10-14 20:05:44 -04:00
|
|
|
#include "picconf.h"
|
2013-10-10 03:34:24 -04:00
|
|
|
#include "picrin/value.h"
|
|
|
|
|
2013-10-16 02:30:52 -04:00
|
|
|
struct pic_code;
|
|
|
|
|
2013-10-15 10:29:34 -04:00
|
|
|
typedef struct pic_callinfo {
|
|
|
|
int argc;
|
2013-10-16 02:30:52 -04:00
|
|
|
struct pic_code *pc;
|
|
|
|
pic_value *sp;
|
2013-10-15 10:29:34 -04:00
|
|
|
} pic_callinfo;
|
|
|
|
|
2013-10-10 03:15:41 -04:00
|
|
|
typedef struct {
|
2013-10-11 11:16:19 -04:00
|
|
|
pic_value *sp;
|
2013-10-11 11:20:53 -04:00
|
|
|
pic_value *stbase, *stend;
|
|
|
|
|
2013-10-15 10:29:34 -04:00
|
|
|
pic_callinfo *ci;
|
|
|
|
pic_callinfo *cibase, *ciend;
|
|
|
|
|
2013-10-17 04:54:28 -04:00
|
|
|
pic_value sDEFINE, sLAMBDA, sIF, sBEGIN;
|
|
|
|
pic_value sCONS;
|
2013-10-15 08:29:07 -04:00
|
|
|
pic_value sADD, sSUB, sMUL, sDIV;
|
2013-10-11 04:36:51 -04:00
|
|
|
struct pic_env *global_env;
|
2013-10-13 02:14:15 -04:00
|
|
|
|
2013-10-17 11:15:15 -04:00
|
|
|
pic_value *globals;
|
|
|
|
size_t glen, gcapa;
|
2013-10-15 22:53:25 -04:00
|
|
|
struct pic_irep **irep;
|
|
|
|
size_t ilen, icapa;
|
|
|
|
|
2013-10-13 02:14:15 -04:00
|
|
|
struct heap_page *heap;
|
2013-10-13 04:02:29 -04:00
|
|
|
struct pic_object *arena[PIC_ARENA_SIZE];
|
|
|
|
int arena_idx;
|
2013-10-10 03:15:41 -04:00
|
|
|
} pic_state;
|
|
|
|
|
2013-10-15 06:19:34 -04:00
|
|
|
typedef pic_value (*pic_func_t)(pic_state *);
|
|
|
|
|
2013-10-10 03:44:51 -04:00
|
|
|
void *pic_alloc(pic_state *, size_t);
|
2013-10-15 22:21:41 -04:00
|
|
|
void *pic_realloc(pic_state *, void *, size_t);
|
2013-10-13 03:55:07 -04:00
|
|
|
struct pic_object *pic_obj_alloc(pic_state *, size_t, enum pic_tt);
|
2013-10-10 03:44:51 -04:00
|
|
|
void pic_free(pic_state *, void *);
|
|
|
|
|
2013-10-13 04:25:36 -04:00
|
|
|
void pic_gc_protect(pic_state *, pic_value);
|
|
|
|
int pic_gc_arena_preserve(pic_state *);
|
|
|
|
void pic_gc_arena_restore(pic_state *, int);
|
|
|
|
|
2013-10-10 03:15:41 -04:00
|
|
|
pic_state *pic_open();
|
2013-10-10 03:19:10 -04:00
|
|
|
void pic_close(pic_state *);
|
2013-10-10 03:15:41 -04:00
|
|
|
|
2013-10-15 06:19:34 -04:00
|
|
|
void pic_get_args(pic_state *, const char *, ...);
|
|
|
|
void pic_defun(pic_state *, const char *, pic_func_t);
|
|
|
|
|
2013-10-10 04:22:25 -04:00
|
|
|
pic_value pic_cons(pic_state *, pic_value, pic_value);
|
|
|
|
pic_value pic_car(pic_state *, pic_value);
|
|
|
|
pic_value pic_cdr(pic_state *, pic_value);
|
|
|
|
|
2013-10-11 04:36:51 -04:00
|
|
|
bool pic_eq_p(pic_state *, pic_value, pic_value);
|
|
|
|
|
2013-10-10 04:22:25 -04:00
|
|
|
pic_value pic_intern_cstr(pic_state *, const char *);
|
2013-10-10 04:06:26 -04:00
|
|
|
|
2013-10-17 07:48:50 -04:00
|
|
|
bool pic_parse(pic_state *, const char *, pic_value *);
|
2013-10-11 02:18:37 -04:00
|
|
|
|
2013-10-11 04:36:51 -04:00
|
|
|
pic_value pic_eval(pic_state *, pic_value, struct pic_env *);
|
2013-10-11 23:53:54 -04:00
|
|
|
pic_value pic_run(pic_state *, struct pic_proc *, pic_value);
|
2013-10-16 02:30:52 -04:00
|
|
|
struct pic_proc *pic_codegen(pic_state *, pic_value, struct pic_env *);
|
2013-10-11 04:36:51 -04:00
|
|
|
|
2013-10-12 01:40:27 -04:00
|
|
|
void pic_raise(pic_state *, const char *);
|
|
|
|
|
2013-10-10 04:48:01 -04:00
|
|
|
void pic_debug(pic_state *, pic_value);
|
|
|
|
|
2013-10-10 03:15:41 -04:00
|
|
|
#endif
|