]> git.proxmox.com Git - ceph.git/blame - ceph/src/lua/src/lparser.h
bump version to 15.2.11-pve1
[ceph.git] / ceph / src / lua / src / lparser.h
CommitLineData
7c673cae
FG
1/*
2** $Id: lparser.h,v 1.74 2014/10/25 11:50:46 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 descriptor
17*/
18
19typedef enum {
20 VVOID, /* no value */
21 VNIL,
22 VTRUE,
23 VFALSE,
24 VK, /* info = index of constant in 'k' */
25 VKFLT, /* nval = numerical float value */
26 VKINT, /* nval = numerical integer value */
27 VNONRELOC, /* info = result register */
28 VLOCAL, /* info = local register */
29 VUPVAL, /* info = index of upvalue in 'upvalues' */
30 VINDEXED, /* t = table register/upvalue; idx = index R/K */
31 VJMP, /* info = instruction pc */
32 VRELOCABLE, /* info = instruction pc */
33 VCALL, /* info = instruction pc */
34 VVARARG /* info = instruction pc */
35} expkind;
36
37
38#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
39#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
40
41typedef struct expdesc {
42 expkind k;
43 union {
44 struct { /* for indexed variables (VINDEXED) */
45 short idx; /* index (R/K) */
46 lu_byte t; /* table (register or upvalue) */
47 lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
48 } ind;
49 int info; /* for generic use */
50 lua_Number nval; /* for VKFLT */
51 lua_Integer ival; /* for VKINT */
52 } u;
53 int t; /* patch list of 'exit when true' */
54 int f; /* patch list of 'exit when false' */
55} expdesc;
56
57
58/* description of active local variable */
59typedef struct Vardesc {
60 short idx; /* variable index in stack */
61} Vardesc;
62
63
64/* description of pending goto statements and label statements */
65typedef struct Labeldesc {
66 TString *name; /* label identifier */
67 int pc; /* position in code */
68 int line; /* line where it appeared */
69 lu_byte nactvar; /* local level where it appears in current block */
70} Labeldesc;
71
72
73/* list of labels or gotos */
74typedef struct Labellist {
75 Labeldesc *arr; /* array */
76 int n; /* number of entries in use */
77 int size; /* array size */
78} Labellist;
79
80
81/* dynamic structures used by the parser */
82typedef struct Dyndata {
83 struct { /* list of active local variables */
84 Vardesc *arr;
85 int n;
86 int size;
87 } actvar;
88 Labellist gt; /* list of pending gotos */
89 Labellist label; /* list of active labels */
90} Dyndata;
91
92
93/* control of blocks */
94struct BlockCnt; /* defined in lparser.c */
95
96
97/* state needed to generate code for a given function */
98typedef struct FuncState {
99 Proto *f; /* current function header */
100 struct FuncState *prev; /* enclosing function */
101 struct LexState *ls; /* lexical state */
102 struct BlockCnt *bl; /* chain of current blocks */
103 int pc; /* next position to code (equivalent to 'ncode') */
104 int lasttarget; /* 'label' of last 'jump label' */
105 int jpc; /* list of pending jumps to 'pc' */
106 int nk; /* number of elements in 'k' */
107 int np; /* number of elements in 'p' */
108 int firstlocal; /* index of first local var (in Dyndata array) */
109 short nlocvars; /* number of elements in 'f->locvars' */
110 lu_byte nactvar; /* number of active local variables */
111 lu_byte nups; /* number of upvalues */
112 lu_byte freereg; /* first free register */
113} FuncState;
114
115
116LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
117 Dyndata *dyd, const char *name, int firstchar);
118
119
120#endif