module Intermediate: sig
.. end
This module contains all the informations about types, structures and classes that are used almost anywhere along the code; other specific objects are declared only where needed
type
label = int
Labels are numeric to simplify things
Register is an index for temporary variables
type
register = int
Offsets is how far the variable is from the stack pointer
type
offset = int
type
return =
The return type of subroutines
type
sType =
The Semantic type, used for semantic analisys
type
inst_type =
| |
CPY |
| |
AGET |
| |
ASET |
| |
ADD |
| |
SUB |
| |
MUL |
| |
DIV |
| |
AND |
| |
OR |
| |
NOT |
| |
CNE |
| |
CG |
| |
CGE |
| |
JNE |
| |
GOTO |
| |
PARAM |
| |
CALL |
| |
RET |
| |
NOP |
| |
HALT |
| |
OUT |
Instructions for intermediate code
type
value =
Type of values
type
element =
Element of intermediate code instruction
type
instruction = inst_type * element * element *
element
The instruction code, the first operand, the second operand, the destination element
class funUtils :
object
.. end
The class contains all the method and objects which differ from one subroutine and the other,
or the main program
class intermediateCode :
object
.. end
This class is a over-structure for the funUtils class, and has methods for the manage of global variables, like registers, which are indipendent from the function (main or subroutines) that is processed
type
dec_table = (Syntaxtree.ide, int * int * element) Hashtbl.t
A dec_table binds an ide (variable name) with 3 elements: 2 integers
(x and y coordinate) and the element associated with the variable
type
proc_entry =
A proc_entry can be in Building phase (which has the parameter
types of the call and the return type) or a Subroutines (which
contains all the informations for that function/procedure, such
as the local variables declaration and the funUtils class for that
subroutine)
type
proc_table = (Syntaxtree.ide, proc_entry) Hashtbl.t
The proc_table binds the name of a subroutine with its proc_entry