Merge remote-tracking branch 'upstream/master' into native-record
Conflicts: include/picrin/value.h piclib/prelude.scm src/codegen.c src/gc.c src/init.c src/macro.c src/vm.c src/write.c
This commit is contained in:
@@ -26,8 +26,6 @@
|
||||
|
||||
/* #define PIC_RESCUE_SIZE 30 */
|
||||
|
||||
/* #define PIC_GLOBALS_SIZE 1024 */
|
||||
|
||||
/* #define PIC_SYM_POOL_SIZE 128 */
|
||||
|
||||
/* #define PIC_IREP_SIZE 8 */
|
||||
@@ -93,10 +91,6 @@
|
||||
# define PIC_RESCUE_SIZE 30
|
||||
#endif
|
||||
|
||||
#ifndef PIC_GLOBALS_SIZE
|
||||
# define PIC_GLOBALS_SIZE 1024
|
||||
#endif
|
||||
|
||||
#ifndef PIC_SYM_POOL_SIZE
|
||||
# define PIC_SYM_POOL_SIZE 128
|
||||
#endif
|
||||
|
||||
+11
-29
@@ -9,11 +9,18 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct pic_block {
|
||||
PIC_OBJECT_HEADER
|
||||
struct pic_block *prev;
|
||||
int depth;
|
||||
struct pic_proc *in, *out;
|
||||
};
|
||||
|
||||
struct pic_cont {
|
||||
PIC_OBJECT_HEADER
|
||||
jmp_buf jmp;
|
||||
|
||||
pic_block *blk;
|
||||
struct pic_block *blk;
|
||||
|
||||
char *stk_pos, *stk_ptr;
|
||||
ptrdiff_t stk_len;
|
||||
@@ -30,37 +37,12 @@ struct pic_cont {
|
||||
size_t arena_size;
|
||||
int arena_idx;
|
||||
|
||||
struct pic_jmpbuf *try_jmps;
|
||||
size_t try_jmp_idx, try_jmp_size;
|
||||
|
||||
pic_value results;
|
||||
};
|
||||
|
||||
#define PIC_BLK_INCREF(pic,blk) do { \
|
||||
(blk)->refcnt++; \
|
||||
} while (0)
|
||||
|
||||
#define PIC_BLK_DECREF(pic,blk) do { \
|
||||
pic_block *_a = (blk), *_b; \
|
||||
while (_a) { \
|
||||
if (! --_a->refcnt) { \
|
||||
_b = _a->prev; \
|
||||
pic_free((pic), _a); \
|
||||
_a = _b; \
|
||||
} else { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PIC_BLK_EXIT(pic) do { \
|
||||
pic_block *_a; \
|
||||
while (pic->blk) { \
|
||||
if (pic->blk->out) \
|
||||
pic_apply0(pic, pic->blk->out); \
|
||||
_a = pic->blk->prev; \
|
||||
PIC_BLK_DECREF(pic, pic->blk); \
|
||||
pic->blk = _a; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
pic_value pic_values0(pic_state *);
|
||||
pic_value pic_values1(pic_state *, pic_value);
|
||||
pic_value pic_values2(pic_state *, pic_value, pic_value);
|
||||
|
||||
@@ -11,17 +11,19 @@ extern "C" {
|
||||
|
||||
struct pic_jmpbuf {
|
||||
jmp_buf here;
|
||||
pic_callinfo *ci;
|
||||
pic_value *sp;
|
||||
struct pic_proc *handler;
|
||||
ptrdiff_t ci_offset;
|
||||
ptrdiff_t sp_offset;
|
||||
pic_code *ip;
|
||||
jmp_buf *prev_jmp;
|
||||
struct pic_jmpbuf *prev;
|
||||
};
|
||||
|
||||
/* do not return from try block! */
|
||||
|
||||
#define pic_try \
|
||||
pic_push_try(pic); \
|
||||
pic_try_with_handler(NULL)
|
||||
#define pic_try_with_handler(handler) \
|
||||
pic_push_try(pic, handler); \
|
||||
if (setjmp(*pic->jmp) == 0) \
|
||||
do
|
||||
#define pic_catch \
|
||||
@@ -29,7 +31,7 @@ struct pic_jmpbuf {
|
||||
else \
|
||||
if (pic_pop_try(pic), 1)
|
||||
|
||||
void pic_push_try(pic_state *);
|
||||
void pic_push_try(pic_state *, struct pic_proc *);
|
||||
void pic_pop_try(pic_state *);
|
||||
|
||||
noreturn void pic_throw(pic_state *, short, const char *, pic_value);
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C" {
|
||||
* pic_sym is just an alias to unsigned int.
|
||||
*/
|
||||
|
||||
typedef unsigned pic_sym;
|
||||
typedef int pic_sym;
|
||||
|
||||
/**
|
||||
* `undef` values never seen from user-end: that is,
|
||||
@@ -116,7 +116,8 @@ enum pic_tt {
|
||||
PIC_TT_IREP,
|
||||
PIC_TT_DATA,
|
||||
PIC_TT_DICT,
|
||||
PIC_TT_RECORD
|
||||
PIC_TT_RECORD,
|
||||
PIC_TT_BLK,
|
||||
};
|
||||
|
||||
#define PIC_OBJECT_HEADER \
|
||||
@@ -271,6 +272,8 @@ pic_type_repr(enum pic_tt tt)
|
||||
return "dict";
|
||||
case PIC_TT_RECORD:
|
||||
return "record";
|
||||
case PIC_TT_BLK:
|
||||
return "block";
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user