From a4943e1f4090a4da7ffbb2e2e317fc7e56c219d1 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Wed, 6 May 2020 12:27:32 +0000 Subject: [PATCH] more cleanup git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@139 4df02467-bbd4-4a76-a152-e7ce94205b78 --- src/flow.c | 4 ++-- src/flow.h | 2 +- src/input.c | 4 ++-- src/input.h | 4 ++-- src/pseudoopcodes.c | 1 + src/section.c | 4 ++-- src/section.h | 6 +++--- src/tree.h | 2 +- src/typesystem.c | 17 +++++++++++------ src/typesystem.h | 4 ++-- 10 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/flow.c b/src/flow.c index 920896f..5a3123d 100644 --- a/src/flow.c +++ b/src/flow.c @@ -191,7 +191,7 @@ void flow_do_while(struct do_while *loop) // parse or skip a block. Returns whether block's '}' terminator was missing. // afterwards: GotByte = '}' -static int skip_or_parse_block(int parse) +static int skip_or_parse_block(boolean parse) { if (!parse) { Input_skip_or_store_block(FALSE); @@ -207,7 +207,7 @@ static int skip_or_parse_block(int parse) // parse {block} [else {block}] -void flow_parse_block_else_block(int parse_first) +void flow_parse_block_else_block(boolean parse_first) { // Parse first block. // If it's not correctly terminated, return immediately (because diff --git a/src/flow.h b/src/flow.h index fce3c20..e2ef904 100644 --- a/src/flow.h +++ b/src/flow.h @@ -58,7 +58,7 @@ extern void flow_do_while(struct do_while *loop); // parse a whole source code file extern void flow_parse_and_close_file(FILE *fd, const char *filename); // parse {block} [else {block}] -extern void flow_parse_block_else_block(int parse_first); +extern void flow_parse_block_else_block(boolean parse_first); // TODO - add an "else if" possibility diff --git a/src/input.c b/src/input.c index cbfb09f..944b2cc 100644 --- a/src/input.c +++ b/src/input.c @@ -340,7 +340,7 @@ void Input_ensure_EOS(void) // Now GotByte = first char to test // After calling this function, GotByte holds '}'. Unless EOF was found first, // but then a serious error would have been thrown. // FIXME - use a struct block *ptr argument! -char *Input_skip_or_store_block(int store) +char *Input_skip_or_store_block(boolean store) { char byte; int depth = 1; // to find matching block end @@ -622,7 +622,7 @@ void includepaths_add(const char *path) // open file for reading (trying list entries as prefixes) // "uses_lib" tells whether to access library or to make use of include paths // file name is expected in GlobalDynaBuf -FILE *includepaths_open_ro(int uses_lib) +FILE *includepaths_open_ro(boolean uses_lib) { FILE *stream; struct ipi *ipi; diff --git a/src/input.h b/src/input.h index 69bb690..9d9b7ac 100644 --- a/src/input.h +++ b/src/input.h @@ -75,7 +75,7 @@ extern void Input_ensure_EOS(void); // If "Store" is FALSE, NULL is returned. // After calling this function, GotByte holds '}'. Unless EOF was found first, // but then a serious error would have been thrown. -extern char *Input_skip_or_store_block(int store); +extern char *Input_skip_or_store_block(boolean store); // Read bytes and add to GlobalDynaBuf until the given terminator (or CHAR_EOS) // is found. Act upon single and double quotes by entering (and leaving) quote // mode as needed (So the terminator does not terminate when inside quotes). @@ -125,7 +125,7 @@ extern void includepaths_add(const char *path); // open file for reading (trying list entries as prefixes) // "uses_lib" tells whether to access library or to make use of include paths // file name is expected in GlobalDynaBuf -extern FILE *includepaths_open_ro(int uses_lib); +extern FILE *includepaths_open_ro(boolean uses_lib); #endif diff --git a/src/pseudoopcodes.c b/src/pseudoopcodes.c index 00fe88a..c2370ea 100644 --- a/src/pseudoopcodes.c +++ b/src/pseudoopcodes.c @@ -74,6 +74,7 @@ void notreallypo_setpc(void) } } vcpu_set_pc(intresult.val.intval, segment_flags); + // TODO - allow block syntax, so it is possible to put data "somewhere else" and then return to old position } diff --git a/src/section.c b/src/section.c index 3ce3037..77e9f72 100644 --- a/src/section.c +++ b/src/section.c @@ -1,5 +1,5 @@ // ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code. -// Copyright (C) 1998-2017 Marco Baye +// Copyright (C) 1998-2020 Marco Baye // Have a look at "acme.c" for further info // // section stuff (move to symbol.h?) @@ -32,7 +32,7 @@ static scope_t cheap_scope_max; // highest scope number yet // write given info into given structure and activate it -void section_new(struct section *section, const char *type, char *title, int allocated) +void section_new(struct section *section, const char *type, char *title, boolean allocated) { // new scope for locals local_scope_max += SCOPE_INCREMENT; diff --git a/src/section.h b/src/section.h index c3791ee..e3d2f5b 100644 --- a/src/section.h +++ b/src/section.h @@ -1,5 +1,5 @@ // ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code. -// Copyright (C) 1998-2017 Marco Baye +// Copyright (C) 1998-2020 Marco Baye // Have a look at "acme.c" for further info // // section stuff @@ -16,7 +16,7 @@ struct section { scope_t cheap_scope; // section's scope for cheap locals const char *type; // "Zone", "Subzone" or "Macro" char *title; // zone title, subzone title or macro title - int allocated; // whether title was malloc()'d + boolean allocated; // whether title was malloc()'d }; @@ -25,7 +25,7 @@ extern struct section *section_now; // write given info into given structure and activate it -extern void section_new(struct section *section, const char *type, char *title, int allocated); +extern void section_new(struct section *section, const char *type, char *title, boolean allocated); // change scope of cheap locals in given section extern void section_new_cheap_scope(struct section *section); // setup outermost section diff --git a/src/tree.h b/src/tree.h index 1322406..1be3d60 100644 --- a/src/tree.h +++ b/src/tree.h @@ -7,8 +7,8 @@ #define tree_H -#include "config.h" #include // for FILE +#include "config.h" // macros for pre-defining tree node tables diff --git a/src/typesystem.c b/src/typesystem.c index 70eaa60..e0c4b6e 100644 --- a/src/typesystem.c +++ b/src/typesystem.c @@ -9,30 +9,34 @@ #include "global.h" -static int in_address_block = FALSE; -static int in_address_statement = FALSE; +static boolean in_address_block = FALSE; +static boolean in_address_statement = FALSE; // Functions -int typesystem_says_address(void) +// return whether explicit symbol definitions should force "address" mode +boolean typesystem_says_address(void) { - return in_address_block | in_address_statement; + return in_address_block || in_address_statement; } +// parse a block while forcing address mode void typesystem_force_address_block(void) { - int buffer = in_address_block; + boolean buffer = in_address_block; in_address_block = TRUE; Parse_optional_block(); in_address_block = buffer; } -void typesystem_force_address_statement(int value) +// force address mode on or off for the next statement +void typesystem_force_address_statement(boolean value) { in_address_statement = value; } +// warn if result is not integer void typesystem_want_imm(struct number *result) { if (!config.warn_on_type_mismatch) @@ -46,6 +50,7 @@ void typesystem_want_imm(struct number *result) //printf("refcount should be 0, but is %d\n", result->addr_refs); } } +// warn if result is not address void typesystem_want_addr(struct number *result) { if (!config.warn_on_type_mismatch) diff --git a/src/typesystem.h b/src/typesystem.h index 204bb31..72b53ee 100644 --- a/src/typesystem.h +++ b/src/typesystem.h @@ -11,11 +11,11 @@ // return whether explicit symbol definitions should force "address" mode -extern int typesystem_says_address(void); +extern boolean typesystem_says_address(void); // parse a block while forcing address mode extern void typesystem_force_address_block(void); // force address mode on or off for the next statement -extern void typesystem_force_address_statement(int value); +extern void typesystem_force_address_statement(boolean value); // warn if result is not integer extern void typesystem_want_imm(struct number *result); // warn if result is not address