annotate lab2/keiko.mli @ 1:b5139af1a420 tip basis

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