mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 09:53:36 +00:00
Estimated hours taken: 2 More cleanup of the bytecode stuff; in particular, add a `MB_' prefix to most names. bytecode/*: - Prefix all names defined in header files with `MB_' (except for `TRUE', `FALSE', `DEBUGGING', and `XXXdebug'). - Add macros `MB_new', `MB_new_array', and `MB_resize_array', and use those instead of using `MB_malloc' and `MB_resize' (formerly `mem_malloc' and `mem_resize') or malloc() and realloc() directly. Uncomment the definition of MB_strdup() now that it calls MB_malloc(). - Delete the definitions of `uchar', `uint', `ushort', `ulong' (just spell them out, its clearer and more portable that way). - Fix the indentation in a few places I missed on my previous pass. - Add a `README' file.
56 lines
1.5 KiB
C
56 lines
1.5 KiB
C
/*
|
|
** Copyright (C) 1997 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: machine.h,v 1.5 1997-04-26 05:56:54 fjh Exp $
|
|
*/
|
|
|
|
#ifndef MB_MACHINE_H
|
|
#define MB_MACHINE_H
|
|
|
|
#define MB_MAX_REGISTERS 40
|
|
|
|
#define MB_MAX_INT_STACK 10000
|
|
#define MB_MAX_INT_HEAP 10000
|
|
#define MB_MAX_CODE 10000
|
|
|
|
/*
|
|
** XXX: Currently we store full bloated bytecodes in the
|
|
** code area (text segment). This is extremely inefficient.
|
|
** We should alter design a stripped-down streamlined `machine
|
|
** code' that is a minimalist bytecode with all symbolic information
|
|
** stripped out and and placed in tables (`data segment'), and all
|
|
** labels replaced with offsets into the text segment
|
|
*/
|
|
|
|
/*
|
|
** An Address is an index into code, heap, or stack area.
|
|
** This should be identical to a pointer since we will need
|
|
** to use the same heap as the compiled Mercury when we interface
|
|
** with compiled code.
|
|
*/
|
|
typedef Word
|
|
MB_Address;
|
|
|
|
typedef struct MB_Machine_struct {
|
|
|
|
Word reg[MB_MAX_REGISTERS]; /* Machine registers */
|
|
|
|
Word maxfr; /* Top stack frame pointer */
|
|
Word curfr; /* Current stack frame pointer */
|
|
Word ip; /* Instruction pointer */
|
|
|
|
Word hp; /* Heap pointer */
|
|
Word sp; /* Stack pointer */
|
|
|
|
Word stack[MB_MAX_INT_STACK]; /* Interpreter stack */
|
|
Word heap[MB_MAX_INT_HEAP]; /* Interpreter heap */
|
|
|
|
MB_Bytecode
|
|
code[MB_MAX_CODE]; /* Data area for storing bytecodes */
|
|
} MB_Machine;
|
|
|
|
|
|
#endif /* MB_MACHINE_H */
|