auto-extend constant pool array

This commit is contained in:
Yuichi Nishiwaki 2014-01-18 22:56:43 +09:00
parent 9fadf16fdb
commit a315f518d2
2 changed files with 9 additions and 7 deletions

View File

@ -22,10 +22,10 @@
#define PIC_HEAP_PAGE_SIZE (10000)
#define PIC_STACK_SIZE 1024
#define PIC_RESCUE_SIZE 30
#define PIC_IREP_SIZE 256
#define PIC_GLOBALS_SIZE 1024
#define PIC_MACROS_SIZE 1024
#define PIC_SYM_POOL_SIZE 128
#define PIC_IREP_SIZE 256
#define PIC_POOL_SIZE 1024
#define PIC_ISEQ_SIZE 1024

View File

@ -457,10 +457,11 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
pic_error(pic, "syntax error");
}
pidx = scope->plen++;
if (pidx >= scope->pcapa) {
pic_abort(pic, "constant pool overflow");
if (scope->plen >= scope->pcapa) {
scope->pool = (pic_value *)pic_realloc(pic, scope->pool, scope->pcapa * 2);
scope->pcapa *= 2;
}
pidx = scope->plen++;
scope->pool[pidx] = pic_car(pic, pic_cdr(pic, obj));
scope->code[scope->clen].insn = OP_PUSHCONST;
scope->code[scope->clen].u.i = pidx;
@ -693,10 +694,11 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
case PIC_TT_VECTOR:
case PIC_TT_BLOB: {
int pidx;
pidx = scope->plen++;
if (pidx >= scope->pcapa) {
pic_abort(pic, "constant pool overflow");
if (scope->plen >= scope->pcapa) {
scope->pool = (pic_value *)pic_realloc(pic, scope->pool, scope->pcapa * 2);
scope->pcapa *= 2;
}
pidx = scope->plen++;
scope->pool[pidx] = obj;
scope->code[scope->clen].insn = OP_PUSHCONST;
scope->code[scope->clen].u.i = pidx;