more cleanup

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@353 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye
2024-03-03 12:49:03 +00:00
parent 5fc6a8a5e3
commit 8f9e3a5855
9 changed files with 40 additions and 41 deletions

View File

@@ -82,6 +82,7 @@ void RISCOS_throwback(const char *message, int type)
// only use throwback protocol if wanted // only use throwback protocol if wanted
if ((RISCOS_flags & RISCOSFLAG_THROWBACK) == 0) if ((RISCOS_flags & RISCOSFLAG_THROWBACK) == 0)
return; return;
// if this is the first throwback, set it up and send info // if this is the first throwback, set it up and send info
if ((RISCOS_flags & RISCOSFLAG_THROWN) == 0) { if ((RISCOS_flags & RISCOSFLAG_THROWN) == 0) {
RISCOS_flags |= RISCOSFLAG_THROWN; RISCOS_flags |= RISCOSFLAG_THROWN;
@@ -89,14 +90,14 @@ void RISCOS_throwback(const char *message, int type)
regs.r[0] = 0; regs.r[0] = 0;
regs.r[1] = 0; regs.r[1] = 0;
// regs.r[2] = (int) toplevel_source; // regs.r[2] = (int) toplevel_source;
regs.r[2] = (int) input_now->original_filename; regs.r[2] = (int) input_now->location.filename;
_kernel_swi(XDDEUTILS_THROWBACKSEND, &regs, &regs); _kernel_swi(XDDEUTILS_THROWBACKSEND, &regs, &regs);
} }
// send throwback message // send throwback message
regs.r[0] = 1; regs.r[0] = 1;
regs.r[1] = 0; regs.r[1] = 0;
regs.r[2] = (int) input_now->original_filename; regs.r[2] = (int) input_now->location.filename;
regs.r[3] = input_now->line_number; regs.r[3] = input_now->location.line_number;
regs.r[4] = type; regs.r[4] = type;
regs.r[5] = (int) message; regs.r[5] = (int) message;
_kernel_swi(XDDEUTILS_THROWBACKSEND, &regs, &regs); _kernel_swi(XDDEUTILS_THROWBACKSEND, &regs, &regs);

View File

