mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +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
43 lines
802 B
C
43 lines
802 B
C
|
|
/*
|
|
** Copyright (C) 1997 The University of Melbourne.
|
|
** This file may only be copied under the terms of the GNU Library General
|
|
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
**
|
|
** $Id: mb_util.h,v 1.1 2001-01-24 07:42:28 lpcam Exp $
|
|
*/
|
|
|
|
|
|
#ifndef MB_UTIL_H
|
|
#define MB_UTIL_H
|
|
|
|
typedef char *
|
|
MB_CString;
|
|
|
|
typedef const char *
|
|
MB_CString_Const;
|
|
|
|
#define MB_NULL_STR ((MB_CString)NULL)
|
|
|
|
/* Standard TRUE & FALSE macros, if not defined */
|
|
#ifndef TRUE
|
|
#define TRUE 1
|
|
#endif
|
|
#ifndef FALSE
|
|
#define FALSE 0
|
|
#endif
|
|
|
|
/* Prints an error (doesn't exit) */
|
|
void
|
|
MB_util_error(const char *fmt, ...);
|
|
|
|
/* Prints an error message and exits */
|
|
void
|
|
MB_fatal(const char* message);
|
|
|
|
/* compare two strings */
|
|
int MB_strcmp(MB_CString_Const a, MB_CString_Const b);
|
|
|
|
#endif /* MB_UTIL_H */
|
|
|