mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-04-12 16:37:18 +00:00
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:
parent
5fc6a8a5e3
commit
8f9e3a5855
@ -82,6 +82,7 @@ void RISCOS_throwback(const char *message, int type)
|
||||
// only use throwback protocol if wanted
|
||||
if ((RISCOS_flags & RISCOSFLAG_THROWBACK) == 0)
|
||||
return;
|
||||
|
||||
// if this is the first throwback, set it up and send info
|
||||
if ((RISCOS_flags & RISCOSFLAG_THROWN) == 0) {
|
||||
RISCOS_flags |= RISCOSFLAG_THROWN;
|
||||
@ -89,14 +90,14 @@ void RISCOS_throwback(const char *message, int type)
|
||||
regs.r[0] = 0;
|
||||
regs.r[1] = 0;
|
||||
// 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, ®s, ®s);
|
||||
}
|
||||
// send throwback message
|
||||
regs.r[0] = 1;
|
||||
regs.r[1] = 0;
|
||||
regs.r[2] = (int) input_now->original_filename;
|
||||
regs.r[3] = input_now->line_number;
|
||||
regs.r[2] = (int) input_now->location.filename;
|
||||
regs.r[3] = input_now->location.line_number;
|
||||
regs.r[4] = type;
|
||||
regs.r[5] = (int) message;
|
||||
_kernel_swi(XDDEUTILS_THROWBACKSEND, ®s, ®s);
|
||||
|
10
src/flow.c
10
src/flow.c
@ -53,7 +53,7 @@ boolean check_ifdef_condition(void)
|
||||
// parse a loop body (TODO - also use for macro body?)
|
||||
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
|
||||
// parse block
|
||||
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)
|
||||
input_now = &loop_input;
|
||||
// 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) {
|
||||
case FORALGO_OLDCOUNT:
|
||||
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)
|
||||
{
|
||||
// write line number
|
||||
condition->line = input_now->line_number;
|
||||
condition->line = input_now->location.line_number;
|
||||
// set defaults
|
||||
condition->invert = FALSE;
|
||||
condition->body = NULL;
|
||||
@ -207,7 +207,7 @@ void flow_store_doloop_condition(struct condition *condition, char terminator)
|
||||
// call with GotByte = first interesting character
|
||||
void flow_store_while_condition(struct condition *condition)
|
||||
{
|
||||
condition->line = input_now->line_number;
|
||||
condition->line = input_now->location.line_number;
|
||||
condition->invert = FALSE;
|
||||
copy_condition(condition, CHAR_SOB);
|
||||
}
|
||||
@ -223,7 +223,7 @@ static boolean check_condition(struct condition *condition)
|
||||
return TRUE; // non-existing conditions are always true
|
||||
|
||||
// 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;
|
||||
GetByte(); // proceed with next char
|
||||
ALU_defined_int(&intresult);
|
||||
|
11
src/global.c
11
src/global.c
@ -224,6 +224,7 @@ static void set_label(scope_t scope, bits force_bit, bits powers)
|
||||
symbol_set_object(symbol, &result, powers);
|
||||
if (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();
|
||||
// global labels must open new scope for cheap locals
|
||||
if (scope == SCOPE_GLOBAL)
|
||||
@ -443,16 +444,17 @@ static void throw_msg(const char *message, const char *ansicolor, const char *ty
|
||||
resetcolor = "";
|
||||
}
|
||||
|
||||
if (config.format_msvc)
|
||||
if (config.format_msvc) {
|
||||
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,
|
||||
section_now->type, section_now->title, message);
|
||||
else
|
||||
} else {
|
||||
fprintf(config.msg_stream, "%s%s%s - File %s, line %d (%s %s): %s\n",
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// generate debug/info/warning/error message
|
||||
@ -527,6 +529,7 @@ void throw_symbol_error(const char *msg)
|
||||
|
||||
|
||||
// handle bugs
|
||||
// FIXME - use a local buffer and sprintf/snprintf to put error code into message!
|
||||
void BUG(const char *message, int code)
|
||||
{
|
||||
Throw_warning("Bug in ACME, code follows");
|
||||
|
18
src/input.c
18
src/input.c
@ -26,8 +26,10 @@ const char FILE_READBINARY[] = "rb";
|
||||
|
||||
// fake input structure (for error msgs before any real input is established)
|
||||
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
|
||||
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
|
||||
void input_new_file(const char *filename, FILE *fd)
|
||||
{
|
||||
input_now->original_filename = filename;
|
||||
input_now->line_number = 1;
|
||||
input_now->location.filename = filename;
|
||||
input_now->location.line_number = 1;
|
||||
input_now->source = INPUTSRC_FILE;
|
||||
input_now->state = INPUTSTATE_SOF;
|
||||
input_now->src.fd = fd;
|
||||
@ -65,7 +67,7 @@ static void report_srcchar(char new_char)
|
||||
|
||||
// if input has changed, insert explanation
|
||||
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->asc_used = 0; // clear buffer
|
||||
prev_char = '\0';
|
||||
@ -74,7 +76,7 @@ static void report_srcchar(char new_char)
|
||||
// line start after line break detected and EOS processed,
|
||||
// build report line:
|
||||
// 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
|
||||
if (report->bin_used) {
|
||||
#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 (GotByte != CHAR_SOL)
|
||||
// return GotByte;
|
||||
// input_now->line_number++;
|
||||
// input_now->location.line_number++;
|
||||
// }
|
||||
if (GotByte == CHAR_SOL)
|
||||
input_now->line_number++;
|
||||
input_now->location.line_number++;
|
||||
return GotByte;
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,7 @@ enum inputsrc {
|
||||
INPUTSRC_RAM
|
||||
};
|
||||
struct input {
|
||||
// FIXME - use struct location for first two elements:
|
||||
const char *original_filename; // during RAM reads, too
|
||||
int line_number; // in file (on RAM reads, too)
|
||||
struct location location; // file + line (during RAM reads as well)
|
||||
enum inputsrc source;
|
||||
enum inputstate state; // state of input
|
||||
union {
|
||||
|
19
src/macro.c
19
src/macro.c
@ -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)
|
||||
{
|
||||
struct macro *original_macro = macro_node->body;
|
||||
const char *buffered_filename;
|
||||
int buffered_linenum;
|
||||
struct location buffered_location;
|
||||
const char *buffered_section_type;
|
||||
char *buffered_section_title;
|
||||
|
||||
@ -142,20 +141,17 @@ static void report_redefinition(struct rwnode *macro_node)
|
||||
// data to generate helpful error messages
|
||||
// FIXME - move this to a function so "symbol twice" error can also use it
|
||||
// buffer old data
|
||||
buffered_filename = input_now->original_filename;
|
||||
buffered_linenum = input_now->line_number;
|
||||
buffered_location = input_now->location;
|
||||
buffered_section_type = section_now->type;
|
||||
buffered_section_title = section_now->title;
|
||||
// set new (fake) data
|
||||
input_now->original_filename = original_macro->definition.filename;
|
||||
input_now->line_number = original_macro->definition.line_number;
|
||||
input_now->location = original_macro->definition;
|
||||
section_now->type = "earlier";
|
||||
section_now->title = "definition";
|
||||
// show error with location of earlier definition
|
||||
Throw_error(exception_macro_twice);
|
||||
// restore old data
|
||||
input_now->original_filename = buffered_filename;
|
||||
input_now->line_number = buffered_linenum;
|
||||
input_now->location = buffered_location;
|
||||
section_now->type = buffered_section_type;
|
||||
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);
|
||||
// Create new macro struct and set it up. Finally we'll read the body.
|
||||
new_macro = safe_malloc(sizeof(*new_macro));
|
||||
new_macro->definition.line_number = input_now->line_number;
|
||||
new_macro->definition.filename = get_string_copy(input_now->original_filename);
|
||||
new_macro->definition.line_number = input_now->location.line_number;
|
||||
new_macro->definition.filename = get_string_copy(input_now->location.filename);
|
||||
new_macro->original_name = get_string_copy(user_macro_name->buffer);
|
||||
new_macro->parameter_list = formal_parameters;
|
||||
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
|
||||
|
||||
// set up new input
|
||||
new_input.original_filename = actual_macro->definition.filename;
|
||||
new_input.line_number = actual_macro->definition.line_number;
|
||||
new_input.location = actual_macro->definition;
|
||||
new_input.source = INPUTSRC_RAM;
|
||||
new_input.state = INPUTSTATE_NORMAL; // FIXME - fix others!
|
||||
new_input.src.ram_ptr = actual_macro->parameter_list;
|
||||
|
@ -1182,7 +1182,7 @@ does not fail. */
|
||||
Throw_serious_error(exception_no_left_brace);
|
||||
|
||||
// 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
|
||||
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);
|
||||
// remember line number of loop body,
|
||||
// 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!
|
||||
loop.block.body = input_skip_or_store_block(TRUE); // must be freed!
|
||||
// now GotByte = '}'
|
||||
@ -1237,7 +1237,7 @@ static enum eos po_while(void) // now GotByte = illegal char
|
||||
Throw_serious_error(exception_no_left_brace);
|
||||
// remember line number of loop body,
|
||||
// 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!
|
||||
loop.block.body = input_skip_or_store_block(TRUE); // must be freed!
|
||||
// clear tail condition
|
||||
|
@ -16,8 +16,8 @@ struct symbol {
|
||||
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 (FIXME - not in future!)
|
||||
// add file ref + line num of last definition
|
||||
struct pseudopc *pseudopc; // for "unpseudopc"-Operator '&', may be NULL
|
||||
//TODO struct location definition; // for "label twice" error
|
||||
};
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#define RELEASE "0.97" // update before release FIXME
|
||||
#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 HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
|
||||
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME
|
||||
|
Loading…
x
Reference in New Issue
Block a user