@@ -53,7 +53,7 @@ boolean check_ifdef_condition(void)
// parse a loop body (TODO - also use for macro body?) // parse a loop body (TODO - also use for macro body?)
static void parse_ram_block(struct block *block) static void parse_ram_block(struct block *block)
{ {
input_now->line_number = block->start; // set line number to loop start input_now->location.line_number = block->start; // set line number to loop start
input_now->src.ram_ptr = block->body; // set RAM read pointer to loop input_now->src.ram_ptr = block->body; // set RAM read pointer to loop
// parse block // parse block
parse_until_eob_or_eof(); parse_until_eob_or_eof();
@@ -131,7 +131,7 @@ void flow_forloop(struct for_loop *loop)
// (not yet useable; pointer and line number are still missing) // (not yet useable; pointer and line number are still missing)
input_now = &loop_input; input_now = &loop_input;
// fix line number (not for block, but in case symbol handling throws errors) // fix line number (not for block, but in case symbol handling throws errors)
input_now->line_number = loop->block.start; input_now->location.line_number = loop->block.start;
switch (loop->algorithm) { switch (loop->algorithm) {
case FORALGO_OLDCOUNT: case FORALGO_OLDCOUNT:
case FORALGO_NEWCOUNT: case FORALGO_NEWCOUNT:
@@ -178,7 +178,7 @@ static void copy_condition(struct condition *condition, char terminator)
void flow_store_doloop_condition(struct condition *condition, char terminator) void flow_store_doloop_condition(struct condition *condition, char terminator)
{ {
// write line number // write line number
condition->line = input_now->line_number; condition->line = input_now->location.line_number;
// set defaults // set defaults
condition->invert = FALSE; condition->invert = FALSE;
condition->body = NULL; condition->body = NULL;
@@ -207,7 +207,7 @@ void flow_store_doloop_condition(struct condition *condition, char terminator)
// call with GotByte = first interesting character // call with GotByte = first interesting character
void flow_store_while_condition(struct condition *condition) void flow_store_while_condition(struct condition *condition)
{ {
condition->line = input_now->line_number; condition->line = input_now->location.line_number;
condition->invert = FALSE; condition->invert = FALSE;
copy_condition(condition, CHAR_SOB); copy_condition(condition, CHAR_SOB);
} }
@@ -223,7 +223,7 @@ static boolean check_condition(struct condition *condition)
return TRUE; // non-existing conditions are always true return TRUE; // non-existing conditions are always true
// set up input for expression evaluation // set up input for expression evaluation
input_now->line_number = condition->line; input_now->location.line_number = condition->line;
input_now->src.ram_ptr = condition->body; input_now->src.ram_ptr = condition->body;
GetByte(); // proceed with next char GetByte(); // proceed with next char
ALU_defined_int(&intresult); ALU_defined_int(&intresult);

View File

@@ -224,6 +224,7 @@ static void set_label(scope_t scope, bits force_bit, bits powers)
symbol_set_object(symbol, &result, powers); symbol_set_object(symbol, &result, powers);
if (force_bit) if (force_bit)
symbol_set_force_bit(symbol, force_bit); symbol_set_force_bit(symbol, force_bit);
// FIXME - move this to symbol_set_object() and call it for all address symbols!
symbol->pseudopc = pseudopc_get_context(); symbol->pseudopc = pseudopc_get_context();
// global labels must open new scope for cheap locals // global labels must open new scope for cheap locals
if (scope == SCOPE_GLOBAL) if (scope == SCOPE_GLOBAL)
@@ -443,16 +444,17 @@ static void throw_msg(const char *message, const char *ansicolor, const char *ty
resetcolor = ""; resetcolor = "";
} }
if (config.format_msvc) if (config.format_msvc) {
fprintf(config.msg_stream, "%s(%d) : %s%s%s (%s %s): %s\n", fprintf(config.msg_stream, "%s(%d) : %s%s%s (%s %s): %s\n",
input_now->original_filename, input_now->line_number, input_now->location.filename, input_now->location.line_number,
ansicolor, type, resetcolor, ansicolor, type, resetcolor,
section_now->type, section_now->title, message); section_now->type, section_now->title, message);
else } else {
fprintf(config.msg_stream, "%s%s%s - File %s, line %d (%s %s): %s\n", fprintf(config.msg_stream, "%s%s%s - File %s, line %d (%s %s): %s\n",
ansicolor, type, resetcolor, ansicolor, type, resetcolor,
input_now->original_filename, input_now->line_number, input_now->location.filename, input_now->location.line_number,
section_now->type, section_now->title, message); section_now->type, section_now->title, message);
}
} }
// generate debug/info/warning/error message // generate debug/info/warning/error message
@@ -527,6 +529,7 @@ void throw_symbol_error(const char *msg)
// handle bugs // handle bugs
// FIXME - use a local buffer and sprintf/snprintf to put error code into message!
void BUG(const char *message, int code) void BUG(const char *message, int code)
{ {
Throw_warning("Bug in ACME, code follows"); Throw_warning("Bug in ACME, code follows");

View File

@@ -26,8 +26,10 @@ const char FILE_READBINARY[] = "rb";
// fake input structure (for error msgs before any real input is established) // fake input structure (for error msgs before any real input is established)
static struct input outermost = { static struct input outermost = {
"<none>", // file name {
0, // line number "<none>", // file name
0, // line number
},
INPUTSRC_FILE, // fake file access, so no RAM read INPUTSRC_FILE, // fake file access, so no RAM read
INPUTSTATE_EOF, // state of input INPUTSTATE_EOF, // state of input
{ {
@@ -45,8 +47,8 @@ struct input *input_now = &outermost; // current input structure
// let current input point to start of file // let current input point to start of file
void input_new_file(const char *filename, FILE *fd) void input_new_file(const char *filename, FILE *fd)
{ {
input_now->original_filename = filename; input_now->location.filename = filename;
input_now->line_number = 1; input_now->location.line_number = 1;
input_now->source = INPUTSRC_FILE; input_now->source = INPUTSRC_FILE;
input_now->state = INPUTSTATE_SOF; input_now->state = INPUTSTATE_SOF;
input_now->src.fd = fd; input_now->src.fd = fd;
@@ -65,7 +67,7 @@ static void report_srcchar(char new_char)
// if input has changed, insert explanation // if input has changed, insert explanation
if (input_now != report->last_input) { if (input_now != report->last_input) {
fprintf(report->fd, "\n; ******** Source: %s\n", input_now->original_filename); fprintf(report->fd, "\n; ******** Source: %s\n", input_now->location.filename);
report->last_input = input_now; report->last_input = input_now;
report->asc_used = 0; // clear buffer report->asc_used = 0; // clear buffer
prev_char = '\0'; prev_char = '\0';
@@ -74,7 +76,7 @@ static void report_srcchar(char new_char)
// line start after line break detected and EOS processed, // line start after line break detected and EOS processed,
// build report line: // build report line:
// show line number... // show line number...
fprintf(report->fd, "%6d ", input_now->line_number - 1); fprintf(report->fd, "%6d ", input_now->location.line_number - 1);
// prepare outbytes' start address // prepare outbytes' start address
if (report->bin_used) { if (report->bin_used) {
#if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L #if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
@@ -284,10 +286,10 @@ char GetByte(void)
// // if start-of-line was read, increment line counter and repeat // // if start-of-line was read, increment line counter and repeat
// if (GotByte != CHAR_SOL) // if (GotByte != CHAR_SOL)
// return GotByte; // return GotByte;
// input_now->line_number++; // input_now->location.line_number++;
// } // }
if (GotByte == CHAR_SOL) if (GotByte == CHAR_SOL)
input_now->line_number++; input_now->location.line_number++;
return GotByte; return GotByte;
} }

View File

@@ -31,9 +31,7 @@ enum inputsrc {
INPUTSRC_RAM INPUTSRC_RAM
}; };
struct input { struct input {
// FIXME - use struct location for first two elements: struct location location; // file + line (during RAM reads as well)
const char *original_filename; // during RAM reads, too
int line_number; // in file (on RAM reads, too)
enum inputsrc source; enum inputsrc source;
enum inputstate state; // state of input enum inputstate state; // state of input
union { union {

View File

@@ -131,8 +131,7 @@ static int search_for_macro(struct rwnode **result, scope_t scope, int create)
static void report_redefinition(struct rwnode *macro_node) static void report_redefinition(struct rwnode *macro_node)
{ {
struct macro *original_macro = macro_node->body; struct macro *original_macro = macro_node->body;
const char *buffered_filename; struct location buffered_location;
int buffered_linenum;
const char *buffered_section_type; const char *buffered_section_type;
char *buffered_section_title; char *buffered_section_title;
@@ -142,20 +141,17 @@ static void report_redefinition(struct rwnode *macro_node)
// data to generate helpful error messages // data to generate helpful error messages
// FIXME - move this to a function so "symbol twice" error can also use it // FIXME - move this to a function so "symbol twice" error can also use it
// buffer old data // buffer old data
buffered_filename = input_now->original_filename; buffered_location = input_now->location;
buffered_linenum = input_now->line_number;
buffered_section_type = section_now->type; buffered_section_type = section_now->type;
buffered_section_title = section_now->title; buffered_section_title = section_now->title;
// set new (fake) data // set new (fake) data
input_now->original_filename = original_macro->definition.filename; input_now->location = original_macro->definition;
input_now->line_number = original_macro->definition.line_number;
section_now->type = "earlier"; section_now->type = "earlier";
section_now->title = "definition"; section_now->title = "definition";
// show error with location of earlier definition // show error with location of earlier definition
Throw_error(exception_macro_twice); Throw_error(exception_macro_twice);
// restore old data // restore old data
input_now->original_filename = buffered_filename; input_now->location = buffered_location;
input_now->line_number = buffered_linenum;
section_now->type = buffered_section_type; section_now->type = buffered_section_type;
section_now->title = buffered_section_title; section_now->title = buffered_section_title;
} }
@@ -214,8 +210,8 @@ void macro_parse_definition(void) // Now GotByte = illegal char after "!macro"
report_redefinition(macro_node); report_redefinition(macro_node);
// Create new macro struct and set it up. Finally we'll read the body. // Create new macro struct and set it up. Finally we'll read the body.
new_macro = safe_malloc(sizeof(*new_macro)); new_macro = safe_malloc(sizeof(*new_macro));
new_macro->definition.line_number = input_now->line_number; new_macro->definition.line_number = input_now->location.line_number;
new_macro->definition.filename = get_string_copy(input_now->original_filename); new_macro->definition.filename = get_string_copy(input_now->location.filename);
new_macro->original_name = get_string_copy(user_macro_name->buffer); new_macro->original_name = get_string_copy(user_macro_name->buffer);
new_macro->parameter_list = formal_parameters; new_macro->parameter_list = formal_parameters;
new_macro->body = input_skip_or_store_block(TRUE); // changes LineNumber new_macro->body = input_skip_or_store_block(TRUE); // changes LineNumber
@@ -292,8 +288,7 @@ void macro_parse_call(void) // Now GotByte = first char of macro name
local_gotbyte = GotByte; // CAUTION - ugly kluge local_gotbyte = GotByte; // CAUTION - ugly kluge
// set up new input // set up new input
new_input.original_filename = actual_macro->definition.filename; new_input.location = actual_macro->definition;
new_input.line_number = actual_macro->definition.line_number;
new_input.source = INPUTSRC_RAM; new_input.source = INPUTSRC_RAM;
new_input.state = INPUTSTATE_NORMAL; // FIXME - fix others! new_input.state = INPUTSTATE_NORMAL; // FIXME - fix others!
new_input.src.ram_ptr = actual_macro->parameter_list; new_input.src.ram_ptr = actual_macro->parameter_list;

View File

@@ -1182,7 +1182,7 @@ does not fail. */
Throw_serious_error(exception_no_left_brace); Throw_serious_error(exception_no_left_brace);
// remember line number of loop pseudo opcode // remember line number of loop pseudo opcode
loop.block.start = input_now->line_number; loop.block.start = input_now->location.line_number;
// read loop body into DynaBuf and get copy // read loop body into DynaBuf and get copy
loop.block.body = input_skip_or_store_block(TRUE); // changes line number! loop.block.body = input_skip_or_store_block(TRUE); // changes line number!
@@ -1208,7 +1208,7 @@ static enum eos po_do(void) // now GotByte = illegal char
Throw_serious_error(exception_no_left_brace); Throw_serious_error(exception_no_left_brace);
// remember line number of loop body, // remember line number of loop body,
// then read block and get copy // then read block and get copy
loop.block.start = input_now->line_number; loop.block.start = input_now->location.line_number;
// reading block changes line number! // reading block changes line number!
loop.block.body = input_skip_or_store_block(TRUE); // must be freed! loop.block.body = input_skip_or_store_block(TRUE); // must be freed!
// now GotByte = '}' // now GotByte = '}'
@@ -1237,7 +1237,7 @@ static enum eos po_while(void) // now GotByte = illegal char
Throw_serious_error(exception_no_left_brace); Throw_serious_error(exception_no_left_brace);
// remember line number of loop body, // remember line number of loop body,
// then read block and get copy // then read block and get copy
loop.block.start = input_now->line_number; loop.block.start = input_now->location.line_number;
// reading block changes line number! // reading block changes line number!
loop.block.body = input_skip_or_store_block(TRUE); // must be freed! loop.block.body = input_skip_or_store_block(TRUE); // must be freed!
// clear tail condition // clear tail condition

View File

@@ -16,8 +16,8 @@ struct symbol {
int pass; // pass of creation (for anon counters) int pass; // pass of creation (for anon counters)
boolean has_been_read; // to find out if actually used boolean has_been_read; // to find out if actually used
boolean has_been_reported; // indicates "has been reported as undefined" boolean has_been_reported; // indicates "has been reported as undefined"
struct pseudopc *pseudopc; // NULL when defined outside of !pseudopc block (FIXME - not in future!) struct pseudopc *pseudopc; // for "unpseudopc"-Operator '&', may be NULL
// add file ref + line num of last definition //TODO struct location definition; // for "label twice" error
}; };

View File

@@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME #define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release #define CODENAME "Zem" // update before release
#define CHANGE_DATE "25 Feb" // update before release FIXME #define CHANGE_DATE "26 Feb" // update before release FIXME
#define CHANGE_YEAR "2024" // update before release #define CHANGE_YEAR "2024" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" //#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME #define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME