diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-12-09 11:50:08 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-12-09 11:50:08 -0200 |
| commit | 80b3d28f4a9e518bf40b35f786199919180bfcd4 (patch) | |
| tree | e25a410ba61883244207e25b16a853991b417ebb /lua.stx | |
| parent | 69d97712ecfcd06aa4edb7374b262131210d0bbc (diff) | |
| download | lua-80b3d28f4a9e518bf40b35f786199919180bfcd4.tar.gz lua-80b3d28f4a9e518bf40b35f786199919180bfcd4.tar.bz2 lua-80b3d28f4a9e518bf40b35f786199919180bfcd4.zip | |
details (mainly error messages)
Diffstat (limited to 'lua.stx')
| -rw-r--r-- | lua.stx | 24 |
1 files changed, 15 insertions, 9 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | %{ | 1 | %{ |
| 2 | /* | 2 | /* |
| 3 | ** $Id: lua.stx,v 1.19 1997/11/21 19:00:46 roberto Exp roberto $ | 3 | ** $Id: lua.stx,v 1.20 1997/12/02 12:43:54 roberto Exp roberto $ |
| 4 | ** Syntax analizer and code generator | 4 | ** Syntax analizer and code generator |
| 5 | ** See Copyright Notice in lua.h | 5 | ** See Copyright Notice in lua.h |
| 6 | */ | 6 | */ |
| @@ -26,6 +26,10 @@ | |||
| 26 | int luaY_parse (void); | 26 | int luaY_parse (void); |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | #define AMES_LIM(x) #x | ||
| 30 | #define MES_LIM(x) "(limit=" AMES_LIM(x) ")" | ||
| 31 | |||
| 32 | |||
| 29 | /* size of a "normal" jump instruction: OpCode + 1 byte */ | 33 | /* size of a "normal" jump instruction: OpCode + 1 byte */ |
| 30 | #define JMPSIZE 2 | 34 | #define JMPSIZE 2 |
| 31 | 35 | ||
| @@ -43,6 +47,8 @@ int luaY_parse (void); | |||
| 43 | /* maximum number of upvalues */ | 47 | /* maximum number of upvalues */ |
| 44 | #define MAXUPVALUES 16 | 48 | #define MAXUPVALUES 16 |
| 45 | 49 | ||
| 50 | |||
| 51 | |||
| 46 | /* | 52 | /* |
| 47 | ** Variable descriptor: | 53 | ** Variable descriptor: |
| 48 | ** if 0<n<MINGLOBAL, represents local variable indexed by (n-1); | 54 | ** if 0<n<MINGLOBAL, represents local variable indexed by (n-1); |
| @@ -132,7 +138,7 @@ static void deltastack (int delta) | |||
| 132 | L->currState->stacksize += delta; | 138 | L->currState->stacksize += delta; |
| 133 | if (L->currState->stacksize > L->currState->maxstacksize) { | 139 | if (L->currState->stacksize > L->currState->maxstacksize) { |
| 134 | if (L->currState->stacksize > 255) | 140 | if (L->currState->stacksize > 255) |
| 135 | luaY_error("function/expression too complex (limit 256)"); | 141 | luaY_error("function/expression too complex"); |
| 136 | L->currState->maxstacksize = L->currState->stacksize; | 142 | L->currState->maxstacksize = L->currState->stacksize; |
| 137 | } | 143 | } |
| 138 | } | 144 | } |
| @@ -156,7 +162,7 @@ static int code_oparg_at (int pc, OpCode op, int builtin, int arg, int delta) | |||
| 156 | L->currState->f->code[pc+2] = arg>>8; | 162 | L->currState->f->code[pc+2] = arg>>8; |
| 157 | return 3; | 163 | return 3; |
| 158 | } | 164 | } |
| 159 | else luaY_error("code too long (limit 64K)"); | 165 | else luaY_error("code too long " MES_LIM(64K)); |
| 160 | return 0; /* to avoid warnings */ | 166 | return 0; /* to avoid warnings */ |
| 161 | } | 167 | } |
| 162 | 168 | ||
| @@ -314,7 +320,7 @@ static void store_localvar (TaggedString *name, int n) | |||
| 314 | if (L->currState->nlocalvar+n < MAXLOCALS) | 320 | if (L->currState->nlocalvar+n < MAXLOCALS) |
| 315 | L->currState->localvar[L->currState->nlocalvar+n] = name; | 321 | L->currState->localvar[L->currState->nlocalvar+n] = name; |
| 316 | else | 322 | else |
| 317 | luaY_error("too many local variables (limit 32)"); | 323 | luaY_error("too many local variables " MES_LIM(MAXLOCALS)); |
| 318 | luaI_registerlocalvar(name, L->lexstate->linenumber); | 324 | luaI_registerlocalvar(name, L->lexstate->linenumber); |
| 319 | } | 325 | } |
| 320 | 326 | ||
| @@ -341,7 +347,7 @@ static vardesc var2store (vardesc var) | |||
| 341 | static void add_varbuffer (vardesc var, int n) | 347 | static void add_varbuffer (vardesc var, int n) |
| 342 | { | 348 | { |
| 343 | if (n >= MAXVAR) | 349 | if (n >= MAXVAR) |
| 344 | luaY_error("variable buffer overflow (limit 32)"); | 350 | luaY_error("variable buffer overflow " MES_LIM(MAXVAR)); |
| 345 | L->currState->varbuffer[n] = var2store(var); | 351 | L->currState->varbuffer[n] = var2store(var); |
| 346 | } | 352 | } |
| 347 | 353 | ||
| @@ -379,7 +385,7 @@ static int indexupvalue (TaggedString *n) | |||
| 379 | } | 385 | } |
| 380 | /* new one */ | 386 | /* new one */ |
| 381 | if (++(L->currState->nupvalues) > MAXUPVALUES) | 387 | if (++(L->currState->nupvalues) > MAXUPVALUES) |
| 382 | luaY_error("too many upvalues in a single function (limit 16)"); | 388 | luaY_error("too many upvalues in a single function " MES_LIM(MAXUPVALUES)); |
| 383 | L->currState->upvalues[i] = v; /* i = L->currState->nupvalues - 1 */ | 389 | L->currState->upvalues[i] = v; /* i = L->currState->nupvalues - 1 */ |
| 384 | return i; | 390 | return i; |
| 385 | } | 391 | } |
| @@ -493,7 +499,7 @@ static int lua_codestore (int i, int left) | |||
| 493 | } | 499 | } |
| 494 | else { /* indexed var with values in between*/ | 500 | else { /* indexed var with values in between*/ |
| 495 | code_oparg(SETTABLE, 0, left+i, -1); | 501 | code_oparg(SETTABLE, 0, left+i, -1); |
| 496 | return left+2; /* table/index are not poped, since they are not on top */ | 502 | return left+2; /* table/index are not popped, since they are not on top */ |
| 497 | } | 503 | } |
| 498 | } | 504 | } |
| 499 | 505 | ||
| @@ -580,7 +586,7 @@ static void init_state (TaggedString *filename) | |||
| 580 | static void init_func (void) | 586 | static void init_func (void) |
| 581 | { | 587 | { |
| 582 | if (L->currState-L->mainState >= MAXSTATES-1) | 588 | if (L->currState-L->mainState >= MAXSTATES-1) |
| 583 | luaY_error("too many nested functions (limit 6)"); | 589 | luaY_error("too many nested functions " MES_LIM(MAXSTATES)); |
| 584 | L->currState++; | 590 | L->currState++; |
| 585 | init_state(L->mainState->f->fileName); | 591 | init_state(L->mainState->f->fileName); |
| 586 | luaY_codedebugline(L->lexstate->linenumber); | 592 | luaY_codedebugline(L->lexstate->linenumber); |
| @@ -604,7 +610,7 @@ static TProtoFunc *close_func (void) | |||
| 604 | 610 | ||
| 605 | 611 | ||
| 606 | /* | 612 | /* |
| 607 | ** Parse LUA code. | 613 | ** Parse Lua code. |
| 608 | */ | 614 | */ |
| 609 | TProtoFunc *luaY_parser (ZIO *z, char *chunkname) | 615 | TProtoFunc *luaY_parser (ZIO *z, char *chunkname) |
| 610 | { | 616 | { |
