diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2004-06-06 19:46:43 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2004-06-06 19:46:43 +0000 |
commit | ff2ed93ec8860b5eea6b524d611f97149c6e5859 (patch) | |
tree | 90d47cd3febf9789c38c213efd92cebdfb23e4ed | |
parent | 7126f125585b219c8ef5c395ded89215d05e6077 (diff) | |
download | mdk-ff2ed93ec8860b5eea6b524d611f97149c6e5859.tar.gz mdk-ff2ed93ec8860b5eea6b524d611f97149c6e5859.tar.bz2 |
keep track of program's end address.
-rw-r--r-- | mixlib/mix_scanner.l | 3 | ||||
-rw-r--r-- | mixlib/xmix_parser.h | 49 |
2 files changed, 27 insertions, 25 deletions
diff --git a/mixlib/mix_scanner.l b/mixlib/mix_scanner.l index 6e4cb71..2d097ca 100644 --- a/mixlib/mix_scanner.l +++ b/mixlib/mix_scanner.l @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mix_scanner.l : * Lexical scanner used by mix_parser_t * ------------------------------------------------------------------ - * Copyright (C) 2000, 2003 Free Software Foundation, Inc. + * Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -330,6 +330,7 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)* {number}{ws}*\n | {number}{ws}+.*\n { parser->start = mix_short_new (atol (yytext)); + parser->end = parser->loc_count; end = TRUE; if ( parser->status == MIX_PERR_NOCOMP ) parser->status = MIX_PERR_OK; return parser->status; diff --git a/mixlib/xmix_parser.h b/mixlib/xmix_parser.h index 1915a0d..d2b3edc 100644 --- a/mixlib/xmix_parser.h +++ b/mixlib/xmix_parser.h @@ -1,22 +1,22 @@ /* -*-c-*- ---------------- xmix_parser.h : * Declarations for the implementation of mix_parser_t * ------------------------------------------------------------------ - * Copyright (C) 2000 Free Software Foundation, Inc. - * + * Copyright (C) 2000, 2004 Free Software Foundation, Inc. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * */ @@ -29,10 +29,10 @@ #include "mix_parser.h" /* mix_parser_t definition */ -struct mix_parser_t +struct mix_parser_t { - mix_file_t *in_file; /* the source file to be compiled */ - mix_symbol_table_t *symbol_table; + mix_file_t *in_file; /* the source file to be compiled */ + mix_symbol_table_t *symbol_table; mix_symbol_table_t *ls_table; /* literal strings symbols */ guint cur_ls; /* current literal string symbol */ GHashTable *future_refs; /* a map from symbol name to list of addresses */ @@ -43,10 +43,11 @@ struct mix_parser_t guint err_count; /* no. of errors during compilation */ guint warn_count; /* no. of warnings during compilation */ mix_address_t start; /* start address of the compiled code */ + mix_address_t end; /* end address of the compiled code */ }; /* each node of the ins_table stores a mix_word_t with the instruction - and a source code line (for debugging and listing) + and a source code line (for debugging and listing) */ typedef struct ins_node_ { @@ -61,27 +62,27 @@ typedef struct ins_node_ #define get_ploc_(parser) ((parser)->loc_count) /* symbol table */ -/* Define a new symbol with given value - * and update previously set refs to this symbol +/* Define a new symbol with given value + * and update previously set refs to this symbol */ extern mix_parser_err_t mix_parser_define_symbol_value (mix_parser_t *parser, const gchar *name, mix_word_t value); -/* Define a new symbol with value equal to the current loc_count - * and update previously set refs to this symbol +/* Define a new symbol with value equal to the current loc_count + * and update previously set refs to this symbol */ -extern mix_parser_err_t -mix_parser_define_symbol_here(mix_parser_t *parser, const gchar *name); +extern mix_parser_err_t +mix_parser_define_symbol_here (mix_parser_t *parser, const gchar *name); /* Set a reference to future symbol here */ extern void -mix_parser_set_future_ref(mix_parser_t *parser, const gchar *name); +mix_parser_set_future_ref (mix_parser_t *parser, const gchar *name); /* Redefine the value of a local symbol as the current loc_count */ extern void -mix_parser_manage_local_symbol(mix_parser_t *parser, const gchar *name, - mix_short_t value); +mix_parser_manage_local_symbol (mix_parser_t *parser, const gchar *name, + mix_short_t value); /* Literal strings symbols */ extern void @@ -90,15 +91,15 @@ mix_parser_define_ls (mix_parser_t *parser, mix_word_t value); /* Compilation */ /* Add instruction with address the current loc_count */ extern void -mix_parser_add_ins(mix_parser_t *parser, const mix_ins_t *new_ins, - guint lineno); +mix_parser_add_ins (mix_parser_t *parser, const mix_ins_t *new_ins, + guint lineno); extern void -mix_parser_add_raw(mix_parser_t *parser, mix_word_t word, guint lineno); +mix_parser_add_raw (mix_parser_t *parser, mix_word_t word, guint lineno); /* Error handling */ -extern void -mix_parser_log_error(mix_parser_t *parser, mix_parser_err_t error, - gint lineno, const gchar *comment, gboolean warn); +extern void +mix_parser_log_error (mix_parser_t *parser, mix_parser_err_t error, + gint lineno, const gchar *comment, gboolean warn); |