ScummVM API documentation
grammar.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
#ifndef PRIVATE_GRAMMAR_H
23
#define PRIVATE_GRAMMAR_H
24
25
#include "common/str.h"
26
#include "common/hash-str.h"
27
#include "common/hash-ptr.h"
28
#include "common/queue.h"
29
#include "common/list.h"
30
#include "common/array.h"
31
#include "common/rect.h"
32
33
#include "private/symbol.h"
34
35
#define NSTACK 256
36
#define NPROG 10000
37
38
namespace
Private
{
39
40
typedef
struct
Datum
{
/* interpreter stack type */
41
short
type;
42
union
{
43
int
val;
44
const
char
*str;
45
Symbol
*sym;
46
Common::Rect
*rect;
47
} u;
48
}
Datum
;
49
50
typedef
struct
Arg
{
51
int
n;
52
int (** inst)();
53
}
Arg
;
54
55
typedef
int (* Inst)();
/* machine instruction */
56
#define STOP (Inst) 0
57
58
typedef
Common::HashMap<void *, Common::String *>
PtrToName
;
59
60
void
initInsts();
61
void
initFuncs();
62
63
namespace
Settings {
64
65
typedef
struct
Setting
{
66
Datum
stack[NSTACK];
/* the stack */
67
Inst prog[NPROG];
/* the machine */
68
}
Setting
;
69
70
typedef
Common::HashMap<Common::String, Setting *>
SettingMap
;
71
72
class
SettingMaps
{
73
public
:
74
Setting
*_setting;
75
SettingMap _map;
76
77
void
init();
78
void
save(
const
char
*);
79
void
load(
const
Common::String
&);
80
};
81
82
extern
SettingMaps
*g_setts;
83
84
}
85
86
// Funtions
87
88
typedef
Common::Array<Datum>
ArgArray
;
89
void
call(
const
char
*,
const
ArgArray &);
90
91
// Code Generation and Execution
92
93
namespace
Gen {
94
95
class
VM
{
96
public
:
97
Datum
*_stack;
/* the stack */
98
Datum
*_stackp;
/* next free spot on stack */
99
100
Inst *_progp;
/* next free spot for code generation */
101
Inst *_prog;
/* the machine */
102
Inst *_pc;
/* program counter during execution */
103
void
run();
/* run the virtual machine */
104
};
105
106
extern
VM
*g_vm;
107
108
Datum
pop();
109
int
push(
const
Datum
&);
110
111
Inst *code(
const
Inst &);
112
int
eval();
113
int
add();
114
int
negate();
115
int
power();
116
int
assign();
117
int
bltin();
118
int
varpush();
119
int
constpush();
120
int
strpush();
121
int
funcpush();
122
int
print();
123
int
ifcode();
124
int
fail();
125
int
lt();
126
int
gt();
127
int
le();
128
int
ge();
129
int
eq();
130
int
ne();
131
int
randbool();
132
133
// Code Execution
134
135
void
execute(Inst *);
136
137
}
138
139
}
// End of namespace Private
140
141
#endif
Common::String
Definition:
str.h:59
Common::Array< Datum >
Private::Settings::Setting
Definition:
grammar.h:65
Common::Rect
Definition:
rect.h:144
Private::Symbol
Definition:
symbol.h:35
Private::Gen::VM
Definition:
grammar.h:95
Common::HashMap
Definition:
hashmap.h:85
Private
Definition:
decompiler.h:30
Private::Settings::SettingMaps
Definition:
grammar.h:72
Private::Arg
Definition:
grammar.h:50
Private::Datum
Definition:
grammar.h:40
engines
private
grammar.h
Generated on Sat Aug 31 2024 09:12:58 for ScummVM API documentation by
1.8.13