diff options
-rw-r--r-- | lbuffer.c | 5 | ||||
-rw-r--r-- | ldo.c | 12 | ||||
-rw-r--r-- | lgc.c | 5 | ||||
-rw-r--r-- | lmem.h | 9 | ||||
-rw-r--r-- | lparser.c | 15 | ||||
-rw-r--r-- | ltm.c | 8 |
6 files changed, 24 insertions, 30 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuffer.c,v 1.7 1999/02/25 19:13:56 roberto Exp roberto $ | 2 | ** $Id: lbuffer.c,v 1.8 1999/02/25 19:20:40 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -26,8 +26,7 @@ static void Openspace (int size) { | |||
26 | lua_State *l = L; /* to optimize */ | 26 | lua_State *l = L; /* to optimize */ |
27 | size += EXTRABUFF; | 27 | size += EXTRABUFF; |
28 | l->Mbuffsize = l->Mbuffnext+size; | 28 | l->Mbuffsize = l->Mbuffnext+size; |
29 | l->Mbuffer = luaM_growvector(l->Mbuffer, l->Mbuffnext, size, char, | 29 | luaM_growvector(l->Mbuffer, l->Mbuffnext, size, char, arrEM, MAX_INT); |
30 | memEM, MAX_INT); | ||
31 | } | 30 | } |
32 | 31 | ||
33 | 32 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.34 1999/02/22 14:17:24 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.35 1999/02/22 19:23:36 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -43,13 +43,12 @@ void luaD_init (void) { | |||
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | void luaD_checkstack (int n) | 46 | void luaD_checkstack (int n) { |
47 | { | ||
48 | struct Stack *S = &L->stack; | 47 | struct Stack *S = &L->stack; |
49 | if (S->last-S->top <= n) { | 48 | if (S->last-S->top <= n) { |
50 | StkId top = S->top-S->stack; | 49 | StkId top = S->top-S->stack; |
51 | int stacksize = (S->last-S->stack)+1+STACK_UNIT+n; | 50 | int stacksize = (S->last-S->stack)+STACK_UNIT+n; |
52 | S->stack = luaM_reallocvector(S->stack, stacksize, TObject); | 51 | luaM_reallocvector(S->stack, stacksize, TObject); |
53 | S->last = S->stack+(stacksize-1); | 52 | S->last = S->stack+(stacksize-1); |
54 | S->top = S->stack + top; | 53 | S->top = S->stack + top; |
55 | if (stacksize >= STACK_LIMIT) { /* stack overflow? */ | 54 | if (stacksize >= STACK_LIMIT) { /* stack overflow? */ |
@@ -65,8 +64,7 @@ void luaD_checkstack (int n) | |||
65 | /* | 64 | /* |
66 | ** Adjust stack. Set top to the given value, pushing NILs if needed. | 65 | ** Adjust stack. Set top to the given value, pushing NILs if needed. |
67 | */ | 66 | */ |
68 | void luaD_adjusttop (StkId newtop) | 67 | void luaD_adjusttop (StkId newtop) { |
69 | { | ||
70 | int diff = newtop-(L->stack.top-L->stack.stack); | 68 | int diff = newtop-(L->stack.top-L->stack.stack); |
71 | if (diff <= 0) | 69 | if (diff <= 0) |
72 | L->stack.top += diff; | 70 | L->stack.top += diff; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.20 1999/01/22 18:08:03 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.21 1999/02/25 15:16:26 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -38,8 +38,7 @@ int luaC_ref (TObject *o, int lock) { | |||
38 | if (L->refArray[ref].status == FREE) | 38 | if (L->refArray[ref].status == FREE) |
39 | break; | 39 | break; |
40 | if (ref == L->refSize) { /* no more empty spaces? */ | 40 | if (ref == L->refSize) { /* no more empty spaces? */ |
41 | L->refArray = luaM_growvector(L->refArray, L->refSize, 1, struct ref, | 41 | luaM_growvector(L->refArray, L->refSize, 1, struct ref, refEM, MAX_INT); |
42 | refEM, MAX_INT); | ||
43 | L->refSize++; | 42 | L->refSize++; |
44 | } | 43 | } |
45 | L->refArray[ref].o = *o; | 44 | L->refArray[ref].o = *o; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmem.h,v 1.6 1998/12/15 14:59:43 roberto Exp roberto $ | 2 | ** $Id: lmem.h,v 1.7 1999/02/25 15:16:26 roberto Exp roberto $ |
3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -16,6 +16,7 @@ | |||
16 | #define refEM "reference table overflow" | 16 | #define refEM "reference table overflow" |
17 | #define tableEM "table overflow" | 17 | #define tableEM "table overflow" |
18 | #define memEM "not enough memory" | 18 | #define memEM "not enough memory" |
19 | #define arrEM "internal array bigger than `int' limit" | ||
19 | 20 | ||
20 | void *luaM_realloc (void *oldblock, unsigned long size); | 21 | void *luaM_realloc (void *oldblock, unsigned long size); |
21 | void *luaM_growaux (void *block, unsigned long nelems, int inc, int size, | 22 | void *luaM_growaux (void *block, unsigned long nelems, int inc, int size, |
@@ -25,9 +26,9 @@ void *luaM_growaux (void *block, unsigned long nelems, int inc, int size, | |||
25 | #define luaM_malloc(t) luaM_realloc(NULL, (t)) | 26 | #define luaM_malloc(t) luaM_realloc(NULL, (t)) |
26 | #define luaM_new(t) ((t *)luaM_malloc(sizeof(t))) | 27 | #define luaM_new(t) ((t *)luaM_malloc(sizeof(t))) |
27 | #define luaM_newvector(n,t) ((t *)luaM_malloc((n)*sizeof(t))) | 28 | #define luaM_newvector(n,t) ((t *)luaM_malloc((n)*sizeof(t))) |
28 | #define luaM_growvector(old,nelems,inc,t,e,l) \ | 29 | #define luaM_growvector(v,nelems,inc,t,e,l) \ |
29 | ((t *)luaM_growaux(old,nelems,inc,sizeof(t),e,l)) | 30 | ((v)=(t *)luaM_growaux(v,nelems,inc,sizeof(t),e,l)) |
30 | #define luaM_reallocvector(v,n,t) ((t *)luaM_realloc(v,(n)*sizeof(t))) | 31 | #define luaM_reallocvector(v,n,t) ((v)=(t *)luaM_realloc(v,(n)*sizeof(t))) |
31 | 32 | ||
32 | 33 | ||
33 | #ifdef DEBUG | 34 | #ifdef DEBUG |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.23 1999/02/25 15:16:26 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.24 1999/02/25 19:13:56 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -131,7 +131,7 @@ static void var_or_func_tail (LexState *ls, vardesc *v); | |||
131 | 131 | ||
132 | 132 | ||
133 | static void check_pc (FuncState *fs, int n) { | 133 | static void check_pc (FuncState *fs, int n) { |
134 | fs->f->code = luaM_growvector(fs->f->code, fs->pc, n, Byte, codeEM, MAX_INT); | 134 | luaM_growvector(fs->f->code, fs->pc, n, Byte, codeEM, MAX_INT); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
@@ -216,8 +216,7 @@ static void code_constant (LexState *ls, int c) { | |||
216 | 216 | ||
217 | static int next_constant (FuncState *fs) { | 217 | static int next_constant (FuncState *fs) { |
218 | TProtoFunc *f = fs->f; | 218 | TProtoFunc *f = fs->f; |
219 | f->consts = luaM_growvector(f->consts, f->nconsts, 1, TObject, | 219 | luaM_growvector(f->consts, f->nconsts, 1, TObject, constantEM, MAX_ARG); |
220 | constantEM, MAX_ARG); | ||
221 | return f->nconsts++; | 220 | return f->nconsts++; |
222 | } | 221 | } |
223 | 222 | ||
@@ -289,7 +288,7 @@ static void luaI_registerlocalvar (FuncState *fs, TaggedString *varname, | |||
289 | int line) { | 288 | int line) { |
290 | if (fs->nvars != -1) { /* debug information? */ | 289 | if (fs->nvars != -1) { /* debug information? */ |
291 | TProtoFunc *f = fs->f; | 290 | TProtoFunc *f = fs->f; |
292 | f->locvars = luaM_growvector(f->locvars, fs->nvars, 1, LocVar, "", MAX_INT); | 291 | luaM_growvector(f->locvars, fs->nvars, 1, LocVar, "", MAX_INT); |
293 | f->locvars[fs->nvars].varname = varname; | 292 | f->locvars[fs->nvars].varname = varname; |
294 | f->locvars[fs->nvars].line = line; | 293 | f->locvars[fs->nvars].line = line; |
295 | fs->nvars++; | 294 | fs->nvars++; |
@@ -562,11 +561,11 @@ static void close_func (LexState *ls) { | |||
562 | TProtoFunc *f = fs->f; | 561 | TProtoFunc *f = fs->f; |
563 | code_opcode(ls, ENDCODE, 0); | 562 | code_opcode(ls, ENDCODE, 0); |
564 | f->code[0] = (Byte)fs->maxstacksize; | 563 | f->code[0] = (Byte)fs->maxstacksize; |
565 | f->code = luaM_reallocvector(f->code, fs->pc, Byte); | 564 | luaM_reallocvector(f->code, fs->pc, Byte); |
566 | f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject); | 565 | luaM_reallocvector(f->consts, f->nconsts, TObject); |
567 | if (fs->nvars != -1) { /* debug information? */ | 566 | if (fs->nvars != -1) { /* debug information? */ |
568 | luaI_registerlocalvar(fs, NULL, -1); /* flag end of vector */ | 567 | luaI_registerlocalvar(fs, NULL, -1); /* flag end of vector */ |
569 | f->locvars = luaM_reallocvector(f->locvars, fs->nvars, LocVar); | 568 | luaM_reallocvector(f->locvars, fs->nvars, LocVar); |
570 | } | 569 | } |
571 | ls->fs = fs->prev; | 570 | ls->fs = fs->prev; |
572 | L->stack.top--; /* pop function */ | 571 | L->stack.top--; /* pop function */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.22 1999/02/25 15:16:26 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.23 1999/02/25 19:13:56 roberto Exp roberto $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -59,8 +59,7 @@ static void init_entry (int tag) { | |||
59 | void luaT_init (void) { | 59 | void luaT_init (void) { |
60 | int t; | 60 | int t; |
61 | L->last_tag = -(NUM_TAGS-1); | 61 | L->last_tag = -(NUM_TAGS-1); |
62 | L->IMtable = luaM_growvector(L->IMtable, 0, NUM_TAGS, | 62 | luaM_growvector(L->IMtable, 0, NUM_TAGS, struct IM, arrEM, MAX_INT); |
63 | struct IM, memEM, MAX_INT); | ||
64 | for (t=L->last_tag; t<=0; t++) | 63 | for (t=L->last_tag; t<=0; t++) |
65 | init_entry(t); | 64 | init_entry(t); |
66 | } | 65 | } |
@@ -68,8 +67,7 @@ void luaT_init (void) { | |||
68 | 67 | ||
69 | int lua_newtag (void) { | 68 | int lua_newtag (void) { |
70 | --L->last_tag; | 69 | --L->last_tag; |
71 | L->IMtable = luaM_growvector(L->IMtable, -(L->last_tag), 1, | 70 | luaM_growvector(L->IMtable, -(L->last_tag), 1, struct IM, arrEM, MAX_INT); |
72 | struct IM, memEM, MAX_INT); | ||
73 | init_entry(L->last_tag); | 71 | init_entry(L->last_tag); |
74 | return L->last_tag; | 72 | return L->last_tag; |
75 | } | 73 | } |