summaryrefslogtreecommitdiff
path: root/lparser.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-03 15:53:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-03 15:53:17 -0300
commitd1ea38580ae35a3a34e7122c41682af7f9901030 (patch)
treece7fa1568be9eb757805966b77ea1eac2bc604f6 /lparser.h
parent3c9d999424520c809e05bee11d81788b488434f6 (diff)
downloadlua-github-d1ea38580ae35a3a34e7122c41682af7f9901030.tar.gz
change of code generation design (independent functions for each opcode)
Diffstat (limited to 'lparser.h')
-rw-r--r--lparser.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/lparser.h b/lparser.h
index a3568a6f..a64b8dda 100644
--- a/lparser.h
+++ b/lparser.h
@@ -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 */