internal cleanup (zone -> scope), no change in functionality

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@73 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2016-08-05 09:59:07 +00:00
parent d53d0992aa
commit a63007c0f9
18 changed files with 139 additions and 138 deletions

View File

@ -33,7 +33,7 @@ flow.o: config.h acme.h alu.h dynabuf.h global.h input.h mnemo.h symbol.h tree.h
global.o: config.h platform.h acme.h cpu.h input.h macro.h pseudoopcodes.h section.h symbol.h global.h global.c
input.o: config.h alu.h dynabuf.h global.h section.h tree.h input.h input.c
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
@ -45,7 +45,7 @@ platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h input.h macro.h output.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h section.h tree.h section.h section.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c
symbol.o: config.h acme.h alu.h cpu.h dynabuf.h global.h input.h section.h tree.h symbol.h symbol.c

View File

@ -34,7 +34,7 @@ flow.o: config.h acme.h alu.h dynabuf.h global.h input.h mnemo.h symbol.h tree.h
global.o: config.h platform.h acme.h cpu.h input.h macro.h pseudoopcodes.h section.h symbol.h global.h global.c
input.o: config.h alu.h dynabuf.h global.h section.h tree.h input.h input.c
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
@ -46,7 +46,7 @@ platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h input.h macro.h output.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h section.h tree.h section.h section.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c
symbol.o: config.h acme.h alu.h cpu.h dynabuf.h global.h input.h section.h tree.h symbol.h symbol.c

View File

@ -37,7 +37,7 @@ flow.o: config.h acme.h alu.h dynabuf.h global.h input.h mnemo.h symbol.h tree.h
global.o: config.h platform.h acme.h cpu.h input.h macro.h pseudoopcodes.h section.h symbol.h global.h global.c
input.o: config.h alu.h dynabuf.h global.h section.h tree.h input.h input.c
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
@ -49,7 +49,7 @@ platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h input.h macro.h output.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h section.h tree.h section.h section.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c
symbol.o: config.h acme.h alu.h cpu.h dynabuf.h global.h input.h section.h tree.h symbol.h symbol.c

View File

@ -32,7 +32,7 @@ flow.o: config.h acme.h alu.h dynabuf.h global.h input.h mnemo.h symbol.h tree.h
global.o: config.h platform.h acme.h cpu.h input.h macro.h pseudoopcodes.h section.h symbol.h global.h global.c
input.o: config.h alu.h dynabuf.h global.h section.h tree.h input.h input.c
input.o: config.h alu.h dynabuf.h global.h section.h symbol.h tree.h input.h input.c
macro.o: config.h acme.h alu.h dynabuf.h global.h input.h section.h symbol.h tree.h macro.h macro.c
@ -44,7 +44,7 @@ platform.o: config.h platform.h platform.c
pseudoopcodes.o: acme.h alu.h input.h macro.h output.h pseudoopcodes.h pseudoopcodes.c
section.o: config.h dynabuf.h global.h section.h tree.h section.h section.c
section.o: config.h dynabuf.h global.h symbol.h tree.h section.h section.c
symbol.o: config.h acme.h alu.h cpu.h dynabuf.h global.h input.h section.h tree.h symbol.h symbol.c

View File

@ -240,7 +240,7 @@ static int perform_pass(void)
if (start_address != ILLEGAL_START_ADDRESS)
vcpu_set_pc(start_address, 0);
encoding_passinit(); // set default encoding
Section_passinit(); // set initial zone (untitled)
section_passinit(); // set initial zone (untitled)
// init variables
pass_undefined_count = 0; // no "NeedValue" errors yet
pass_real_errors = 0; // no real errors yet

View File

