diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-12-26 16:46:09 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-12-26 16:46:09 -0200 |
commit | 8c49e198654567f770a7d5081b886a7c35201d81 (patch) | |
tree | 8c1de3e885ef138574e51a8868f175feeaab71e2 /lcode.c | |
parent | 6af005ec20323defd2a5ead01e2d389462884d04 (diff) | |
download | lua-8c49e198654567f770a7d5081b886a7c35201d81.tar.gz lua-8c49e198654567f770a7d5081b886a7c35201d81.tar.bz2 lua-8c49e198654567f770a7d5081b886a7c35201d81.zip |
explicit control of size for growing vectors
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.52 2000/11/30 18:50:47 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.53 2000/12/04 18:33:40 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -107,8 +107,8 @@ static int number_constant (FuncState *fs, lua_Number r) { | |||
107 | while (--c >= lim) | 107 | while (--c >= lim) |
108 | if (f->knum[c] == r) return c; | 108 | if (f->knum[c] == r) return c; |
109 | /* not found; create a new entry */ | 109 | /* not found; create a new entry */ |
110 | luaM_growvector(fs->L, f->knum, f->nknum, 1, lua_Number, | 110 | luaM_growvector(fs->L, f->knum, f->nknum, fs->sizeknum, lua_Number, |
111 | "constant table overflow", MAXARG_U); | 111 | MAXARG_U, "constant table overflow"); |
112 | c = f->nknum++; | 112 | c = f->nknum++; |
113 | f->knum[c] = r; | 113 | f->knum[c] = r; |
114 | return c; | 114 | return c; |
@@ -423,10 +423,13 @@ static void codelineinfo (FuncState *fs) { | |||
423 | Proto *f = fs->f; | 423 | Proto *f = fs->f; |
424 | LexState *ls = fs->ls; | 424 | LexState *ls = fs->ls; |
425 | if (ls->lastline > fs->lastline) { | 425 | if (ls->lastline > fs->lastline) { |
426 | luaM_growvector(fs->L, f->lineinfo, f->nlineinfo, 2, int, | 426 | if (ls->lastline > fs->lastline+1) { |
427 | "line info overflow", MAX_INT); | 427 | luaM_growvector(fs->L, f->lineinfo, f->nlineinfo, fs->sizelineinfo, int, |
428 | if (ls->lastline > fs->lastline+1) | 428 | MAX_INT, "line info overflow"); |
429 | f->lineinfo[f->nlineinfo++] = -(ls->lastline - (fs->lastline+1)); | 429 | f->lineinfo[f->nlineinfo++] = -(ls->lastline - (fs->lastline+1)); |
430 | } | ||
431 | luaM_growvector(fs->L, f->lineinfo, f->nlineinfo, fs->sizelineinfo, int, | ||
432 | MAX_INT, "line info overflow"); | ||
430 | f->lineinfo[f->nlineinfo++] = fs->pc; | 433 | f->lineinfo[f->nlineinfo++] = fs->pc; |
431 | fs->lastline = ls->lastline; | 434 | fs->lastline = ls->lastline; |
432 | } | 435 | } |
@@ -640,8 +643,8 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { | |||
640 | } | 643 | } |
641 | codelineinfo(fs); | 644 | codelineinfo(fs); |
642 | /* put new instruction in code array */ | 645 | /* put new instruction in code array */ |
643 | luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction, | 646 | luaM_growvector(fs->L, fs->f->code, fs->pc, fs->sizecode, Instruction, |
644 | "code size overflow", MAX_INT); | 647 | MAX_INT, "code size overflow"); |
645 | fs->f->code[fs->pc] = i; | 648 | fs->f->code[fs->pc] = i; |
646 | return fs->pc++; | 649 | return fs->pc++; |
647 | } | 650 | } |