The Battle for Wesnoth
1.13.4+dev
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
lua
lparser.h
Go to the documentation of this file.
1
/*
2
** Lua Parser
3
** See Copyright Notice in lua.h
4
*/
5
6
#ifndef lparser_h
7
#define lparser_h
8
9
#include "
llimits.h
"
10
#include "
lobject.h
"
11
#include "
lzio.h
"
12
13
14
/*
15
** Expression descriptor
16
*/
17
18
typedef
enum
{
19
VVOID
,
/* no value */
20
VNIL
,
21
VTRUE
,
22
VFALSE
,
23
VK
,
/* info = index of constant in `k' */
24
VKNUM
,
/* nval = numerical value */
25
VNONRELOC
,
/* info = result register */
26
VLOCAL
,
/* info = local register */
27
VUPVAL
,
/* info = index of upvalue in 'upvalues' */
28
VINDEXED
,
/* t = table register/upvalue; idx = index R/K */
29
VJMP
,
/* info = instruction pc */
30
VRELOCABLE
,
/* info = instruction pc */
31
VCALL
,
/* info = instruction pc */
32
VVARARG
/* info = instruction pc */
33
}
expkind
;
34
35
36
#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
37
#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
38
39
typedef
struct
expdesc
{
40
expkind
k
;
41
union
{
42
struct
{
/* for indexed variables (VINDEXED) */
43
short
idx
;
/* index (R/K) */
44
lu_byte
t
;
/* table (register or upvalue) */
45
lu_byte
vt
;
/* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
46
}
ind
;
47
int
info
;
/* for generic use */
48
lua_Number
nval
;
/* for VKNUM */
49
}
u
;
50
int
t
;
/* patch list of `exit when true' */
51
int
f
;
/* patch list of `exit when false' */
52
}
expdesc
;
53
54
55
/* description of active local variable */
56
typedef
struct
Vardesc
{
57
short
idx
;
/* variable index in stack */
58
}
Vardesc
;
59
60
61
/* description of pending goto statements and label statements */
62
typedef
struct
Labeldesc
{
63
TString
*
name
;
/* label identifier */
64
int
pc
;
/* position in code */
65
int
line
;
/* line where it appeared */
66
lu_byte
nactvar
;
/* local level where it appears in current block */
67
}
Labeldesc
;
68
69
70
/* list of labels or gotos */
71
typedef
struct
Labellist
{
72
Labeldesc
*
arr
;
/* array */
73
int
n
;
/* number of entries in use */
74
int
size
;
/* array size */
75
}
Labellist
;
76
77
78
/* dynamic structures used by the parser */
79
typedef
struct
Dyndata
{
80
struct
{
/* list of active local variables */
81
Vardesc
*
arr
;
82
int
n
;
83
int
size
;
84
}
actvar
;
85
Labellist
gt
;
/* list of pending gotos */
86
Labellist
label
;
/* list of active labels */
87
}
Dyndata
;
88
89
90
/* control of blocks */
91
struct
BlockCnt
;
/* defined in lparser.c */
92
93
94
/* state needed to generate code for a given function */
95
typedef
struct
FuncState
{
96
Proto
*
f
;
/* current function header */
97
Table
*
h
;
/* table to find (and reuse) elements in `k' */
98
struct
FuncState
*
prev
;
/* enclosing function */
99
struct
LexState
*
ls
;
/* lexical state */
100
struct
BlockCnt
*
bl
;
/* chain of current blocks */
101
int
pc
;
/* next position to code (equivalent to `ncode') */
102
int
lasttarget
;
/* 'label' of last 'jump label' */
103
int
jpc
;
/* list of pending jumps to `pc' */
104
int
nk
;
/* number of elements in `k' */
105
int
np
;
/* number of elements in `p' */
106
int
firstlocal
;
/* index of first local var (in Dyndata array) */
107
short
nlocvars
;
/* number of elements in 'f->locvars' */
108
lu_byte
nactvar
;
/* number of active local variables */
109
lu_byte
nups
;
/* number of upvalues */
110
lu_byte
freereg
;
/* first free register */
111
}
FuncState
;
112
113
114
LUAI_FUNC
Closure
*
luaY_parser
(
lua_State
*L,
ZIO
*
z
,
Mbuffer
*buff,
115
Dyndata
*dyd,
const
char
*
name
,
int
firstchar);
116
117
118
#endif
FuncState::ls
struct LexState * ls
Definition:
lparser.h:99
z
GLdouble GLdouble z
Definition:
glew.h:1527
Labellist::n
int n
Definition:
lparser.h:73
Table
Definition:
lobject.h:559
expdesc::t
lu_byte t
Definition:
lparser.h:44
BlockCnt
Definition:
lparser.cpp:41
Labeldesc::pc
int pc
Definition:
lparser.h:64
Proto
Definition:
lobject.h:466
LUAI_FUNC
#define LUAI_FUNC
Definition:
luaconf.h:187
VVOID
Definition:
lparser.h:19
Dyndata
Definition:
lparser.h:79
expdesc::nval
lua_Number nval
Definition:
lparser.h:48
FuncState::pc
int pc
Definition:
lparser.h:101
VVARARG
Definition:
lparser.h:32
FuncState::nk
int nk
Definition:
lparser.h:104
Dyndata::gt
Labellist gt
Definition:
lparser.h:85
Dyndata::n
int n
Definition:
lparser.h:82
FuncState
Definition:
lparser.h:95
VJMP
Definition:
lparser.h:29
FuncState::lasttarget
int lasttarget
Definition:
lparser.h:102
Labeldesc::line
int line
Definition:
lparser.h:65
FuncState::nups
lu_byte nups
Definition:
lparser.h:109
FuncState::firstlocal
int firstlocal
Definition:
lparser.h:106
Labeldesc
Definition:
lparser.h:62
expkind
expkind
Definition:
lparser.h:18
expdesc::info
int info
Definition:
lparser.h:47
TString
Definition:
lobject.h:409
Labeldesc::name
TString * name
Definition:
lparser.h:63
VLOCAL
Definition:
lparser.h:26
lobject.h
lu_byte
unsigned char lu_byte
Definition:
llimits.h:26
VK
Definition:
lparser.h:23
VCALL
Definition:
lparser.h:31
VNONRELOC
Definition:
lparser.h:25
Labellist::arr
Labeldesc * arr
Definition:
lparser.h:72
FuncState::jpc
int jpc
Definition:
lparser.h:103
Vardesc::idx
short idx
Definition:
lparser.h:57
VRELOCABLE
Definition:
lparser.h:30
Labellist::size
int size
Definition:
lparser.h:74
VKNUM
Definition:
lparser.h:24
lua_State
Definition:
lstate.h:153
expdesc::vt
lu_byte vt
Definition:
lparser.h:45
Labeldesc
struct Labeldesc Labeldesc
Dyndata
struct Dyndata Dyndata
VINDEXED
Definition:
lparser.h:28
expdesc::t
int t
Definition:
lparser.h:50
lzio.h
Dyndata::arr
Vardesc * arr
Definition:
lparser.h:81
Dyndata::label
Labellist label
Definition:
lparser.h:86
VTRUE
Definition:
lparser.h:21
Zio
Definition:
lzio.h:53
Dyndata::actvar
struct Dyndata::@15 actvar
Closure
Definition:
lobject.h:529
expdesc::idx
short idx
Definition:
lparser.h:43
FuncState::nlocvars
short nlocvars
Definition:
lparser.h:107
FuncState::nactvar
lu_byte nactvar
Definition:
lparser.h:108
FuncState::freereg
lu_byte freereg
Definition:
lparser.h:110
VNIL
Definition:
lparser.h:20
llimits.h
LexState
Definition:
llex.h:50
Labeldesc::nactvar
lu_byte nactvar
Definition:
lparser.h:66
expdesc::ind
struct expdesc::@13::@14 ind
FuncState::h
Table * h
Definition:
lparser.h:97
name
GLuint const GLchar * name
Definition:
glew.h:1782
Labellist
struct Labellist Labellist
FuncState::np
int np
Definition:
lparser.h:105
Vardesc
struct Vardesc Vardesc
FuncState::f
Proto * f
Definition:
lparser.h:96
luaY_parser
LUAI_FUNC Closure * luaY_parser(lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar)
Definition:
lparser.cpp:1617
expdesc
Definition:
lparser.h:39
expdesc
struct expdesc expdesc
expdesc::u
union expdesc::@13 u
Labellist
Definition:
lparser.h:71
Mbuffer
Definition:
lzio.h:22
expdesc::f
int f
Definition:
lparser.h:51
FuncState
struct FuncState FuncState
Dyndata::size
int size
Definition:
lparser.h:83
Vardesc
Definition:
lparser.h:56
FuncState::bl
struct BlockCnt * bl
Definition:
lparser.h:100
lua_Number
LUA_NUMBER lua_Number
Definition:
lua.h:102
VUPVAL
Definition:
lparser.h:27
VFALSE
Definition:
lparser.h:22
FuncState::prev
struct FuncState * prev
Definition:
lparser.h:98
expdesc::k
expkind k
Definition:
lparser.h:40
Generated by
1.8.8