changeset 364:0b5a26bedbe1

Pass framework simplified; skeleton pass 3
author lost@starbug
date Tue, 06 Apr 2010 21:35:09 -0600
parents d96c30e60ddf
children 6a98cc90c14f
files lwasm/Makefile.am lwasm/main.c lwasm/pass3.c
diffstat 3 files changed, 67 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/Makefile.am	Tue Apr 06 21:03:19 2010 -0600
+++ b/lwasm/Makefile.am	Tue Apr 06 21:35:09 2010 -0600
@@ -1,7 +1,7 @@
 AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_builddir)/lwlib -I$(top_srcdir)/lwlib
 bin_PROGRAMS = lwasm
 lwasm_SOURCES = main.c pragma.c input.c pass1.c lwasm.c \
-	instab.c symbol.c macro.c pass2.c \
+	instab.c symbol.c macro.c pass2.c pass3.c \
 	insn_inh.c insn_rtor.c insn_tfm.c insn_rlist.c insn_rel.c \
 	insn_bitbit.c insn_indexed.c insn_gen.c insn_logicmem.c \
 	pseudo.c section.c os9.c
--- a/lwasm/main.c	Tue Apr 06 21:03:19 2010 -0600
+++ b/lwasm/main.c	Tue Apr 06 21:35:09 2010 -0600
@@ -166,11 +166,26 @@
 */
 extern void do_pass1(asmstate_t *as);
 extern void do_pass2(asmstate_t *as);
+extern void do_pass3(asmstate_t *as);
 extern lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv);
 extern lw_expr_t lwasm_evaluate_var(char *var, void *priv);
 extern lw_expr_t lwasm_parse_term(char **p, void *priv);
+
+struct passlist_s
+{
+	char *passname;
+	void (*fn)(asmstate_t *as);
+} passlist[] = {
+	{ "parse", do_pass1 },
+	{ "symcheck", do_pass2 },
+	{ "resolve1", do_pass3 },
+	{ NULL, NULL }
+};
+
 int main(int argc, char **argv)
 {
+	int passnum;
+
 	/* assembler state */
 	asmstate_t asmstate = { 0 };
 	program_name = argv[0];
@@ -193,13 +208,15 @@
 
 	input_init(&asmstate);
 
-	do_pass1(&asmstate);
-	if (asmstate.errorcount > 0)
+	for (passnum = 0; passlist[passnum].fn; passnum++)
 	{
-		lwasm_show_errors(&asmstate);
-		exit(1);
+		fprintf(stderr, "Doing pass %d (%s)\n", passnum, passlist[passnum].passname);
+		(passlist[passnum].fn)(&asmstate);
+		
+		if (asmstate.errorcount > 0)
+		{
+			lwasm_show_errors(&asmstate);
+			exit(1);
+		}
 	}
-	do_pass2(&asmstate);
-	
-	exit(0);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lwasm/pass3.c	Tue Apr 06 21:35:09 2010 -0600
@@ -0,0 +1,42 @@
+/*
+pass3.c
+
+Copyright © 2010 William Astle
+
+This file is part of LWTOOLS.
+
+LWTOOLS 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <lw_alloc.h>
+#include <lw_string.h>
+
+#include "lwasm.h"
+#include "instab.h"
+
+/*
+Resolve1 Pass
+
+repeatedly resolve instruction sizes and line addresses
+until nothing more reduces
+
+*/
+void do_pass3(asmstate_t *as)
+{
+}