mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-12-23 10:29:46 +00:00
comments only
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@213 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
9db5ad6fdb
commit
72fc28e84c
@ -351,7 +351,7 @@ static void get_symbol_value(scope_t scope, char optional_prefix_char, size_t na
|
||||
struct object *arg;
|
||||
|
||||
// if the symbol gets created now, mark it as unsure
|
||||
symbol = symbol_find(scope, NUMBER_EVER_UNDEFINED);
|
||||
symbol = symbol_find(scope, NUMBER_EVER_UNDEFINED); // TODO - split into "find" and "if NULL object, make into undefined int"
|
||||
// first push on arg stack, so we have a local copy we can "unpseudopc"
|
||||
arg = &arg_stack[arg_sp++];
|
||||
*arg = symbol->object;
|
||||
|
10
src/global.c
10
src/global.c
@ -162,13 +162,13 @@ static int first_label_of_statement(int *statement_flags)
|
||||
// parse label definition (can be either global or local).
|
||||
// name must be held in GlobalDynaBuf.
|
||||
// called by parse_symbol_definition, parse_backward_anon_def, parse_forward_anon_def
|
||||
static void set_label(scope_t scope, int stat_flags, int force_bit, boolean change_allowed)
|
||||
static void set_label(scope_t scope, int stat_flags, int force_bit, boolean change_allowed) // "change_allowed" is used by backward anons!
|
||||
{
|
||||
struct number pc;
|
||||
struct object result;
|
||||
struct symbol *symbol;
|
||||
|
||||
symbol = symbol_find(scope, force_bit);
|
||||
symbol = symbol_find(scope, force_bit); // TODO - split into "find", "forcebit handling", "if NULL object, make int" and "if not int, complain"
|
||||
// label definition
|
||||
if ((stat_flags & SF_FOUND_BLANK) && config.warn_on_indented_labels)
|
||||
Throw_first_pass_warning("Label name not in leftmost column.");
|
||||
@ -178,7 +178,7 @@ static void set_label(scope_t scope, int stat_flags, int force_bit, boolean chan
|
||||
result.u.number.flags = pc.flags & NUMBER_IS_DEFINED;
|
||||
result.u.number.val.intval = pc.val.intval;
|
||||
result.u.number.addr_refs = pc.addr_refs;
|
||||
symbol_set_object(symbol, &result, change_allowed);
|
||||
symbol_set_object(symbol, &result, change_allowed); // FIXME - "backward anon allows number redef" is different from "!set allows object redef"!
|
||||
symbol->pseudopc = pseudopc_get_context();
|
||||
// global labels must open new scope for cheap locals
|
||||
if (scope == SCOPE_GLOBAL)
|
||||
@ -197,7 +197,7 @@ static void parse_symbol_definition(scope_t scope, int stat_flags)
|
||||
|
||||
if (GotByte == '=') {
|
||||
// explicit symbol definition (symbol = <something>)
|
||||
symbol = symbol_find(scope, force_bit);
|
||||
symbol = symbol_find(scope, force_bit); // FIXME - split into "find", "forcebit handling", "if not NULL object, types must be equal"...
|
||||
// symbol = parsed value
|
||||
GetByte(); // skip '='
|
||||
ALU_any_result(&result);
|
||||
@ -251,6 +251,7 @@ static void parse_backward_anon_def(int *statement_flags)
|
||||
{
|
||||
if (!first_label_of_statement(statement_flags))
|
||||
return;
|
||||
|
||||
DYNABUF_CLEAR(GlobalDynaBuf);
|
||||
do
|
||||
DYNABUF_APPEND(GlobalDynaBuf, '-');
|
||||
@ -265,6 +266,7 @@ static void parse_forward_anon_def(int *statement_flags)
|
||||
{
|
||||
if (!first_label_of_statement(statement_flags))
|
||||
return;
|
||||
|
||||
DYNABUF_CLEAR(GlobalDynaBuf);
|
||||
DynaBuf_append(GlobalDynaBuf, '+');
|
||||
while (GotByte == '+') {
|
||||
|
@ -266,7 +266,7 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
|
||||
GetByte(); // skip '~' character
|
||||
Input_read_scope_and_keyword(&symbol_scope);
|
||||
// GotByte = illegal char
|
||||
arg_table[arg_count].symbol = symbol_find(symbol_scope, 0);
|
||||
arg_table[arg_count].symbol = symbol_find(symbol_scope, 0); // FIXME - do not default to undefined int!
|
||||
} else {
|
||||
// read call-by-value arg
|
||||
DynaBuf_append(internal_name, ARGTYPE_VALUE);
|
||||
@ -319,6 +319,7 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
|
||||
// assign call-by-reference arg
|
||||
GetByte(); // skip '~' character
|
||||
Input_read_scope_and_keyword(&symbol_scope);
|
||||
// create new tree node and link existing symbol struct from arg list to it
|
||||
if ((Tree_hard_scan(&symbol_node, symbols_forest, symbol_scope, TRUE) == FALSE)
|
||||
&& (FIRST_PASS))
|
||||
Throw_error("Macro parameter twice.");
|
||||
@ -326,11 +327,12 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
|
||||
} else {
|
||||
// assign call-by-value arg
|
||||
Input_read_scope_and_keyword(&symbol_scope);
|
||||
symbol = symbol_find(symbol_scope, 0);
|
||||
symbol = symbol_find(symbol_scope, 0); // FIXME - split into "find", "ensure freshly created"
|
||||
// FIXME - add a possibility to symbol_find to make it possible to find out
|
||||
// whether symbol was just created. Then check for the same error message here
|
||||
// as above ("Macro parameter twice.").
|
||||
symbol->object = arg_table[arg_count].result;
|
||||
// TODO - on the other hand, this would rule out globals as args (stupid anyway, but not illegal yet!)
|
||||
symbol->object = arg_table[arg_count].result; // FIXME - this assignment redefines globals without throwing errors!
|
||||
}
|
||||
++arg_count;
|
||||
} while (Input_accept_comma());
|
||||
|
@ -749,7 +749,7 @@ static enum eos po_set(void) // now GotByte = illegal char
|
||||
return SKIP_REMAINDER;
|
||||
|
||||
force_bit = Input_get_force_bit(); // skips spaces after
|
||||
symbol = symbol_find(scope, force_bit);
|
||||
symbol = symbol_find(scope, force_bit); // FIXME - split into "find" and "handle forcebits", remove the "default to undefined int" part!
|
||||
if (GotByte != '=') {
|
||||
Throw_error(exception_syntax);
|
||||
return SKIP_REMAINDER;
|
||||
@ -914,6 +914,7 @@ static boolean check_ifdef_condition(void)
|
||||
// in first pass, count usage
|
||||
if (FIRST_PASS)
|
||||
symbol->usage++;
|
||||
// TODO - if object type is NULL, return FALSE!
|
||||
return symbol->object.type->is_defined(&symbol->object);
|
||||
}
|
||||
// if/ifdef/ifndef/else function, to be able to do ELSE IF
|
||||
@ -1056,7 +1057,7 @@ static enum eos po_for(void) // now GotByte = illegal char
|
||||
|
||||
// now GotByte = illegal char
|
||||
force_bit = Input_get_force_bit(); // skips spaces after
|
||||
loop.symbol = symbol_find(scope, force_bit);
|
||||
loop.symbol = symbol_find(scope, force_bit); // FIXME - split into "find" and "handle force bit". if type is not NULL, complain if not number!
|
||||
if (!Input_accept_comma()) {
|
||||
Throw_error(exception_syntax);
|
||||
return SKIP_REMAINDER;
|
||||
|
@ -35,6 +35,8 @@ static void dump_one_symbol(struct rwnode *node, FILE *fd)
|
||||
&& (symbol->object.type != &type_float))
|
||||
return;
|
||||
|
||||
// CAUTION: if more types are added, check for NULL before using type pointer!
|
||||
|
||||
// output name
|
||||
if (config.warn_on_type_mismatch
|
||||
&& symbol->object.u.number.addr_refs == 1)
|
||||
@ -148,7 +150,7 @@ symbol.c
|
||||
symbol_define
|
||||
symbol_fix_forward_anon_name
|
||||
*/
|
||||
struct symbol *symbol_find(scope_t scope, int flags)
|
||||
struct symbol *symbol_find(scope_t scope, int flags) // FIXME - "flags" is either 0 or UNDEFINED or a forcebit, right? move UNDEFINED and forcebit stuff elsewhere!
|
||||
{
|
||||
struct symbol *symbol;
|
||||
int new_force_bits;
|
||||
@ -177,7 +179,8 @@ struct symbol *symbol_find(scope_t scope, int flags)
|
||||
|
||||
// assign value to symbol. the function acts upon the symbol's flag bits and
|
||||
// produces an error if needed.
|
||||
void symbol_set_object(struct symbol *symbol, struct object *new_value, boolean change_allowed)
|
||||
// TODO - split checks into two parts: first deal with object type. in case of number, then check value/flags/whatever
|
||||
void symbol_set_object(struct symbol *symbol, struct object *new_value, boolean change_allowed) // FIXME - does "change_allowed" refer to type change or number value change?
|
||||
{
|
||||
int flags; // for int/float re-definitions
|
||||
|
||||
@ -224,7 +227,7 @@ void symbol_set_object(struct symbol *symbol, struct object *new_value, boolean
|
||||
}
|
||||
|
||||
|
||||
// set global symbol to value, no questions asked (for "-D" switch)
|
||||
// set global symbol to integer value, no questions asked (for "-D" switch)
|
||||
// Name must be held in GlobalDynaBuf.
|
||||
void symbol_define(intval_t value)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user