From 1f74a6b8fdbfeca84bf05153c4977414fe2fc862 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Mon, 8 Jun 2020 17:25:50 +0000 Subject: [PATCH] comments only git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@221 4df02467-bbd4-4a76-a152-e7ce94205b78 --- src/alu.h | 2 +- src/symbol.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/alu.h b/src/alu.h index bb9661d..dcaffc1 100644 --- a/src/alu.h +++ b/src/alu.h @@ -47,7 +47,7 @@ struct expression { // undefined expression. Needed for producing the same addresses in all // passes; because in the first pass there will almost for sure be // labels that are undefined, we can't simply get the addressing mode - // from looking at the parameter's value. + // from looking at the parameter's value. FIXME - rename to TAINTED :) // create dynamic buffer, operator/function trees and operator/operand stacks diff --git a/src/symbol.c b/src/symbol.c index cf3aa49..f54c7fb 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -198,9 +198,17 @@ static void symbol_set_object(struct symbol *symbol, struct object *new_value, b // take flags from new value, then OR EVER_UNDEFINED from old value flags = (flags & NUMBER_EVER_UNDEFINED) | new_value->u.number.flags; } else { - if ((flags & NUMBER_FORCEBITS) == 0) - if ((flags & (NUMBER_EVER_UNDEFINED | NUMBER_IS_DEFINED)) == 0) // FIXME - this can't happen!? + if ((flags & NUMBER_FORCEBITS) == 0) { + if ((flags & (NUMBER_EVER_UNDEFINED | NUMBER_IS_DEFINED)) == 0) { + // FIXME - this can't happen!? Yes, it can! + // if the symbol was created just now to be assigned a value, + // then both flags are clear before the assignment takes place. + // in future this should no longer happen, because creating a + // symbol will give it the NULL type, and flags will only + // matter if it then gets assigned an int or float value. flags |= new_value->u.number.flags & NUMBER_FORCEBITS; + } + } flags |= new_value->u.number.flags & ~NUMBER_FORCEBITS; } symbol->object.u.number.flags = flags; @@ -208,7 +216,7 @@ static void symbol_set_object(struct symbol *symbol, struct object *new_value, b // FIXME - temporary helper function during refactoring // used for: // (implicit!) label definitions, including anons (FIXME - anons cannot have force bits. handle them elsewhere? change backward anons directly, no questions asked?) -// setting up loop counter for "!for" (actual incrementing is then done directly!) +// setting up loop counter for "!for" (CAUTION: actual incrementing is then done directly without calling this function!) // "change_allowed" is used by backward anons, but then force_bit is 0 // "change_allowed" is also used by "!for", then force_bit may be nonzero void symbol_set_object2(struct symbol *symbol, struct object *result, int force_bit, boolean change_allowed) @@ -230,6 +238,7 @@ void symbol_set_object3(struct symbol *symbol, struct object *result, int force_ // (but only do this for numbers!) if (((symbol->object.type == &type_int) || (symbol->object.type == &type_float)) && ((result->type == &type_int) || (result->type == &type_float))) { + // clear symbol's size flags, set new one, clear result's size flags symbol->object.u.number.flags &= ~(NUMBER_FORCEBITS | NUMBER_FITS_BYTE); if (force_bit) { symbol->object.u.number.flags |= force_bit;