mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 09:53:36 +00:00
Estimated hours taken: 40 The beginnings of the new bytecode interpreter. Probably just over half the code is the same or a superficially modified revision of the old one. bytecode/mb_bytecode.c bytecode/mb_bytecode.h Almost identical. Only real change is made MB_read_cstring not use any static variables bytecode/mb_disasm.c bytecode/mb_disasm.h Again, code very similar. Changed all the functions to write to a buffer instead of a file and to allow for bytecode indenting. Output format string for some instructions changed (hopefully more menaingful than just a dump of numbers) bytecode/mb_machine.c bytecode/mb_machine.h (completely different from old machine.c) The actual part that contains an abstract machine. The rest is really just support code. The instruction_table array is how instructions are dispatched. Look at instr_xxxx for the actual interpreter code. Not all instructions are implemented. MB_step and MB_run execute the actual interpreting code bytecode/mb_machine_show.h bytecode/mb_machine_show.c displays output showing the state of the machine bytecode/mb_mem.c bytecode/mb_mem.h Identical to old mem apart from file name changes bytecode/mb_util.c bytecode/mb_util.h took out strdup (not needed) and changed some comments bytecode/mb_stack.c bytecode/mb_stack.h word based stack that will reallocate itself if it needs to bytecode/mbi.c front end for bytecode interpreter bytecode/mdis.c disassembles a file and dumps it to the screen
125 lines
3.4 KiB
Plaintext
125 lines
3.4 KiB
Plaintext
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 1997-2000 The University of Melbourne.
|
|
# This file may only be copied under the terms of the GNU General
|
|
# Public License - see the file COPYING in the Mercury distribution.
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Mmake - Mmake file for the Mercury bytecode utilities
|
|
|
|
MAIN_TARGET=all
|
|
|
|
MERCURY_DIR=..
|
|
include $(MERCURY_DIR)/Mmake.common
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
INCPATH = -I$(RUNTIME_DIR) \
|
|
-I$(BOEHM_GC_DIR) \
|
|
-I$(BOEHM_GC_DIR)/include \
|
|
-I.
|
|
LIBPATH = -L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR) -L.
|
|
CFLAGS = -g $(EXTRA_CFLAGS) -D_POSIX_SOURCE $(INCPATH) -DDEBUGGING
|
|
MGNUC = MERCURY_ALL_C_INCL_DIRS="$(INCPATH)" $(SCRIPTS_DIR)/mgnuc
|
|
MGNUCFLAGS = $(CFLAGS)
|
|
|
|
MAKEDEPEND = makedepend
|
|
|
|
# We need VPATH so we can find getopt.h (!)
|
|
VPATH = $(MERCURY_DIR)/runtime
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
MB_HDRS = bytecode.h dict.h disasm.h mbi.h mem.h machine.h \
|
|
mdis.h static_data.h template.h util.h
|
|
|
|
HDRS = $(MB_HDRS) getopt.h
|
|
|
|
ORIG_CS = bytecode.c dict.c disasm.c machine.c mbi.c mbi_main.c \
|
|
mdis.c mem.c static_data.c template.c util.c
|
|
|
|
#LIBS = -lmer ` \
|
|
# case "$(GRADE)" in \
|
|
# *.par*.gc*.prof*) echo "-lpar_gc_prof" ;; \
|
|
# *.par*.gc*) echo "-lpar_gc" ;; \
|
|
# *.gc*.prof*) echo "-lgc_prof" ;; \
|
|
# *.gc*) echo "-lgc" ;; \
|
|
# esac \
|
|
# `
|
|
LIBS = libgc.a
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: all
|
|
|
|
all: mdb mdis mbi libmbi
|
|
|
|
MDIS_OBJS = bytecode.o disasm.o mdis.o mem.o util.o
|
|
mdis: $(MDIS_OBJS)
|
|
$(MGNUC) $(CFLAGS) -o mdis $(MDIS_OBJS) $(LIBPATH) $(LIBS)
|
|
|
|
LIBMBI_OBJS = bytecode.o dict.o mbi.o mem.o util.o
|
|
LIBMBI_PIC_OBJS = $(LIBMBI_OBJS:.o=.$(EXT_FOR_PIC_OBJECTS))
|
|
MBI_OBJS = mbi_main.o $(LIBMBI_OBJS)
|
|
|
|
mbi: $(MBI_OBJS)
|
|
$(MGNUC) $(CFLAGS) -o mbi $(MBI_OBJS) $(LIBPATH) $(LIBS)
|
|
|
|
libmbi: libmbi.a libmbi.$(EXT_FOR_SHARED_LIB)
|
|
|
|
libmbi.a: $(LIBMBI_OBJS)
|
|
rm -f libmbi.a
|
|
ar cr libmbi.a $(LIBMBI_OBJS)
|
|
|
|
libmbi.so: $(LIBMBI_OBJS)
|
|
$(LINK_SHARED_OBJ) -o libmbi.so $(LIBMBI_PIC_OBJS) \
|
|
$(LIBPATH) $(LIBS) $(SHARED_LIBS)
|
|
|
|
mdb: libmbi.so mdb.m
|
|
$(MC) -o mdb mdb.m -L. -lmbi
|
|
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
tags: $(ORIG_CS)
|
|
ctags $(ORIG_CS) $(MB_HDRS)
|
|
|
|
.PHONY: check_headers
|
|
check_headers:
|
|
for file in $(HDRS); do \
|
|
echo "$$file"; \
|
|
echo "#include \"$$file\"" > tmp.c; \
|
|
$(MGNUC) $(MGNUCFLAGS) -c tmp.c || exit 1; \
|
|
done
|
|
rm -f tmp.c
|
|
|
|
# Create dependencies.
|
|
depend: $(ORIG_CS) $(HDR)
|
|
if test ! -f depend.mk ; then touch depend.mk ; else true ; fi
|
|
$(MAKEDEPEND) $(INCPATH) -f depend.mk $^
|
|
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# installation rules
|
|
|
|
install:
|
|
echo "Module \"bytecode\" does not yet install anything."
|
|
|
|
uninstall:
|
|
echo "Nothing to uninstall for module \"bytecode\""
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
clean_local:
|
|
rm -f *.o *.pic_o
|
|
|
|
realclean_local:
|
|
-$(RM) mbi mdis depend.mk* libmbi.a libmbi.so \
|
|
mdb mdb.c mdb.d mdb_init.c
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
-include depend.mk
|
|
|
|
#-----------------------------------------------------------------------------#
|