File: interpret.h

package info (click to toggle)
mlton 20061107-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,828 kB
  • ctags: 61,118
  • sloc: ansic: 11,446; makefile: 1,339; sh: 1,160; lisp: 900; pascal: 256; asm: 97
file content (57 lines) | stat: -rw-r--r-- 1,503 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Copyright (C) 2004-2005 Henry Cejtin, Matthew Fluet, Suresh
 *    Jagannathan, and Stephen Weeks.
 *
 * MLton is released under a BSD-style license.
 * See the file MLton-LICENSE for details.
 */

#ifndef _INTERPRET_H_
#define _INTERPRET_H_

#include <stdio.h>
#include "types.h"
#include "assert.h"

#define regs(ty)                                \
        extern int ty##RegI;                    \
        extern ty ty##Reg[]

regs(Real32);
regs(Real64);
regs(Word8);
regs(Word16);
regs(Word32);
regs(Word64);

#undef regs

#define assertRegsEmpty()                       \
        do {                                    \
                assert (0 == Word8RegI);        \
                assert (0 == Word16RegI);       \
                assert (0 == Word32RegI);       \
                assert (0 == Word64RegI);       \
                assert (0 == Real32RegI);       \
                assert (0 == Real64RegI);       \
        } while (0)

struct NameOffsets {
        Word32 codeOffset;  // An offset into code.
        Word32 nameOffset;  // An offset into addressNames.
};

typedef struct Bytecode {
        char *addressNames;
        Pointer code;
        Word32 codeSize;
        struct NameOffsets *nameOffsets;
        Word32 nameOffsetsSize;
} *Bytecode;

#define PopReg(ty) (assert (ty##RegI > 0), ty##Reg [--ty##RegI])
#define PushReg(ty) ty##Reg [ty##RegI++]

void MLton_callC (int i);  // provided by client
void MLton_Bytecode_interpret (Bytecode b, Word32 codeOffset);

#endif