aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/tads/tads2/post_compilation.h
blob: 1dde838d02bb92dc383d8e550659c578f500007d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

/* definitions for post-compilation setup
 *
 * Does post-compilation setup, such as setting up contents lists
 * faster run-time performance, but run - time errors could be disastrous.
 */

#ifndef GLK_TADS_TADS2_POST_COMPILATION
#define GLK_TADS_TADS2_POST_COMPILATION

#include "glk/tads/tads2/run.h"
#include "glk/tads/tads2/tokenizer.h"
#include "glk/tads/tads2/vocabulary.h"

namespace Glk {
namespace TADS {
namespace TADS2 {

/* setup context */
struct supcxdef {
    errcxdef *supcxerr;
    mcmcxdef *supcxmem;                    /* memory manager client context */
    voccxdef *supcxvoc;                   /* player command parsing context */
    tokthdef *supcxtab;                           /* top-level symbol table */
    runcxdef *supcxrun;                                /* execution context */
    uchar    *supcxbuf;                        /* space for building a list */
    ushort    supcxlen;                                   /* size of buffer */
};

/* set up contents list for one object for demand-on-load */
void supcont(void *ctx, objnum obj, prpnum prp);

/* set up inherited vocabulary (called before executing game) */
void supivoc(supcxdef *ctx);

/* find required objects/functions */
void supfind(errcxdef *ctx, tokthdef *tab, voccxdef *voc,
             objnum *preinit, int warnlevel, int casefold);

/* set up reserved words */
void suprsrv(supcxdef *sup, void (*bif[])(struct bifcxdef *, int),
             toktdef *tab, int fncntmax, int v1compat, char *new_do,
             int casefold);

/* set up built-in functions without symbol table (for run-time) */
void supbif(supcxdef *sup, void (*bif[])(struct bifcxdef *, int),
            int bifsiz);

/* log an undefined-object error */
void sup_log_undefobj(mcmcxdef *mctx, errcxdef *ec, int err,
                      char *sym_name, int sym_name_len, objnum objn);

/* set up inherited vocabulary for a particular object */
void supivoc1(supcxdef *sup, voccxdef *ctx, vocidef *v, objnum target,
              int inh_from_obj, int flags);

/* get name of an object out of symbol table */
void supgnam(char *buf, tokthdef *tab, objnum objn);

/* table of built-in functions */
typedef struct supbidef supbidef;
struct supbidef
{
    char  *supbinam;                                    /* name of function */
    void (*supbifn)(struct bifcxdef *, int);           /* C routine to call */
};

/* external definition for special token table */
extern tokldef supsctab[];

} // End of namespace TADS2
} // End of namespace TADS
} // End of namespace Glk

#endif