mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-02-16 19:32:16 +00:00
first step to refactor symbol assignments
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@212 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
7a0f9f9528
commit
9db5ad6fdb
@ -347,13 +347,16 @@ Too many '('.
|
||||
Un-pseudopc operator '&' can only be applied to labels.
|
||||
You tried to apply the operator '&' to something that is not a
|
||||
label. This operator only works on labels, it cannot be used on
|
||||
the results of calculations.
|
||||
other objects.
|
||||
|
||||
Un-pseudopc operator '&' has no !pseudopc context.
|
||||
You tried to apply the operator '&' to a label that wasn't defined
|
||||
in a !pseudopc block.
|
||||
Or, more generally, you used more '&' characters on the label than
|
||||
there were !pseudopc blocks around it.
|
||||
You either tried to apply the operator '&' to something that is
|
||||
not an implicitly defined label, but the result of an explicit
|
||||
symbol assignment (like the result of a calculation).
|
||||
Or you applied the operator to a label that was defined outside of
|
||||
a !pseudopc block, or, more generally, the number of '&'
|
||||
characters used was larger than the number of !pseudopc blocks
|
||||
around the definition.
|
||||
|
||||
Unknown encoding.
|
||||
You used the "!convtab" command with a keyword ACME does not know.
|
||||
|
41
src/symbol.c
41
src/symbol.c
@ -105,6 +105,31 @@ static void dump_vice_unusednonaddress(struct rwnode *node, FILE *fd)
|
||||
}
|
||||
|
||||
|
||||
// temporary helper function to properly refactor this mess
|
||||
static struct symbol *temp_find(scope_t scope)
|
||||
{
|
||||
struct rwnode *node;
|
||||
struct symbol *symbol;
|
||||
boolean node_created;
|
||||
|
||||
node_created = Tree_hard_scan(&node, symbols_forest, scope, TRUE);
|
||||
// if node has just been created, create symbol as well
|
||||
if (node_created) {
|
||||
// create new symbol structure
|
||||
symbol = safe_malloc(sizeof(*symbol));
|
||||
node->body = symbol;
|
||||
// finish empty symbol item
|
||||
symbol->object.type = NULL; // no object yet (CAUTION!)
|
||||
symbol->usage = 0; // usage count
|
||||
symbol->pass = pass.number;
|
||||
symbol->has_been_reported = FALSE;
|
||||
symbol->pseudopc = NULL;
|
||||
} else {
|
||||
symbol = node->body;
|
||||
}
|
||||
return symbol; // now symbol->object.type can be tested to see if this was freshly created.
|
||||
// CAUTION: this only works if caller always sets a type pointer after checking! if NULL is kept, the struct still looks new later on...
|
||||
}
|
||||
// search for symbol. create if nonexistant. if created, give it flags "flags".
|
||||
// the symbol name must be held in GlobalDynaBuf.
|
||||
/*
|
||||
@ -125,28 +150,18 @@ symbol.c
|
||||
*/
|
||||
struct symbol *symbol_find(scope_t scope, int flags)
|
||||
{
|
||||
struct rwnode *node;
|
||||
struct symbol *symbol;
|
||||
boolean node_created;
|
||||
int new_force_bits;
|
||||
|
||||
node_created = Tree_hard_scan(&node, symbols_forest, scope, TRUE);
|
||||
// if node has just been created, create symbol as well
|
||||
if (node_created) {
|
||||
// create new symbol structure
|
||||
symbol = safe_malloc(sizeof(*symbol));
|
||||
symbol = temp_find(scope);
|
||||
// if symbol has no object assigned to it, make it an int
|
||||
if (symbol->object.type == NULL) {
|
||||
// finish empty symbol item
|
||||
symbol->object.type = &type_int;
|
||||
symbol->object.u.number.flags = flags;
|
||||
symbol->object.u.number.addr_refs = 0;
|
||||
symbol->object.u.number.val.intval = 0;
|
||||
symbol->usage = 0; // usage count
|
||||
symbol->pass = pass.number;
|
||||
symbol->has_been_reported = FALSE;
|
||||
symbol->pseudopc = NULL;
|
||||
node->body = symbol;
|
||||
} else {
|
||||
symbol = node->body;
|
||||
// make sure the force bits don't clash
|
||||
if ((symbol->object.type == &type_int)
|
||||
|| (symbol->object.type == &type_float)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user