@ -339,17 +339,17 @@ static void check_for_def(int flags, int prefix, char *name, size_t length)
}
// Lookup (and create, if necessary) symbol tree item and return its value.
// DynaBuf holds the symbol's name and "zone" its zone.
// DynaBuf holds the symbol's name and "scope" its scope.
// The name length must be given explicitly because of anonymous forward labels;
// their internal name is different (longer) than their displayed name.
// This function is not allowed to change DynaBuf because that's where the
// symbol name is stored!
static void get_symbol_value(zone_t zone, int prefix, size_t name_length)
static void get_symbol_value(scope_t scope, int prefix, size_t name_length)
{
struct symbol *symbol;
// if the symbol gets created now, mark it as unsure
symbol = symbol_find(zone, MVALUE_UNSURE);
symbol = symbol_find(scope, MVALUE_UNSURE);
// if needed, remember name for "undefined" error output
check_for_def(symbol->result.flags, prefix, GLOBALDYNABUF_CURRENT, name_length);
// in first pass, count usage
@ -617,7 +617,7 @@ static void expect_operand_or_monadic_operator(void)
while (GetByte() == '+');
ugly_length_kluge = GlobalDynaBuf->size; // FIXME - get rid of this!
symbol_fix_forward_anon_name(FALSE); // FALSE: do not increment counter
get_symbol_value(Section_now->zone, 0, ugly_length_kluge);
get_symbol_value(section_now->scope, 0, ugly_length_kluge);
goto now_expect_dyadic;
case '-': // NEGATION operator or anonymous backward label
@ -631,7 +631,7 @@ static void expect_operand_or_monadic_operator(void)
SKIPSPACE();
if (BYTEFLAGS(GotByte) & FOLLOWS_ANON) {
DynaBuf_append(GlobalDynaBuf, '\0');
get_symbol_value(Section_now->zone, 0, GlobalDynaBuf->size - 1); // -1 to not count terminator
get_symbol_value(section_now->scope, 0, GlobalDynaBuf->size - 1); // -1 to not count terminator
goto now_expect_dyadic;
}
@ -704,7 +704,7 @@ static void expect_operand_or_monadic_operator(void)
if (Input_read_keyword()) {
// Now GotByte = illegal char
get_symbol_value(Section_now->zone, 1, GlobalDynaBuf->size - 1); // -1 to not count terminator
get_symbol_value(section_now->scope, 1, GlobalDynaBuf->size - 1); // -1 to not count terminator
goto now_expect_dyadic;
}
@ -743,7 +743,7 @@ static void expect_operand_or_monadic_operator(void)
// however, apart from that check above, function calls have nothing to do with
// parentheses: "sin(x+y)" gets parsed just like "not(x+y)".
} else {
get_symbol_value(ZONE_GLOBAL, 0, GlobalDynaBuf->size - 1); // -1 to not count terminator
get_symbol_value(SCOPE_GLOBAL, 0, GlobalDynaBuf->size - 1); // -1 to not count terminator
goto now_expect_dyadic;
}
}

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// Configuration
@ -8,7 +8,7 @@
// types
typedef unsigned int zone_t;
typedef unsigned int scope_t;
typedef signed long intval_t; // at least 32 bits
typedef unsigned long uintval_t; // just for logical shift right
// result structure type definition with support for floating point

View File

