Debian Codegraph @

src/symbol.h

raw symbols SCIP
1 // ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
2 // Copyright (C) 1998-2024 Marco Baye
3 // Have a look at "acme.c" for further info
4 //
5 // symbol stuff
6 #ifndef symbol_H
7 #define symbol_H
8
9
10 #include <stdio.h>
11 #include "config.h"
12
13
14 struct symbol {
15 struct object object; // number/list/string
16 boolean has_been_read; // to find out if actually used
17 boolean has_been_reported; // indicates "has been reported as undefined"
18 struct pseudopc *pseudopc; // for "unpseudopc"-Operator '&', may be NULL
19 struct location definition; // for info message after "symbol already defined" error
20 // the next field is used for two different purposes:
21 // forward anon counter symbols use this for "reset-to-0-in-each-pass",
22 // all other symbols use it to tell the difference between
23 // "symbol already defined" (same pass number) and
24 // "symbol redefined" (different pass numbers).
25 int pass_number;
26 };
27
28
29 // Constants
30 #define SCOPE_GLOBAL 0 // number of "global zone"
31
32
33 // variables
34 extern struct rwnode *symbols_forest[]; // trees (because of 8-bit hash)
35
36
37 // search for symbol. if it does not exist, create with NULL type object (CAUTION!).
38 // the symbol name must be held in GlobalDynaBuf.
39 extern struct symbol *symbol_find(scope_t scope);
40
41 // assign object to symbol. function acts upon the symbol's flag bits and
42 // produces an error if needed.
43 // using "power" bits, caller can state which changes are ok.
44 #define POWER_NONE 0
45 #define POWER_CHANGE_VALUE (1u << 0) // e.g. change 3 to 5 or 2.71
46 #define POWER_CHANGE_OBJTYPE (1u << 1) // e.g. change 3 to "somestring"
47 extern void symbol_set_object(struct symbol *symbol, struct object *new_obj, bits powers);
48
49 // set force bit of symbol. trying to change to a different one will raise error.
50 extern void symbol_set_force_bit(struct symbol *symbol, bits force_bit);
51
52 // create and return symbol for "-D" command line switch (with NULL type object, CAUTION!).
53 // name must be held in GlobalDynaBuf
54 extern struct symbol *symbol_for_cli_def(void);
55 // set symbol to integer value, no questions asked (for "-D" switch)
56 extern void symbol_define_int(struct symbol *symbol, intval_t value);
57 // set symbol to string value, no questions asked (for "-D" switch)
58 // string value must be held in GlobalDynaBuf
59 extern void symbol_define_string(struct symbol *symbol);
60
61 // dump global symbols to file
62 extern void symbols_list(FILE *fd);
63
64 // dump global labels to file in VICE format
65 extern void symbols_vicelabels(FILE *fd);
66
67 // fix name of anonymous forward label (held in GlobalDynaBuf, NOT TERMINATED!)
68 // so it references the *next* anonymous forward label definition.
69 extern void symbol_fix_forward_anon_name(boolean increment);
70
71
72 #endif