diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 15:17:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 15:17:01 -0300 |
commit | 762d059a13d83eb367238a6115bbb4f5f13fcb49 (patch) | |
tree | f35fdf0675b791865d0d4800522b172903b34803 /lparser.h | |
parent | 572a69b6afbd368beab8844bc876b0f9690b5253 (diff) | |
download | lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.tar.gz lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.tar.bz2 lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.zip |
new implementation for the Virtual Machine
Diffstat (limited to 'lparser.h')
-rw-r--r-- | lparser.h | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.h,v 1.29 2000/12/28 12:55:41 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.30 2001/02/20 18:28:11 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -16,25 +16,32 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | typedef enum { | 18 | typedef enum { |
19 | VGLOBAL, | 19 | VVOID, /* no value */ |
20 | VLOCAL, | 20 | VNIL, |
21 | VINDEXED, | 21 | VNUMBER, /* n = value */ |
22 | VEXP | 22 | VK, /* info = index of constant in `k' */ |
23 | VGLOBAL, /* info = index of global name in `k' */ | ||
24 | VLOCAL, /* info = local register */ | ||
25 | VINDEXED, /* info = table register; aux = index register (or `k') */ | ||
26 | VRELOCABLE, /* info = instruction pc */ | ||
27 | VNONRELOC, /* info = result register */ | ||
28 | VJMP, /* info = result register */ | ||
29 | VCALL /* info = result register */ | ||
23 | } expkind; | 30 | } expkind; |
24 | 31 | ||
25 | typedef struct expdesc { | 32 | typedef struct expdesc { |
26 | expkind k; | 33 | expkind k; |
27 | union { | 34 | union { |
28 | int index; /* VGLOBAL: `kstr' index of global name; VLOCAL: stack index */ | ||
29 | struct { | 35 | struct { |
30 | int t; /* patch list of `exit when true' */ | 36 | int info, aux; |
31 | int f; /* patch list of `exit when false' */ | 37 | } i; |
32 | } l; | 38 | lua_Number n; |
33 | } u; | 39 | } u; |
40 | int t; /* patch list of `exit when true' */ | ||
41 | int f; /* patch list of `exit when false' */ | ||
34 | } expdesc; | 42 | } expdesc; |
35 | 43 | ||
36 | 44 | ||
37 | |||
38 | /* state needed to generate code for a given function */ | 45 | /* state needed to generate code for a given function */ |
39 | typedef struct FuncState { | 46 | typedef struct FuncState { |
40 | Proto *f; /* current function header */ | 47 | Proto *f; /* current function header */ |
@@ -44,10 +51,9 @@ typedef struct FuncState { | |||
44 | int pc; /* next position to code (equivalent to `ncode') */ | 51 | int pc; /* next position to code (equivalent to `ncode') */ |
45 | int lasttarget; /* `pc' of last `jump target' */ | 52 | int lasttarget; /* `pc' of last `jump target' */ |
46 | int jlt; /* list of jumps to `lasttarget' */ | 53 | int jlt; /* list of jumps to `lasttarget' */ |
47 | int stacklevel; /* number of values on activation register */ | 54 | int freereg; /* first free register */ |
48 | int nkstr; /* number of elements in `kstr' */ | 55 | int nk; /* number of elements in `k' */ |
49 | int nkproto; /* number of elements in `kproto' */ | 56 | int nkproto; /* number of elements in `kproto' */ |
50 | int nknum; /* number of elements in `knum' */ | ||
51 | int nlineinfo; /* number of elements in `lineinfo' */ | 57 | int nlineinfo; /* number of elements in `lineinfo' */ |
52 | int nlocvars; /* number of elements in `locvars' */ | 58 | int nlocvars; /* number of elements in `locvars' */ |
53 | int nactloc; /* number of active local variables */ | 59 | int nactloc; /* number of active local variables */ |