changed symbol usage counter to "has been read" boolean

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@220 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2020-06-08 17:01:17 +00:00
parent 93cea56d88
commit a165279e88
5 changed files with 14 additions and 15 deletions

View File

@ -350,14 +350,17 @@ static void get_symbol_value(scope_t scope, char optional_prefix_char, size_t na
struct symbol *symbol;
struct object *arg;
// if the symbol gets created now, mark it as unsure
symbol = symbol_find(scope);
symbol->has_been_read = TRUE;
if (symbol->object.type == NULL) {
// finish symbol item by making it an undefined int
symbol->object.type = &type_int;
symbol->object.u.number.flags = NUMBER_EVER_UNDEFINED;
symbol->object.u.number.flags = NUMBER_EVER_UNDEFINED; // reading undefined taints it
symbol->object.u.number.addr_refs = 0;
symbol->object.u.number.val.intval = 0;
} else {
// FIXME - add sanity check for int/float where DEFINED is false and EVER_UNDEFINED is false -> Bug_found()!
// (because the only way to have DEFINED clear is the block above, and EVER_UNDEFINED taints everything it touches)
}
// first push on arg stack, so we have a local copy we can "unpseudopc"
arg = &arg_stack[arg_sp++];
@ -375,9 +378,6 @@ static void get_symbol_value(scope_t scope, char optional_prefix_char, size_t na
// FIXME - in case of unpseudopc, error message should include the correct amount of '&' characters
if (!(arg->type->is_defined(arg)))
is_not_defined(symbol, optional_prefix_char, GLOBALDYNABUF_CURRENT, name_length);
// in first pass, count usage
if (FIRST_PASS)
symbol->usage++;
// FIXME - if arg is list, increment ref count!
}

View File

@ -893,10 +893,9 @@ static boolean check_ifdef_condition(void)
return FALSE; // not found -> no, not defined
symbol = (struct symbol *) node->body;
// in first pass, count usage
if (FIRST_PASS)
symbol->usage++;
// TODO - if object type is NULL, return FALSE!
symbol->has_been_read = TRUE; // we did not really read the symbol's value, but checking for its existence still counts as "used it"
if (symbol->object.type == NULL)
Bug_found("ObjectHasNullType", 0); // FIXME - add to docs!
return symbol->object.type->is_defined(&symbol->object);
}
// if/ifdef/ifndef/else function, to be able to do ELSE IF

View File

@ -66,7 +66,7 @@ static void dump_one_symbol(struct rwnode *node, FILE *fd)
}
if (symbol->object.u.number.flags & NUMBER_EVER_UNDEFINED)
fprintf(fd, "\t; ?"); // TODO - write "forward" instead?
if (symbol->usage == 0)
if (!symbol->has_been_read)
fprintf(fd, "\t; unused");
fprintf(fd, "\n");
}
@ -88,7 +88,7 @@ static void dump_vice_usednonaddress(struct rwnode *node, FILE *fd)
struct symbol *symbol = node->body;
// dump non-addresses that are used
if (symbol->usage
if (symbol->has_been_read
&& (symbol->object.type == &type_int)
&& (symbol->object.u.number.flags & NUMBER_IS_DEFINED)
&& (symbol->object.u.number.addr_refs != 1))
@ -99,7 +99,7 @@ static void dump_vice_unusednonaddress(struct rwnode *node, FILE *fd)
struct symbol *symbol = node->body;
// dump non-addresses that are unused
if (!symbol->usage
if (!symbol->has_been_read
&& (symbol->object.type == &type_int)
&& (symbol->object.u.number.flags & NUMBER_IS_DEFINED)
&& (symbol->object.u.number.addr_refs != 1))
@ -123,8 +123,8 @@ struct symbol *symbol_find(scope_t scope)
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_read = FALSE;
symbol->has_been_reported = FALSE;
symbol->pseudopc = NULL;
} else {

View File

@ -13,8 +13,8 @@
struct symbol {
struct object object; // number/list/string
int usage; // usage count
int pass; // pass of creation (for anon counters)
boolean has_been_read; // to find out if actually used
boolean has_been_reported; // indicates "has been reported as undefined"
struct pseudopc *pseudopc; // NULL when defined outside of !pseudopc block
// add file ref + line num of last definition

View File

@ -9,7 +9,7 @@
#define RELEASE "0.96.5" // update before release FIXME
#define CODENAME "Fenchurch" // update before release
#define CHANGE_DATE "7 June" // update before release FIXME
#define CHANGE_DATE "8 June" // update before release FIXME
#define CHANGE_YEAR "2020" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME