ScummVM API documentation
lstate.h
1
/*
2
** Global State
3
** See Copyright Notice in lua.h
4
*/
5
6
#ifndef GRIM_LSTATE_H
7
#define GRIM_LSTATE_H
8
9
#include "engines/grim/lua/lobject.h"
10
11
#include <setjmp.h>
12
13
namespace
Grim
{
14
15
#define MAX_C_BLOCKS 10
16
#define GARBAGE_BLOCK 150
17
18
/* The pause status for the scripts is stored in one byte in the savegame.
19
*
20
* The "single script pause" status will be stored in the highest significant bit.
21
* For GRIM that flag is never set because GRIM does not pause single scripts.
22
*
23
* The "all scripts pause" status is a number which counts, how often
24
* pause_scripts(TRUE) was called without a corresponding unpause_scripts() call.
25
* The value is stored in the lower 7 bit of the pause status byte.
26
* For GRIM, since the (un)pause_scripts() are called symmetrically, only
27
* the lowest bit will be used.
28
*/
29
#define LUA_SG_ALL_PAUSED 0x7f
30
#define LUA_SG_PAUSED 0x80
31
32
typedef
int32
StkId
;
/* index to stack elements */
33
34
struct
Stack
{
35
TObject
*top;
36
TObject
*stack;
37
TObject
*last;
38
};
39
40
struct
C_Lua_Stack
{
41
StkId base;
// when Lua calls C or C calls Lua, points to
42
// the first slot after the last parameter.
43
StkId lua2C;
// points to first element of "array" lua2C
44
int32 num;
// size of "array" lua2C
45
};
46
47
48
typedef
struct
{
49
int32 size;
50
int32 nuse;
// number of elements (including EMPTYs)
51
TaggedString
**hash;
52
}
stringtable
;
53
54
enum
Status { LOCK, HOLD, FREE, COLLECTED };
55
56
struct
ref
{
57
TObject
o;
58
enum
Status status;
59
};
60
61
struct
CallInfo
{
62
Closure
*c;
63
TProtoFunc
*tf;
// Set to NULL for C function
64
StkId base;
65
byte *pc;
66
int32 nResults;
67
};
68
69
struct
lua_Task
;
70
71
extern
GCnode
rootproto;
72
extern
GCnode
rootcl;
73
extern
GCnode
rootglobal;
74
extern
GCnode
roottable;
75
extern
struct
ref
*refArray;
76
extern
int32 refSize;
77
extern
int32 GCthreshold;
78
extern
int32 nblocks;
79
extern
int32 Mbuffsize;
80
extern
int32 Mbuffnext;
81
extern
char
*Mbuffbase;
82
extern
char
*
Mbuffer
;
83
extern
TObject
errorim;
84
extern
stringtable
*string_root;
85
extern
int32 last_tag;
86
extern
struct
IM
*IMtable;
87
extern
int32 IMtable_size;
88
89
struct
LState
{
90
LState
*prev;
// handle to previous state in list
91
LState
*next;
// handle to next state in list
92
int
all_paused;
// counter of often pause_scripts(TRUE) was called
93
bool
paused;
// true if this particular script has been paused
94
int32 preventBreakCounter;
95
int32 callLevelCounter;
96
bool
updated;
97
Stack
stack;
// Lua stack
98
C_Lua_Stack
Cstack;
// C2lua struct
99
struct
FuncState
*mainState, *currState;
// point to local structs in yacc
100
struct
LexState
*lexstate;
// point to local struct in yacc
101
jmp_buf *errorJmp;
// current error recover point
102
lua_Task
*task;
// handle to task
103
lua_Task
*prevTask;
104
uint32 id;
// current id of task
105
TObject
taskFunc;
106
struct
C_Lua_Stack
Cblocks[MAX_C_BLOCKS];
107
int
numCblocks;
// number of nested Cblocks
108
int
sleepFor;
109
};
110
111
extern
LState
*lua_state, *lua_rootState;
112
113
extern
int
globalTaskSerialId;
114
115
void
lua_stateinit(
LState
*state);
116
void
lua_statedeinit(
LState
*state);
117
void
lua_resetglobals();
118
119
}
// end of namespace Grim
120
121
#endif
Grim::C_Lua_Stack
Definition:
lstate.h:40
lua_TValue
Definition:
lobject.h:73
Grim::TObject
Definition:
lobject.h:65
Grim::CallInfo
Definition:
lstate.h:61
Grim::TProtoFunc
Definition:
lobject.h:93
Grim::LState
Definition:
lstate.h:89
Grim::ref
Definition:
lstate.h:56
Grim::IM
Definition:
ltm.h:42
Grim::TaggedString
Definition:
lobject.h:82
Grim::lua_Task
Definition:
ltask.h:10
Grim
Definition:
actor.h:33
Mbuffer
Definition:
lzio.h:24
FuncState
Definition:
lparser.h:58
Grim::Closure
Definition:
lobject.h:122
Grim::stringtable
Definition:
lstate.h:48
Grim::GCnode
Definition:
lobject.h:73
Grim::Stack
Definition:
lstate.h:34
Grim::LexState
Definition:
llex.h:24
engines
grim
lua
lstate.h
Generated on Fri Nov 22 2024 09:08:17 for ScummVM API documentation by
1.8.13