diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 15:53:17 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 15:53:17 -0300 |
commit | d1ea38580ae35a3a34e7122c41682af7f9901030 (patch) | |
tree | ce7fa1568be9eb757805966b77ea1eac2bc604f6 /lparser.h | |
parent | 3c9d999424520c809e05bee11d81788b488434f6 (diff) | |
download | lua-github-d1ea38580ae35a3a34e7122c41682af7f9901030.tar.gz |
change of code generation design (independent functions for each opcode)
Diffstat (limited to 'lparser.h')
-rw-r--r-- | lparser.h | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.7 2000/03/03 12:33:59 roberto Exp roberto $ +** $Id: lparser.h,v 1.8 2000/03/03 14:58:26 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -8,7 +8,6 @@ #define lparser_h #include "lobject.h" -#include "lopcodes.h" #include "lzio.h" @@ -42,21 +41,18 @@ #endif -#if MAXLOCALS>MAXARG_U || MAXUPVALUES>MAXARG_B || MAXVARSLH>MAXARG_B || \ - MAXPARAMS>MAXLOCALS || MAXSTACK>MAXARG_A || LFIELDS_PER_FLUSH>MAXARG_B -#error invalid limits -#endif - - /* ** Expression descriptor */ + +#define NOJUMPS 0 + typedef enum { VGLOBAL, /* info is constant index of global name */ VLOCAL, /* info is stack index */ - VINDEXED, /* no info (table and index are on the stack) */ - VEXP /* info is pc index of exp main operator */ + VINDEXED, /* info is info of the index expression */ + VEXP /* info is NOJUMPS if exp has no internal jumps */ } expkind; typedef struct expdesc { @@ -65,12 +61,22 @@ typedef struct expdesc { } expdesc; +/* +** Expression List descriptor: +** tells number of expressions in the list, +** and gives the `info' of last expression. +*/ +typedef struct listdesc { + int n; + int info; /* 0 if last expression has no internal jumps */ +} listdesc; + + /* state needed to generate code for a given function */ typedef struct FuncState { TProtoFunc *f; /* current function header */ struct FuncState *prev; /* enclosing function */ int pc; /* next position to code */ - int last_pc; /* last instruction coded (for optimizations) */ int stacksize; /* number of values on activation register */ int nlocalvar; /* number of active local variables */ int nupvalues; /* number of upvalues */ |