Ardour
9.0-pre0-582-g084a23a80d
lparser.h
Go to the documentation of this file.
1
/*
2
** $Id: lparser.h,v 1.76.1.1 2017/04/19 17:20:42 roberto Exp $
3
** Lua Parser
4
** See Copyright Notice in lua.h
5
*/
6
7
#ifndef lparser_h
8
#define lparser_h
9
10
#include "
llimits.h
"
11
#include "
lobject.h
"
12
#include "
lzio.h
"
13
14
15
/*
16
** Expression and variable descriptor.
17
** Code generation for variables and expressions can be delayed to allow
18
** optimizations; An 'expdesc' structure describes a potentially-delayed
19
** variable/expression. It has a description of its "main" value plus a
20
** list of conditional jumps that can also produce its value (generated
21
** by short-circuit operators 'and'/'or').
22
*/
23
24
/* kinds of variables/expressions */
25
typedef
enum
{
26
VVOID
,
/* when 'expdesc' describes the last expression a list,
27
this kind means an empty list (so, no expression) */
28
VNIL
,
/* constant nil */
29
VTRUE
,
/* constant true */
30
VFALSE
,
/* constant false */
31
VK
,
/* constant in 'k'; info = index of constant in 'k' */
32
VKFLT
,
/* floating constant; nval = numerical float value */
33
VKINT
,
/* integer constant; nval = numerical integer value */
34
VNONRELOC
,
/* expression has its value in a fixed register;
35
info = result register */
36
VLOCAL
,
/* local variable; info = local register */
37
VUPVAL
,
/* upvalue variable; info = index of upvalue in 'upvalues' */
38
VINDEXED
,
/* indexed variable;
39
ind.vt = whether 't' is register or upvalue;
40
ind.t = table register or upvalue;
41
ind.idx = key's R/K index */
42
VJMP
,
/* expression is a test/comparison;
43
info = pc of corresponding jump instruction */
44
VRELOCABLE
,
/* expression can put result in any register;
45
info = instruction pc */
46
VCALL
,
/* expression is a function call; info = instruction pc */
47
VVARARG
/* vararg expression; info = instruction pc */
48
}
expkind
;
49
50
51
#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
52
#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
53
54
typedef
struct
expdesc
{
55
expkind
k
;
56
union
{
57
lua_Integer
ival
;
/* for VKINT */
58
lua_Number
nval
;
/* for VKFLT */
59
int
info
;
/* for generic use */
60
struct
{
/* for indexed variables (VINDEXED) */
61
short
idx
;
/* index (R/K) */
62
lu_byte
t
;
/* table (register or upvalue) */
63
lu_byte
vt
;
/* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
64
}
ind
;
65
}
u
;
66
int
t
;
/* patch list of 'exit when true' */
67
int
f
;
/* patch list of 'exit when false' */
68
}
expdesc
;
69
70
71
/* description of active local variable */
72
typedef
struct
Vardesc
{
73
short
idx
;
/* variable index in stack */
74
}
Vardesc
;
75
76
77
/* description of pending goto statements and label statements */
78
typedef
struct
Labeldesc
{
79
TString
*
name
;
/* label identifier */
80
int
pc
;
/* position in code */
81
int
line
;
/* line where it appeared */
82
lu_byte
nactvar
;
/* local level where it appears in current block */
83
}
Labeldesc
;
84
85
86
/* list of labels or gotos */
87
typedef
struct
Labellist
{
88
Labeldesc
*
arr
;
/* array */
89
int
n
;
/* number of entries in use */
90
int
size
;
/* array size */
91
}
Labellist
;
92
93
94
/* dynamic structures used by the parser */
95
typedef
struct
Dyndata
{
96
struct
{
/* list of active local variables */
97
Vardesc
*
arr
;
98
int
n
;
99
int
size
;
100
}
actvar
;
101
Labellist
gt
;
/* list of pending gotos */
102
Labellist
label
;
/* list of active labels */
103
}
Dyndata
;
104
105
106
/* control of blocks */
107
struct
BlockCnt;
/* defined in lparser.c */
108
109
110
/* state needed to generate code for a given function */
111
typedef
struct
FuncState
{
112
Proto
*
f
;
/* current function header */
113
struct
FuncState
*
prev
;
/* enclosing function */
114
struct
LexState
*
ls
;
/* lexical state */
115
struct
BlockCnt *
bl
;
/* chain of current blocks */
116
int
pc
;
/* next position to code (equivalent to 'ncode') */
117
int
lasttarget
;
/* 'label' of last 'jump label' */
118
int
jpc
;
/* list of pending jumps to 'pc' */
119
int
nk
;
/* number of elements in 'k' */
120
int
np
;
/* number of elements in 'p' */
121
int
firstlocal
;
/* index of first local var (in Dyndata array) */
122
short
nlocvars
;
/* number of elements in 'f->locvars' */
123
lu_byte
nactvar
;
/* number of active local variables */
124
lu_byte
nups
;
/* number of upvalues */
125
lu_byte
freereg
;
/* first free register */
126
}
FuncState
;
127
128
129
LUAI_FUNC
LClosure
*
luaY_parser
(
lua_State
*L,
ZIO
*z,
Mbuffer
*buff,
130
Dyndata
*dyd,
const
char
*
name
,
int
firstchar);
131
132
133
#endif
name
GtkImageIconNameData name
Definition:
gtkimage.h:6
llimits.h
lu_byte
unsigned char lu_byte
Definition:
llimits.h:35
lobject.h
FuncState
struct FuncState FuncState
expdesc
struct expdesc expdesc
Vardesc
struct Vardesc Vardesc
Labeldesc
struct Labeldesc Labeldesc
luaY_parser
LClosure * luaY_parser(lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar)
Labellist
struct Labellist Labellist
Dyndata
struct Dyndata Dyndata
expkind
expkind
Definition:
lparser.h:25
VTRUE
@ VTRUE
Definition:
lparser.h:29
VFALSE
@ VFALSE
Definition:
lparser.h:30
VVARARG
@ VVARARG
Definition:
lparser.h:47
VKFLT
@ VKFLT
Definition:
lparser.h:32
VNIL
@ VNIL
Definition:
lparser.h:28
VKINT
@ VKINT
Definition:
lparser.h:33
VUPVAL
@ VUPVAL
Definition:
lparser.h:37
VNONRELOC
@ VNONRELOC
Definition:
lparser.h:34
VINDEXED
@ VINDEXED
Definition:
lparser.h:38
VRELOCABLE
@ VRELOCABLE
Definition:
lparser.h:44
VJMP
@ VJMP
Definition:
lparser.h:42
VLOCAL
@ VLOCAL
Definition:
lparser.h:36
VVOID
@ VVOID
Definition:
lparser.h:26
VCALL
@ VCALL
Definition:
lparser.h:46
VK
@ VK
Definition:
lparser.h:31
lua_Integer
LUA_INTEGER lua_Integer
Definition:
lua-5.3.5/lua.h:93
lua_Number
double lua_Number
Definition:
lua-5.3.5/lua.h:89
LUAI_FUNC
#define LUAI_FUNC
Definition:
luaconf.h:282
lzio.h
Dyndata
Definition:
lparser.h:95
Dyndata::gt
Labellist gt
Definition:
lparser.h:101
Dyndata::size
int size
Definition:
lparser.h:99
Dyndata::label
Labellist label
Definition:
lparser.h:102
Dyndata::arr
Vardesc * arr
Definition:
lparser.h:97
Dyndata::n
int n
Definition:
lparser.h:98
Dyndata::actvar
struct Dyndata::@35 actvar
FuncState
Definition:
lparser.h:111
FuncState::nactvar
lu_byte nactvar
Definition:
lparser.h:123
FuncState::jpc
int jpc
Definition:
lparser.h:118
FuncState::bl
struct BlockCnt * bl
Definition:
lparser.h:115
FuncState::nk
int nk
Definition:
lparser.h:119
FuncState::nlocvars
short nlocvars
Definition:
lparser.h:122
FuncState::firstlocal
int firstlocal
Definition:
lparser.h:121
FuncState::freereg
lu_byte freereg
Definition:
lparser.h:125
FuncState::f
Proto * f
Definition:
lparser.h:112
FuncState::nups
lu_byte nups
Definition:
lparser.h:124
FuncState::np
int np
Definition:
lparser.h:120
FuncState::pc
int pc
Definition:
lparser.h:116
FuncState::prev
struct FuncState * prev
Definition:
lparser.h:113
FuncState::ls
struct LexState * ls
Definition:
lparser.h:114
FuncState::lasttarget
int lasttarget
Definition:
lparser.h:117
LClosure
Definition:
lobject.h:453
Labeldesc
Definition:
lparser.h:78
Labeldesc::pc
int pc
Definition:
lparser.h:80
Labeldesc::nactvar
lu_byte nactvar
Definition:
lparser.h:82
Labeldesc::line
int line
Definition:
lparser.h:81
Labeldesc::name
TString * name
Definition:
lparser.h:79
Labellist
Definition:
lparser.h:87
Labellist::size
int size
Definition:
lparser.h:90
Labellist::arr
Labeldesc * arr
Definition:
lparser.h:88
Labellist::n
int n
Definition:
lparser.h:89
LexState
Definition:
llex.h:58
Mbuffer
Definition:
lzio.h:23
Proto
Definition:
lobject.h:407
TString
Definition:
lobject.h:303
Vardesc
Definition:
lparser.h:72
Vardesc::idx
short idx
Definition:
lparser.h:73
Zio
Definition:
lzio.h:55
expdesc
Definition:
lparser.h:54
expdesc::info
int info
Definition:
lparser.h:59
expdesc::idx
short idx
Definition:
lparser.h:61
expdesc::u
union expdesc::@33 u
expdesc::t
int t
Definition:
lparser.h:66
expdesc::ival
lua_Integer ival
Definition:
lparser.h:57
expdesc::vt
lu_byte vt
Definition:
lparser.h:63
expdesc::nval
lua_Number nval
Definition:
lparser.h:58
expdesc::k
expkind k
Definition:
lparser.h:55
expdesc::ind
struct expdesc::@33::@34 ind
expdesc::f
int f
Definition:
lparser.h:67
expdesc::t
lu_byte t
Definition:
lparser.h:62
lua_State
Definition:
lstate.h:178
libs
lua
lua-5.3.5
lparser.h
Generated on Wed Dec 25 2024 05:44:34 for Ardour by
1.9.1