@ -177,7 +177,7 @@ static void parse_mnemo_or_global_symbol_def(int *statement_flags)
if ((*GLOBALDYNABUF_CURRENT == (char) 0xa0)
|| ((GlobalDynaBuf->size >= 2) && (GLOBALDYNABUF_CURRENT[0] == (char) 0xc2) && (GLOBALDYNABUF_CURRENT[1] == (char) 0xa0)))
Throw_first_pass_warning("Label name starts with a shift-space character.");
symbol_parse_definition(ZONE_GLOBAL, *statement_flags);
symbol_parse_definition(SCOPE_GLOBAL, *statement_flags);
}
}
@ -189,7 +189,7 @@ static void parse_local_symbol_def(int *statement_flags)
return;
GetByte(); // start after '.'
if (Input_read_keyword())
symbol_parse_definition(Section_now->zone, *statement_flags);
symbol_parse_definition(section_now->scope, *statement_flags);
}
@ -203,7 +203,7 @@ static void parse_backward_anon_def(int *statement_flags)
DYNABUF_APPEND(GlobalDynaBuf, '-');
while (GetByte() == '-');
DynaBuf_append(GlobalDynaBuf, '\0');
symbol_set_label(Section_now->zone, *statement_flags, 0, TRUE); // this "TRUE" is the whole secret
symbol_set_label(section_now->scope, *statement_flags, 0, TRUE); // this "TRUE" is the whole secret
}
@ -220,8 +220,8 @@ static void parse_forward_anon_def(int *statement_flags)
}
symbol_fix_forward_anon_name(TRUE); // TRUE: increment counter
DynaBuf_append(GlobalDynaBuf, '\0');
//printf("[%d, %s]\n", Section_now->zone, GlobalDynaBuf->buffer);
symbol_set_label(Section_now->zone, *statement_flags, 0, FALSE);
//printf("[%d, %s]\n", section_now->scope, GlobalDynaBuf->buffer);
symbol_set_label(section_now->scope, *statement_flags, 0, FALSE);
}
@ -318,11 +318,11 @@ static void throw_message(const char *message, const char *type)
if (format_msvc)
fprintf(msg_stream, "%s(%d) : %s (%s %s): %s\n",
Input_now->original_filename, Input_now->line_number,
type, Section_now->type, Section_now->title, message);
type, section_now->type, section_now->title, message);
else
fprintf(msg_stream, "%s - File %s, line %d (%s %s): %s\n",
type, Input_now->original_filename, Input_now->line_number,
Section_now->type, Section_now->title, message);
section_now->type, section_now->title, message);
}

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// Input stuff
@ -11,6 +11,7 @@
#include "global.h" // FIXME - remove when no longer needed
#include "platform.h"
#include "section.h"
#include "symbol.h"
#include "tree.h"
@ -421,17 +422,20 @@ int Input_append_keyword_to_global_dynabuf(void)
}
// Check whether GotByte is LOCAL_PREFIX (default '.').
// If not, store global zone value.
// If yes, store current zone value and read next byte.
// If not, store global scope value.
// If yes, store current local scope value and read next byte.
// Then jump to Input_read_keyword(), which returns length of keyword.
int Input_read_zone_and_keyword(zone_t *zone)
int Input_read_scope_and_keyword(scope_t *scope)
{
SKIPSPACE();
if (GotByte == LOCAL_PREFIX) {
GetByte();
*zone = Section_now->zone;
*scope = section_now->scope;
/* TODO } else if (GotByte == CHEAP_PREFIX) {
GetByte();
*scope = symbol_cheap_scope; */
} else {
*zone = ZONE_GLOBAL;
*scope = SCOPE_GLOBAL;
}
return Input_read_keyword();
}

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// Input stuff
@ -8,7 +8,7 @@
#include <stdio.h> // for FILE
#include "config.h" // for zone_t
#include "config.h" // for scope_t
// type definitions
@ -84,10 +84,10 @@ extern void Input_until_terminator(char terminator);
// Throws "missing string" error if none. Returns number of characters added.
extern int Input_append_keyword_to_global_dynabuf(void);
// Check whether GotByte is a dot.
// If not, store global zone value.
// If yes, store current zone value and read next byte.
// If not, store global scope value.
// If yes, store current scope value and read next byte.
// Then jump to Input_read_keyword(), which returns length of keyword.
extern int Input_read_zone_and_keyword(zone_t *);
extern int Input_read_scope_and_keyword(scope_t *scope);
// Clear dynamic buffer, then append to it until an illegal (for a keyword)
// character is read. Zero-terminate the string. Return its length (without
// terminator).

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// Macro stuff
@ -75,27 +75,27 @@ void Macro_init(void)
enlarge_arg_table();
}
// Read macro zone and title. Title is read to GlobalDynaBuf and then copied
// Read macro scope and title. Title is read to GlobalDynaBuf and then copied
// over to internal_name DynaBuf, where ARG_SEPARATOR is added.
// In user_macro_name DynaBuf, the original name is reconstructed (even with
// LOCAL_PREFIX) so a copy can be linked to the resulting macro struct.
static zone_t get_zone_and_title(void)
static scope_t get_scope_and_title(void)
{
zone_t macro_zone;
scope_t macro_scope;
Input_read_zone_and_keyword(&macro_zone); // skips spaces before
Input_read_scope_and_keyword(&macro_scope); // skips spaces before
// now GotByte = illegal character after title
// copy macro title to private dynabuf and add separator character
DYNABUF_CLEAR(user_macro_name);
DYNABUF_CLEAR(internal_name);
if (macro_zone != ZONE_GLOBAL)
if (macro_scope != SCOPE_GLOBAL)
DynaBuf_append(user_macro_name, LOCAL_PREFIX);
DynaBuf_add_string(user_macro_name, GLOBALDYNABUF_CURRENT);
DynaBuf_add_string(internal_name, GLOBALDYNABUF_CURRENT);
DynaBuf_append(user_macro_name, '\0');
DynaBuf_append(internal_name, ARG_SEPARATOR);
SKIPSPACE(); // done here once so it's not necessary at two callers
return macro_zone;
return macro_scope;
}
// Check for comma. If there, append to GlobalDynaBuf.
@ -125,14 +125,14 @@ static char *get_string_copy(const char *original)
// Terminate macro name and copy from internal_name to GlobalDynaBuf
// (because that's where Tree_hard_scan() looks for the search string).
// Then try to find macro and return whether it was created.
static int search_for_macro(struct rwnode **result, zone_t zone, int create)
static int search_for_macro(struct rwnode **result, scope_t scope, int create)
{
DynaBuf_append(internal_name, '\0'); // terminate macro name
// now internal_name = macro_title SPC argument_specifiers NUL
DYNABUF_CLEAR(GlobalDynaBuf);
DynaBuf_add_string(GlobalDynaBuf, internal_name->buffer);
DynaBuf_append(GlobalDynaBuf, '\0');
return Tree_hard_scan(result, macro_forest, zone, create);
return Tree_hard_scan(result, macro_forest, scope, create);
}
// This function is called when an already existing macro is re-defined.
@ -145,12 +145,12 @@ static void report_redefinition(struct rwnode *macro_node)
// show warning with location of current definition
Throw_warning(exception_macro_twice);
// CAUTION, ugly kluge: fiddle with Input_now and Section_now
// CAUTION, ugly kluge: fiddle with Input_now and section_now
// data to generate helpful error messages
Input_now->original_filename = original_macro->def_filename;
Input_now->line_number = original_macro->def_line_number;
Section_now->type = "original";
Section_now->title = "definition";
section_now->type = "original";
section_now->title = "definition";
// show serious error with location of original definition
Throw_serious_error(exception_macro_twice);
}
@ -163,7 +163,7 @@ void Macro_parse_definition(void) // Now GotByte = illegal char after "!macro"
char *formal_parameters;
struct rwnode *macro_node;
struct macro *new_macro;
zone_t macro_zone = get_zone_and_title();
scope_t macro_scope = get_scope_and_title();
// now GotByte = first non-space after title
DYNABUF_CLEAR(GlobalDynaBuf); // prepare to hold formal parameters
@ -208,7 +208,7 @@ void Macro_parse_definition(void) // Now GotByte = illegal char after "!macro"
// error messages, we're checking for "macro twice" *now*.
// Search for macro. Create if not found.
// But if found, complain (macro twice).
if (search_for_macro(&macro_node, macro_zone, TRUE) == FALSE)
if (search_for_macro(&macro_node, macro_scope, TRUE) == FALSE)
report_redefinition(macro_node); // quits with serious error
// Create new macro struct and set it up. Finally we'll read the body.
new_macro = safe_malloc(sizeof(*new_macro));
@ -233,15 +233,15 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
struct macro *actual_macro;
struct rwnode *macro_node,
*symbol_node;
zone_t macro_zone,
symbol_zone;
scope_t macro_scope,
symbol_scope;
int arg_count = 0;
// Enter deeper nesting level
// Quit program if recursion too deep.
if (--macro_recursions_left < 0)
Throw_serious_error("Too deeply nested. Recursive macro calls?");
macro_zone = get_zone_and_title();
macro_scope = get_scope_and_title();
// now GotByte = first non-space after title
// internal_name = MacroTitle ARG_SEPARATOR (grows to signature)
// Accept n>=0 comma-separated arguments before CHAR_EOS.
@ -261,9 +261,9 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
// read call-by-reference arg
DynaBuf_append(internal_name, ARGTYPE_NUM_REF);
GetByte(); // skip '~' character
Input_read_zone_and_keyword(&symbol_zone);
Input_read_scope_and_keyword(&symbol_scope);
// GotByte = illegal char
arg_table[arg_count].symbol = symbol_find(symbol_zone, 0);
arg_table[arg_count].symbol = symbol_find(symbol_scope, 0);
} else {
// read call-by-value arg
DynaBuf_append(internal_name, ARGTYPE_NUM_VAL);
@ -276,7 +276,7 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
// now GlobalDynaBuf = unused
// check for "unknown macro"
// Search for macro. Do not create if not found.
search_for_macro(&macro_node, macro_zone, FALSE);
search_for_macro(&macro_node, macro_scope, FALSE);
if (macro_node == NULL) {
Throw_error("Macro not defined (or wrong signature).");
Input_skip_remainder();
@ -295,10 +295,10 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
// activate new input
Input_now = &new_input;
// remember old section
outer_section = Section_now;
// start new section (with new zone)
outer_section = section_now;
// start new section (with new scope)
// FALSE = title mustn't be freed
Section_new_zone(&new_section, "Macro", actual_macro->original_name, FALSE);
section_new(&new_section, "Macro", actual_macro->original_name, FALSE);
GetByte(); // fetch first byte of parameter list
// assign arguments
if (GotByte != CHAR_EOS) { // any at all?
@ -310,15 +310,15 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
if (GotByte == REFERENCE_CHAR) {
// assign call-by-reference arg
GetByte(); // skip '~' character
Input_read_zone_and_keyword(&symbol_zone);
if ((Tree_hard_scan(&symbol_node, symbols_forest, symbol_zone, TRUE) == FALSE)
Input_read_scope_and_keyword(&symbol_scope);
if ((Tree_hard_scan(&symbol_node, symbols_forest, symbol_scope, TRUE) == FALSE)
&& (pass_count == 0))
Throw_error("Macro parameter twice.");
symbol_node->body = arg_table[arg_count].symbol;
} else {
// assign call-by-value arg
Input_read_zone_and_keyword(&symbol_zone);
symbol = symbol_find(symbol_zone, 0);
Input_read_scope_and_keyword(&symbol_scope);
symbol = symbol_find(symbol_scope, 0);
// 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.").
@ -335,9 +335,9 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name
if (GotByte != CHAR_EOB)
Bug_found("IllegalBlockTerminator", GotByte);
// end section (free title memory, if needed)
Section_finalize(&new_section);
section_finalize(&new_section);
// restore previous section
Section_now = outer_section;
section_now = outer_section;
// restore previous input:
Input_now = outer_input;
// restore old Gotbyte context

View File

@ -544,14 +544,14 @@ static enum eos po_set(void) // now GotByte = illegal char
struct result result;
int force_bit;
struct symbol *symbol;
zone_t zone;
scope_t scope;
if (Input_read_zone_and_keyword(&zone) == 0) // skips spaces before
if (Input_read_scope_and_keyword(&scope) == 0) // skips spaces before
// now GotByte = illegal char
return SKIP_REMAINDER;
force_bit = Input_get_force_bit(); // skips spaces after
symbol = symbol_find(zone, force_bit);
symbol = symbol_find(scope, force_bit);
if (GotByte != '=') {
Throw_error(exception_syntax);
return SKIP_REMAINDER;
@ -616,7 +616,7 @@ static enum eos po_zone(void)
int allocated;
// remember everything about current structure
entry_values = *Section_now;
entry_values = *section_now;
// set default values in case there is no valid title
new_title = s_untitled;
allocated = FALSE;
@ -631,15 +631,15 @@ static enum eos po_zone(void)
}
// setup new section
// section type is "subzone", just in case a block follows
Section_new_zone(Section_now, "Subzone", new_title, allocated);
section_new(section_now, "Subzone", new_title, allocated);
if (Parse_optional_block()) {
// Block has been parsed, so it was a SUBzone.
Section_finalize(Section_now); // end inner zone
*Section_now = entry_values; // restore entry values
section_finalize(section_now); // end inner zone
*section_now = entry_values; // restore entry values
} else {
// no block found, so it's a normal zone change
Section_finalize(&entry_values); // end outer zone
Section_now->type = s_Zone; // change type to "Zone"
section_finalize(&entry_values); // end outer zone
section_now->type = s_Zone; // change type to "Zone"
}
return ENSURE_EOS;
}
@ -713,13 +713,13 @@ static enum eos ifdef_ifndef(int is_ifndef) // now GotByte = illegal char
{
struct rwnode *node;
struct symbol *symbol;
zone_t zone;
scope_t scope;
int defined = FALSE;
if (Input_read_zone_and_keyword(&zone) == 0) // skips spaces before
if (Input_read_scope_and_keyword(&scope) == 0) // skips spaces before
return SKIP_REMAINDER;
Tree_hard_scan(&node, symbols_forest, zone, FALSE);
Tree_hard_scan(&node, symbols_forest, scope, FALSE);
if (node) {
symbol = (struct symbol *) node->body;
// in first pass, count usage
@ -759,17 +759,17 @@ static enum eos po_ifndef(void) // now GotByte = illegal char
// new syntax: !for VAR, START, END { BLOCK } VAR counts from START to END
static enum eos po_for(void) // now GotByte = illegal char
{
zone_t zone;
scope_t scope;
int force_bit;
struct result intresult;
struct for_loop loop;
if (Input_read_zone_and_keyword(&zone) == 0) // skips spaces before
if (Input_read_scope_and_keyword(&scope) == 0) // skips spaces before
return SKIP_REMAINDER;
// now GotByte = illegal char
force_bit = Input_get_force_bit(); // skips spaces after
loop.symbol = symbol_find(zone, force_bit);
loop.symbol = symbol_find(scope, force_bit);
if (!Input_accept_comma()) {
Throw_error(exception_syntax);
return SKIP_REMAINDER;

View File

@ -1,54 +1,56 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// Section stuff
// section stuff (move to symbol.h?)
#include "section.h"
#include "config.h"
#include "dynabuf.h"
#include "global.h" // FIXME - remove when no longer needed
#include "input.h"
#include "symbol.h"
#include "tree.h"
// fake section structure (for error msgs before any real section is in use)
static struct section initial_section = {
0, // zone value
0, // scope value
"during", // "type" => normally "zone Title" or
"init", // "title" => "macro test", now "during init"
FALSE, // no, title was not malloc'd
};
// Variables
struct section *Section_now = &initial_section; // current section
// variables
struct section *section_now = &initial_section; // current section
static struct section outer_section; // outermost section struct
static zone_t zone_max; // Highest zone number yet
static scope_t scope_localcount; // highest scope number yet
// Write given info into given zone structure and activate it
void Section_new_zone(struct section *section, const char *type, char *title, int allocated)
// write given info into given structure and activate it
void section_new(struct section *section, const char *type, char *title, int allocated)
{
section->zone = ++zone_max;
section->scope = ++scope_localcount;
section->type = type;
section->title = title;
section->allocated = allocated;
// activate new section
Section_now = section;
//printf("[new zone %d: %s, %s]\n", section->zone, section->type, section->title);
section_now = section;
//printf("[new zone %d: %s, %s]\n", section->scope, section->type, section->title);
}
// Tidy up: If necessary, release section title.
// Warning - the state of the component "Allocd" may have
// changed in the meantime, so don't rely on a local variable.
void Section_finalize(struct section *section)
void section_finalize(struct section *section)
{
if (section->allocated)
free(section->title);
}
// Setup outermost section
void Section_passinit(void)
// setup outermost section
void section_passinit(void)
{
zone_max = ZONE_GLOBAL; // will be incremented by next line
Section_new_zone(&outer_section, s_Zone, s_untitled, FALSE);
scope_localcount = SCOPE_GLOBAL; // will be incremented by next line
section_new(&outer_section, s_Zone, s_untitled, FALSE);
}

View File

@ -1,8 +1,8 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2015 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// Section stuff
// section stuff
#ifndef section_H
#define section_H
@ -12,33 +12,23 @@
// "section" structure type definition
struct section {
zone_t zone; // current zone value
scope_t scope; // section's scope
const char *type; // "Zone", "Subzone" or "Macro"
char *title; // zone title, subzone title or macro title
int allocated; // whether title was malloc()'d
};
// Constants
// TODO: rename internal stuff from "zone" to "scope",
// then add cheap locals (so there's SCOPE_GLOBAL, scope_zone and scope_cheap)
#define ZONE_GLOBAL 0 // Number of "global zone"
// Variables
// current section structure
extern struct section *Section_now;
extern struct section *section_now;
// Prototypes
// Write given info into given zone structure and activate it
extern void Section_new_zone(struct section *section, const char *type, char *title, int allocated);
// Setup outermost section
extern void Section_passinit(void);
// Tidy up: If necessary, release section title.
extern void Section_finalize(struct section *section);
// write given info into given structure and activate it
extern void section_new(struct section *section, const char *type, char *title, int allocated);
// setup outermost section
extern void section_passinit(void);
// tidy up: if necessary, release section title.
extern void section_finalize(struct section *section);
#endif

View File

@ -100,14 +100,14 @@ static void dump_vice_unusednonaddress(struct rwnode *node, FILE *fd)
// search for symbol. create if nonexistant. if created, give it flags "flags".
// the symbol name must be held in GlobalDynaBuf.
struct symbol *symbol_find(zone_t zone, int flags)
struct symbol *symbol_find(scope_t scope, int flags)
{
struct rwnode *node;
struct symbol *symbol;
int node_created,
force_bits = flags & MVALUE_FORCEBITS;
node_created = Tree_hard_scan(&node, symbols_forest, zone, TRUE);
node_created = Tree_hard_scan(&node, symbols_forest, scope, TRUE);
// if node has just been created, create symbol as well
if (node_created) {
// create new symbol structure
@ -168,13 +168,13 @@ void symbol_set_value(struct symbol *symbol, struct result *new_value, int chang
// parse label definition (can be either global or local).
// name must be held in GlobalDynaBuf.
void symbol_set_label(zone_t zone, int stat_flags, int force_bit, int change_allowed)
void symbol_set_label(scope_t scope, int stat_flags, int force_bit, int change_allowed)
{
struct result pc,
result;
struct symbol *symbol;
symbol = symbol_find(zone, force_bit);
symbol = symbol_find(scope, force_bit);
// label definition
if ((stat_flags & SF_FOUND_BLANK) && warn_on_indented_labels)
Throw_first_pass_warning("Label name not in leftmost column.");
@ -188,7 +188,7 @@ void symbol_set_label(zone_t zone, int stat_flags, int force_bit, int change_all
// parse symbol definition (can be either global or local, may turn out to be a label).
// name must be held in GlobalDynaBuf.
void symbol_parse_definition(zone_t zone, int stat_flags)
void symbol_parse_definition(scope_t scope, int stat_flags)
{
struct result result;
struct symbol *symbol;
@ -197,7 +197,7 @@ void symbol_parse_definition(zone_t zone, int stat_flags)
if (GotByte == '=') {
// explicit symbol definition (symbol = <something>)
symbol = symbol_find(zone, force_bit);
symbol = symbol_find(scope, force_bit);
// symbol = parsed value
GetByte(); // skip '='
ALU_any_result(&result);
@ -207,7 +207,7 @@ void symbol_parse_definition(zone_t zone, int stat_flags)
symbol_set_value(symbol, &result, FALSE);
Input_ensure_EOS();
} else {
symbol_set_label(zone, stat_flags, force_bit, FALSE);
symbol_set_label(scope, stat_flags, force_bit, FALSE);
}
}
@ -221,7 +221,7 @@ void symbol_define(intval_t value)
result.flags = MVALUE_GIVEN;
result.val.intval = value;
symbol = symbol_find(ZONE_GLOBAL, 0);
symbol = symbol_find(SCOPE_GLOBAL, 0);
symbol_set_value(symbol, &result, TRUE);
}
@ -229,7 +229,7 @@ void symbol_define(intval_t value)
// dump global symbols to file
void symbols_list(FILE *fd)
{
Tree_dump_forest(symbols_forest, ZONE_GLOBAL, dump_one_symbol, fd);
Tree_dump_forest(symbols_forest, SCOPE_GLOBAL, dump_one_symbol, fd);
}
@ -238,13 +238,13 @@ void symbols_vicelabels(FILE *fd)
// FIXME - if type checking is enabled, maybe only output addresses?
// the order of dumped labels is important because VICE will prefer later defined labels
// dump unused labels
Tree_dump_forest(symbols_forest, ZONE_GLOBAL, dump_vice_unusednonaddress, fd);
Tree_dump_forest(symbols_forest, SCOPE_GLOBAL, dump_vice_unusednonaddress, fd);
fputc('\n', fd);
// dump other used labels
Tree_dump_forest(symbols_forest, ZONE_GLOBAL, dump_vice_usednonaddress, fd);
Tree_dump_forest(symbols_forest, SCOPE_GLOBAL, dump_vice_usednonaddress, fd);
fputc('\n', fd);
// dump address symbols
Tree_dump_forest(symbols_forest, ZONE_GLOBAL, dump_vice_address, fd);
Tree_dump_forest(symbols_forest, SCOPE_GLOBAL, dump_vice_address, fd);
}
@ -259,7 +259,7 @@ void symbol_fix_forward_anon_name(int increment)
// terminate name, find "counter" symbol and read value
DynaBuf_append(GlobalDynaBuf, '\0');
counter_symbol = symbol_find(Section_now->zone, 0);
counter_symbol = symbol_find(section_now->scope, 0);
// make sure it gets reset to zero in each new pass
if (counter_symbol->pass != pass_count) {
counter_symbol->pass = pass_count;

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// symbol stuff
@ -20,6 +20,11 @@ struct symbol {
};
// Constants
// TODO: add cheap locals (so there's SCOPE_GLOBAL, scope_zone and scope_cheap)
#define SCOPE_GLOBAL 0 // number of "global zone"
// variables
extern struct rwnode *symbols_forest[]; // trees (because of 8-bit hash)
@ -28,13 +33,13 @@ extern struct rwnode *symbols_forest[]; // trees (because of 8-bit hash)
extern void symbol_set_value(struct symbol *symbol, struct result *new_value, int change_allowed);
// parse label definition (can be either global or local).
// name must be held in GlobalDynaBuf.
extern void symbol_set_label(zone_t zone, int stat_flags, int force_bit, int change_allowed);
extern void symbol_set_label(scope_t scope, int stat_flags, int force_bit, int change_allowed);
// parse symbol definition (can be either global or local, may turn out to be a label).
// name must be held in GlobalDynaBuf.
extern void symbol_parse_definition(zone_t zone, int stat_flags);
extern void symbol_parse_definition(scope_t scope, int stat_flags);
// search for symbol. create if nonexistant. if created, assign flags.
// name must be held in GlobalDynaBuf.
extern struct symbol *symbol_find(zone_t, int flags);
extern struct symbol *symbol_find(scope_t, int flags);
// set global symbol to value, no questions asked (for "-D" switch)
// name must be held in GlobalDynaBuf.
extern void symbol_define(intval_t value);

View File

@ -1,5 +1,5 @@
// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Copyright (C) 1998-2016 Marco Baye
// Have a look at "acme.c" for further info
//
// tree stuff
@ -28,14 +28,14 @@ struct ronode {
void *body; // bytes, handles or handler function
};
// tree node structure type definition for "read/write" items, i.e. macros/labels
// tree node structure type definition for "read/write" items, i.e. macros/symbols
struct rwnode {
struct rwnode *greater_than; // pointer to sub-tree
struct rwnode *less_than_or_equal; // pointer to sub-tree
hash_t hash_value;
char *id_string; // name, zero-terminated
void *body; // macro/label body
unsigned int id_number; // zone number
void *body; // macro/symbol body
unsigned int id_number; // scope number
};

View File

@ -9,7 +9,7 @@
#define RELEASE "0.95.7" // update before release (FIXME)
#define CODENAME "Fenchurch" // update before release
#define CHANGE_DATE "19 Jul" // update before release
#define CHANGE_DATE "5 Aug" // update before release
#define CHANGE_YEAR "2016" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" // FIXME
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME