aboutsummaryrefslogtreecommitdiff
path: root/lparser.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-09-07 14:39:10 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-09-07 14:39:10 -0300
commitabdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5 (patch)
tree051a7571c8acaf5451b5c9b7d67f1796a345c565 /lparser.h
parent4d0935ec0ffed827aade5594216fae15bed7c6b5 (diff)
downloadlua-abdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5.tar.gz
lua-abdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5.tar.bz2
lua-abdbe883a86bbc7fbf1d1bfc50756e1b42fc45b5.zip
first implementation of unrestricted static scoping
Diffstat (limited to 'lparser.h')
-rw-r--r--lparser.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/lparser.h b/lparser.h
index 22482ce2..2355b35d 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.h,v 1.33 2001/08/10 20:53:03 roberto Exp roberto $ 2** $Id: lparser.h,v 1.34 2001/08/27 15:16:28 roberto Exp $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -7,11 +7,24 @@
7#ifndef lparser_h 7#ifndef lparser_h
8#define lparser_h 8#define lparser_h
9 9
10#include "llimits.h"
10#include "lobject.h" 11#include "lobject.h"
11#include "ltable.h" 12#include "ltable.h"
12#include "lzio.h" 13#include "lzio.h"
13 14
14 15
16
17/* small implementation of bit arrays */
18
19#define BPW (CHAR_BIT*sizeof(unsigned int)) /* bits per word */
20
21#define words2bits(b) (((b)-1)/BPW + 1)
22
23#define setbit(a, b) ((a)[(b)/BPW] |= (1 << (b)%BPW))
24#define resetbit(a, b) ((a)[(b)/BPW] &= ~((1 << (b)%BPW)))
25#define testbit(a, b) ((a)[(b)/BPW] & (1 << (b)%BPW))
26
27
15/* 28/*
16** Expression descriptor 29** Expression descriptor
17*/ 30*/
@@ -21,8 +34,9 @@ typedef enum {
21 VNIL, 34 VNIL,
22 VNUMBER, /* n = value */ 35 VNUMBER, /* n = value */
23 VK, /* info = index of constant in `k' */ 36 VK, /* info = index of constant in `k' */
24 VGLOBAL, /* info = index of global name in `k' */
25 VLOCAL, /* info = local register */ 37 VLOCAL, /* info = local register */
38 VUPVAL, /* info = index of upvalue in `upvalues' */
39 VGLOBAL, /* info = index of global name in `k' */
26 VINDEXED, /* info = table register; aux = index register (or `k') */ 40 VINDEXED, /* info = table register; aux = index register (or `k') */
27 VRELOCABLE, /* info = instruction pc */ 41 VRELOCABLE, /* info = instruction pc */
28 VNONRELOC, /* info = result register */ 42 VNONRELOC, /* info = result register */
@@ -63,6 +77,8 @@ typedef struct FuncState {
63 struct Breaklabel *bl; /* chain of breakable blocks */ 77 struct Breaklabel *bl; /* chain of breakable blocks */
64 expdesc upvalues[MAXUPVALUES]; /* upvalues */ 78 expdesc upvalues[MAXUPVALUES]; /* upvalues */
65 int actloc[MAXLOCALS]; /* local-variable stack (indices to locvars) */ 79 int actloc[MAXLOCALS]; /* local-variable stack (indices to locvars) */
80 unsigned int wasup[words2bits(MAXLOCALS)]; /* bit array to mark whether a
81 local variable was used as upvalue at some level */
66} FuncState; 82} FuncState;
67 83
68 84