-
Notifications
You must be signed in to change notification settings - Fork 0
/
symbol.h
55 lines (42 loc) · 1.5 KB
/
symbol.h
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
/* MIX simulator, copyright 1994 by Darius Bacon */
#ifndef SYMBOL_H
#define SYMBOL_H
#include "mix.h"
typedef struct AddressList {
struct AddressList *next;
Address address;
} *AddressList;
/* --- Symbols --- */
typedef struct Symbol {
struct Symbol *next;
char *name;
Flag defined;
Cell cell;
AddressList references;
} *Symbol;
/*
* If sym->defined, then sym->cell is the symbol's value.
* If !sym->defined, then sym->references is the set of
* references to sym. When the symbol is finally defined,
* the address field (0:2) of each cell in sym->references
* gets set to the defined value.
*/
/* Return the symbol named;
if it doesn't exist, create it, initially undefined. */
Symbol string_to_symbol(const char *name);
Flag is_defined(Symbol symbol);
/* Pre: is_defined(symbol) */
Cell symbol_value(Symbol symbol);
/* Pre: !is_defined(symbol)
Post: address has been adjoined to symbol's references. */
void forward_reference(Symbol symbol, Address address);
/* Post: symbol_value(symbol) == cell
If symbol was undefined, then all refs to it are resolved.
If symbol was already defined, and non-local, then gives a warning. */
void define_symbol(Symbol symbol, Cell cell);
/* Return a symbol, distinct from all symbols defined in the source program,
whose value will be set, when resolve_generated_futures() is called,
to the address of a cell which contains value. */
Symbol generate_future_sym(Cell value);
void resolve_generated_futures(void);
#endif