mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 21:35:49 +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
This directory holds the source code for the Mercury bytecode utilities. `mdis' is the Mercury bytecode disassembler. `mbi' is the Mercury bytecode interpreter. `libmbi' is the same thing, minus main(). All exported symbols defined in modules in this directory should be prefixed with `MB_', for "Mercury Bytecode", to avoid clashes with names defined in other packages.