aboutsummaryrefslogtreecommitdiff
path: root/lua.stx
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-12-20 19:20:36 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-12-20 19:20:36 -0200
commit8cb8594a3bcfdc1447aebfcd0ac85db9af5ca490 (patch)
tree13d09f704662cafa2597e77c92611b468e4741c9 /lua.stx
parentfe8338335dfb4bf37e6b164cb55bfcc94ec6563d (diff)
downloadlua-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.stx20
1 files changed, 12 insertions, 8 deletions
diff --git a/lua.stx b/lua.stx
index 2dd21a3c..5ab2d2cc 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
1%{ 1%{
2 2
3char *rcs_luastx = "$Id: lua.stx,v 3.12 1994/11/25 19:24:57 roberto Exp $"; 3char *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
32static Long maxcode; 32static Word maxcode;
33static Long maxmain; 33static Word maxmain;
34static Long maxcurr ; 34static Long maxcurr; /* to allow maxcurr *= 2 without overflow */
35static Byte *funcCode = NULL; 35static Byte *funcCode = NULL;
36static Byte **initcode; 36static Byte **initcode;
37static Byte *basepc; 37static Byte *basepc;
38static Long maincode; 38static Word maincode;
39static Long pc; 39static Word pc;
40 40
41#define MAXVAR 32 41#define MAXVAR 32
42static long varbuffer[MAXVAR]; /* variables in an assignment list; 42static 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 */
44static int nvarbuffer=0; /* number of variables at a list */ 44static 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*/
570static void lua_pushvar (long number) 574static void lua_pushvar (Long number)
571{ 575{
572 if (number > 0) /* global var */ 576 if (number > 0) /* global var */
573 { 577 {