"input_now" ptr is no longer exported

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@388 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-08-05 10:49:33 +00:00
parent 7015508538
commit 25fcf4f1f4
7 changed files with 38 additions and 30 deletions

View File

@ -144,6 +144,7 @@ void flow_forloop(struct for_loop *loop)
// read condition, make copy, link to struct
// FIXME - change to some input_line_getcopy() fn, like input_block_getcopy()!
static void copy_condition(struct condition *condition, char terminator)
{
int err;
@ -172,8 +173,11 @@ static void copy_condition(struct condition *condition, char terminator)
// call with GotByte = first interesting character
void flow_store_doloop_condition(struct condition *condition, char terminator)
{
struct location loc;
// write line number
condition->block.line_number = input_now->location.line_number;
input_get_location(&loc); // FIXME - get rid of this when changing copy_condition to input_line_getcopy!
condition->block.line_number = loc.line_number;
// set defaults
condition->invert = FALSE;
condition->block.body = NULL;
@ -202,7 +206,10 @@ 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->block.line_number = input_now->location.line_number;
struct location loc;
input_get_location(&loc); // FIXME - get rid of this when changing copy_condition to input_line_getcopy!
condition->block.line_number = loc.line_number;
condition->invert = FALSE;
copy_condition(condition, CHAR_SOB);
}

View File

@ -491,7 +491,8 @@ bits parser_get_force_bit(void)
// This function will do the actual output for warnings, errors and serious
// errors. It shows the given message string, as well as the current
// context: file name, line number, source type and source title.
static void throw_msg(const char *message, const char *ansicolor, const char *type)
// if the "optional alternative location" given is NULL, the current location is used
static void throw_msg(const char *message, const char *ansicolor, const char *type, struct location *opt_alt_loc)
{
const char *resetcolor = "\033[0m";
struct location location;
@ -501,7 +502,11 @@ static void throw_msg(const char *message, const char *ansicolor, const char *ty
resetcolor = "";
}
input_get_location(&location);
// optional alternative location given?
if (opt_alt_loc)
location = *opt_alt_loc; // use alternative location
else
input_get_location(&location); // use current location
if (config.format_msvc) {
fprintf(config.msg_stream, "%s(%d) : %s%s%s (%s %s): %s\n",
@ -517,7 +522,8 @@ static void throw_msg(const char *message, const char *ansicolor, const char *ty
}
// generate debug/info/warning/error message
void throw_message(enum debuglevel level, const char msg[])
// if the "optional alternative location" given is NULL, the current location is used
void throw_message(enum debuglevel level, const char msg[], struct location *opt_alt_loc)
{
// if level is taken from source, ensure valid value:
if (level < DEBUGLEVEL_SERIOUS)
@ -528,14 +534,14 @@ void throw_message(enum debuglevel level, const char msg[])
// output a serious error
// (assembly stops, for example if outbuffer overruns).
PLATFORM_SERIOUS(msg);
throw_msg(msg, "\033[1m\033[31m", "Serious error"); // bold + red
throw_msg(msg, "\033[1m\033[31m", "Serious error", opt_alt_loc); // bold + red
//++pass.error_count; // FIXME - needed when problem below is solved
exit(ACME_finalize(EXIT_FAILURE)); // FIXME - this inhibits output of macro call stack
case DEBUGLEVEL_ERROR:
// output an error
// (something is wrong, no output file will be generated).
PLATFORM_ERROR(msg);
throw_msg(msg, "\033[31m", "Error"); // red
throw_msg(msg, "\033[31m", "Error", opt_alt_loc); // red
++pass.error_count;
if (pass.error_count >= config.max_errors)
exit(ACME_finalize(EXIT_FAILURE));
@ -547,7 +553,7 @@ void throw_message(enum debuglevel level, const char msg[])
if (in_nowarn_block || (statement_flags & SF_NOWARN_PREFIX))
break;
PLATFORM_WARNING(msg);
throw_msg(msg, "\033[33m", "Warning"); // yellow
throw_msg(msg, "\033[33m", "Warning", opt_alt_loc); // yellow
++pass.warning_count;
// then check if warnings should be handled like errors:
if (config.all_warnings_are_errors) {
@ -557,11 +563,11 @@ void throw_message(enum debuglevel level, const char msg[])
}
break;
case DEBUGLEVEL_INFO:
throw_msg(msg, "\033[32m", "Info"); // green
throw_msg(msg, "\033[32m", "Info", opt_alt_loc); // green
break;
default:
// debug
throw_msg(msg, "\033[36m", "Debug"); // cyan
throw_msg(msg, "\033[36m", "Debug", opt_alt_loc); // cyan
break;
}
}
@ -572,25 +578,20 @@ void throw_message(enum debuglevel level, const char msg[])
// reach the maximum error limit inbetween.
void throw_redef_error(struct location *old_def, const char msg[])
{
struct location buffered_location;
const char *buffered_section_type;
char *buffered_section_title;
// CAUTION, ugly kluge: fiddle with input_now and section_now
// data so error message is actually helpful
// FIXME: maybe better pass "old location" as an optional arg to throw_message!
// buffer old data
input_get_location(&buffered_location);
// CAUTION, ugly kluge: fiddle with section_now data to generate
// "earlier definition" section.
// buffer old section
buffered_section_type = section_now->type;
buffered_section_title = section_now->title;
// set new (fake) data
input_now->location = *old_def;
// set new (fake) section
section_now->type = "earlier";
section_now->title = "definition";
// show warning with location of earlier definition
Throw_warning(msg); // FIXME - throw as info?
// restore old data
input_now->location = buffered_location;
throw_message(DEBUGLEVEL_WARNING, msg, old_def); // FIXME - throw as info?
// restore old section
section_now->type = buffered_section_type;
section_now->title = buffered_section_title;
// show error with location of current definition

View File

@ -201,15 +201,16 @@ extern void parse_source_code_file(FILE *fd, const char *eternal_plat_filename);
extern bits parser_get_force_bit(void);
// generate a debug/info/warning/error message
extern void throw_message(enum debuglevel level, const char msg[]);
// if the "optional alternative location" given is NULL, the current location is used
extern void throw_message(enum debuglevel level, const char msg[], struct location *opt_alt_loc);
// output a warning (something looks wrong, like "label name starts with shift-space character")
#define Throw_warning(msg) throw_message(DEBUGLEVEL_WARNING, msg)
#define Throw_warning(msg) throw_message(DEBUGLEVEL_WARNING, msg, NULL)
// output an error (something is wrong, no output file will be generated).
// the assembler will try to go on with the assembly, so the user gets to know
// about more than one of his typos at a time.
#define Throw_error(msg) throw_message(DEBUGLEVEL_ERROR, msg)
#define Throw_error(msg) throw_message(DEBUGLEVEL_ERROR, msg, NULL)
// throw "macro twice" error (FIXME - also use for "symbol twice"!)
// first output a warning, then an error, this guarantees that ACME does not
@ -222,7 +223,7 @@ extern void throw_redef_error(struct location *old_def, const char msg[]);
extern void throw_symbol_error(const char *msg);
// output a serious error (assembly stops, for example if outbuffer overruns).
#define Throw_serious_error(msg) throw_message(DEBUGLEVEL_SERIOUS, msg)
#define Throw_serious_error(msg) throw_message(DEBUGLEVEL_SERIOUS, msg, NULL)
// handle bugs
extern void BUG(const char *msg, int code);

View File

@ -47,7 +47,6 @@ extern const char FILE_READBINARY[];
// Variables
extern struct input *input_now; // current input structure
extern char GotByte; // last byte read (processed)
// name of source file used for resolving relative paths
// (i.e. not changed during macro execution):

View File

@ -99,7 +99,7 @@ static void border_crossed(int current_offset)
if (current_offset >= config.outbuf_size)
Throw_serious_error("Reached memory limit.");
if (pass.flags.do_segment_checks) {
throw_message(config.debuglevel_segmentprobs, "Segment reached another one, overwriting it.");
throw_message(config.debuglevel_segmentprobs, "Segment reached another one, overwriting it.", NULL);
find_segment_max(current_offset + 1); // find new (next) limit
}
}
@ -282,7 +282,7 @@ static void check_segment(intval_t new_pc)
while (test_segment->start <= new_pc) {
if ((test_segment->start + test_segment->length) > new_pc) {
// TODO - include overlap size in error message!
throw_message(config.debuglevel_segmentprobs, "Segment starts inside another one, overwriting it.");
throw_message(config.debuglevel_segmentprobs, "Segment starts inside another one, overwriting it.", NULL);
return;
}

View File

@ -1351,7 +1351,7 @@ static enum eos throw_src_string(enum debuglevel level, const char prefix[])
}
} while (input_accept_comma());
dynabuf_append(user_message, '\0');
throw_message(level, user_message->buffer);
throw_message(level, user_message->buffer, NULL);
return ENSURE_EOS;
}

View File

@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release
#define CHANGE_DATE "24 Jul" // update before release FIXME
#define CHANGE_DATE "25 Jul" // 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