diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-12-20 19:20:36 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-12-20 19:20:36 -0200 |
| commit | 8cb8594a3bcfdc1447aebfcd0ac85db9af5ca490 (patch) | |
| tree | 13d09f704662cafa2597e77c92611b468e4741c9 /lua.stx | |
| parent | fe8338335dfb4bf37e6b164cb55bfcc94ec6563d (diff) | |
| download | lua-8cb8594a3bcfdc1447aebfcd0ac85db9af5ca490.tar.gz lua-8cb8594a3bcfdc1447aebfcd0ac85db9af5ca490.tar.bz2 lua-8cb8594a3bcfdc1447aebfcd0ac85db9af5ca490.zip | |
better control of integer types and their limits
Diffstat (limited to 'lua.stx')
| -rw-r--r-- | lua.stx | 20 |
1 files changed, 12 insertions, 8 deletions
| @@ -1,6 +1,6 @@ | |||
| 1 | %{ | 1 | %{ |
| 2 | 2 | ||
| 3 | char *rcs_luastx = "$Id: lua.stx,v 3.12 1994/11/25 19:24:57 roberto Exp $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 3.13 1994/12/06 14:27:18 roberto Exp roberto $"; |
| 4 | 4 | ||
| 5 | #include <stdio.h> | 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| @@ -29,17 +29,17 @@ int yyparse (void); | |||
| 29 | #ifndef CODE_BLOCK | 29 | #ifndef CODE_BLOCK |
| 30 | #define CODE_BLOCK 256 | 30 | #define CODE_BLOCK 256 |
| 31 | #endif | 31 | #endif |
| 32 | static Long maxcode; | 32 | static Word maxcode; |
| 33 | static Long maxmain; | 33 | static Word maxmain; |
| 34 | static Long maxcurr ; | 34 | static Long maxcurr; /* to allow maxcurr *= 2 without overflow */ |
| 35 | static Byte *funcCode = NULL; | 35 | static Byte *funcCode = NULL; |
| 36 | static Byte **initcode; | 36 | static Byte **initcode; |
| 37 | static Byte *basepc; | 37 | static Byte *basepc; |
| 38 | static Long maincode; | 38 | static Word maincode; |
| 39 | static Long pc; | 39 | static Word pc; |
| 40 | 40 | ||
| 41 | #define MAXVAR 32 | 41 | #define MAXVAR 32 |
| 42 | static long varbuffer[MAXVAR]; /* variables in an assignment list; | 42 | static Long varbuffer[MAXVAR]; /* variables in an assignment list; |
| 43 | it's long to store negative Word values */ | 43 | it's long to store negative Word values */ |
| 44 | static int nvarbuffer=0; /* number of variables at a list */ | 44 | static int nvarbuffer=0; /* number of variables at a list */ |
| 45 | 45 | ||
| @@ -57,7 +57,11 @@ static void code_byte (Byte c) | |||
| 57 | { | 57 | { |
| 58 | if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ | 58 | if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ |
| 59 | { | 59 | { |
| 60 | if (maxcurr >= MAX_WORD) | ||
| 61 | lua_error("code size overflow"); | ||
| 60 | maxcurr *= 2; | 62 | maxcurr *= 2; |
| 63 | if (maxcurr >= MAX_WORD) | ||
| 64 | maxcurr = MAX_WORD; | ||
| 61 | basepc = growvector(basepc, maxcurr, Byte); | 65 | basepc = growvector(basepc, maxcurr, Byte); |
| 62 | } | 66 | } |
| 63 | basepc[pc++] = c; | 67 | basepc[pc++] = c; |
| @@ -567,7 +571,7 @@ static int lua_localname (Word n) | |||
| 567 | ** indexed by (number -1). If negative, push local indexed by ABS(number)-1. | 571 | ** indexed by (number -1). If negative, push local indexed by ABS(number)-1. |
| 568 | ** Otherwise, if zero, push indexed variable (record). | 572 | ** Otherwise, if zero, push indexed variable (record). |
| 569 | */ | 573 | */ |
| 570 | static void lua_pushvar (long number) | 574 | static void lua_pushvar (Long number) |
| 571 | { | 575 | { |
| 572 | if (number > 0) /* global var */ | 576 | if (number > 0) /* global var */ |
| 573 | { | 577 | { |
