Mercurial > hg > compilers
comparison lab2/keiko.mli @ 0:bfdcc3820b32
Basis
author | Mike Spivey <mike@cs.ox.ac.uk> |
---|---|
date | Thu, 05 Oct 2017 08:04:15 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bfdcc3820b32 |
---|---|
1 (* common/keiko.mli *) | |
2 (* Copyright (c) 2017 J. M. Spivey *) | |
3 | |
4 (* |codelab| -- type of code labels *) | |
5 type codelab = int | |
6 | |
7 (* |label| -- allocate a code label *) | |
8 val label : unit -> codelab | |
9 | |
10 (* |op| -- type of picoPascal operators *) | |
11 type op = Plus | Minus | Times | Div | Mod | Eq | |
12 | Uminus | Lt | Gt | Leq | Geq | Neq | And | Or | Not | |
13 | |
14 (* op_name -- map an operator to its name *) | |
15 val op_name : op -> string | |
16 | |
17 (* |code| -- type of intermediate instructions *) | |
18 type code = | |
19 CONST of int (* Push constant (value) *) | |
20 | GLOBAL of string (* Push global address (name) *) | |
21 | LOCAL of int (* Push local adddress (offset) *) | |
22 | LOADW (* Load word *) | |
23 | STOREW (* Store word *) | |
24 | LOADC (* Load character *) | |
25 | STOREC (* Store character *) | |
26 | MONOP of op (* Perform unary operation (op) *) | |
27 | BINOP of op (* Perform binary operation (op) *) | |
28 | OFFSET (* Add address and offset *) | |
29 | LABEL of codelab (* Set code label *) | |
30 | JUMP of codelab (* Unconditional branch (dest) *) | |
31 | JUMPC of op * codelab (* Conditional branch (op, dest) *) | |
32 | PCALL of int (* Call procedure *) | |
33 | PCALLW of int (* Proc call with result (nargs) *) | |
34 | RETURNW (* Return from procedure *) | |
35 | BOUND of int (* Bounds check *) | |
36 | CASEJUMP of int (* Case jump (num cases) *) | |
37 | CASEARM of int * codelab (* Case value and label *) | |
38 | PACK (* Pack two values into one *) | |
39 | UNPACK (* Unpack one value into two *) | |
40 | DUP | |
41 | POP | |
42 | |
43 | LDGW of string (* Load Global Word (name) *) | |
44 | STGW of string (* Store Global Word (name) *) | |
45 | LDLW of int (* Load Local Word (offset) *) | |
46 | STLW of int (* Store Local Word (offset) *) | |
47 | LDNW of int (* Load word with offset *) | |
48 | STNW of int (* Store word with offset *) | |
49 | |
50 | LINE of int | |
51 | SEQ of code list | |
52 | NOP | |
53 | |
54 (* |fInst| -- format an instruction for |printf| *) | |
55 val fInst : code -> Print.arg | |
56 | |
57 (* |canon| -- flatten a code sequence *) | |
58 val canon : code -> code | |
59 | |
60 (* |output| -- output a code sequence *) | |
61 val output : code -> unit |