2016-12-28 20:32:00 +00:00
|
|
|
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
|
2024-01-28 19:38:20 +00:00
|
|
|
// Copyright (C) 1998-2024 Marco Baye
|
2014-06-07 00:12:10 +00:00
|
|
|
// Have a look at "acme.c" for further info
|
|
|
|
//
|
|
|
|
// symbol stuff
|
|
|
|
#ifndef symbol_H
|
|
|
|
#define symbol_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct symbol {
|
2020-05-29 10:57:01 +00:00
|
|
|
struct object object; // number/list/string
|
2014-06-07 00:12:10 +00:00
|
|
|
int pass; // pass of creation (for anon counters)
|
2020-06-08 17:01:17 +00:00
|
|
|
boolean has_been_read; // to find out if actually used
|
2020-05-02 21:59:20 +00:00
|
|
|
boolean has_been_reported; // indicates "has been reported as undefined"
|
2024-03-03 12:49:03 +00:00
|
|
|
struct pseudopc *pseudopc; // for "unpseudopc"-Operator '&', may be NULL
|
|
|
|
//TODO struct location definition; // for "label twice" error
|
2014-06-07 00:12:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-08-05 09:59:07 +00:00
|
|
|
// Constants
|
|
|
|
#define SCOPE_GLOBAL 0 // number of "global zone"
|
|
|
|
|
|
|
|
|
2014-06-07 00:12:10 +00:00
|
|
|
// variables
|
2014-11-24 14:52:05 +00:00
|
|
|
extern struct rwnode *symbols_forest[]; // trees (because of 8-bit hash)
|
2014-06-07 00:12:10 +00:00
|
|
|
|
|
|
|
|
2020-06-05 15:15:12 +00:00
|
|
|
// search for symbol. if it does not exist, create with NULL type object (CAUTION!).
|
2020-06-05 01:11:51 +00:00
|
|
|
// the symbol name must be held in GlobalDynaBuf.
|
|
|
|
extern struct symbol *symbol_find(scope_t scope);
|
2024-01-28 19:38:20 +00:00
|
|
|
|
2020-06-13 23:11:10 +00:00
|
|
|
// assign object to symbol. function acts upon the symbol's flag bits and
|
|
|
|
// produces an error if needed.
|
|
|
|
// using "power" bits, caller can state which changes are ok.
|
|
|
|
#define POWER_NONE 0
|
|
|
|
#define POWER_CHANGE_VALUE (1u << 0) // e.g. change 3 to 5 or 2.71
|
|
|
|
#define POWER_CHANGE_OBJTYPE (1u << 1) // e.g. change 3 to "somestring"
|
2020-06-14 00:26:38 +00:00
|
|
|
extern void symbol_set_object(struct symbol *symbol, struct object *new_obj, bits powers);
|
2024-01-28 19:38:20 +00:00
|
|
|
|
2020-06-13 23:11:10 +00:00
|
|
|
// set force bit of symbol. trying to change to a different one will raise error.
|
2020-06-14 00:26:38 +00:00
|
|
|
extern void symbol_set_force_bit(struct symbol *symbol, bits force_bit);
|
2024-01-28 19:38:20 +00:00
|
|
|
|
2014-06-07 00:12:10 +00:00
|
|
|
// set global symbol to value, no questions asked (for "-D" switch)
|
|
|
|
// name must be held in GlobalDynaBuf.
|
|
|
|
extern void symbol_define(intval_t value);
|
2024-01-28 19:38:20 +00:00
|
|
|
|
2014-06-07 00:12:10 +00:00
|
|
|
// dump global symbols to file
|
2014-11-22 01:36:02 +00:00
|
|
|
extern void symbols_list(FILE *fd);
|
2024-01-28 19:38:20 +00:00
|
|
|
|
2014-11-23 23:40:01 +00:00
|
|
|
// dump global labels to file in VICE format
|
|
|
|
extern void symbols_vicelabels(FILE *fd);
|
2024-01-28 19:38:20 +00:00
|
|
|
|
2014-06-07 00:12:10 +00:00
|
|
|
// fix name of anonymous forward label (held in GlobalDynaBuf, NOT TERMINATED!)
|
|
|
|
// so it references the *next* anonymous forward label definition.
|
2020-05-13 23:26:40 +00:00
|
|
|
extern void symbol_fix_forward_anon_name(boolean increment);
|
2014-06-07 00:12:10 +00:00
|
|
|
|
2024-01-29 22:02:28 +00:00
|
|
|
// replace name of dynamic symbol with its final version.
|
|
|
|
// return whether there was an error.
|
|
|
|
extern int symbol_fix_dynamic_name(void);
|
|
|
|
|
2014-06-07 00:12:10 +00:00
|
|
|
|
|
|
|
#endif
|