module Subroutines: sig
.. end
Contains the functions to create the procedure/function table
Contains the functions to create the procedure/function table
val jointable : ('a, 'b) Hashtbl.t -> ('a, 'b) Hashtbl.t -> ('a, 'b) Hashtbl.t
Used to join two Hashtable into a single one
val convertList : Syntaxtree.param list -> Syntaxtree.dec list
Converts a param list into a dec list
Returns The converted list
plist
: The param list
val genParamTable : Syntaxtree.dec list -> Intermediate.dec_table -> Intermediate.dec_table
Generate the Hashtable with the declaration of the parameters
Returns The updated table of parameters
p
: The declaration list of the parameters
pdect
: The dec_table for the parameters
val genSubroutine : Syntaxtree.ide ->
Syntaxtree.dec list ->
Syntaxtree.dec list ->
Intermediate.dec_table ->
Intermediate.proc_table ->
Syntaxtree.cmd ->
Intermediate.intermediateCode ->
Intermediate.return -> Intermediate.proc_entry
Generates the Subroutine entry for the Hashtable, after creating an Hashtable containing all the declarations of
the local variables and the parameters; then is checked the semantic of the subroutine's body and finally the
intermediate code is generated and saved. To do this, a new FunUtils class is created and substituted to the
present one, in order to have new variables for offsets and labels, but not registers (which are common for all
functions/procedures/main )
Returns The built entry for the subroutine
id
: The ide of the procedure
pdeclist
: The dec list of the parameters
dlist
: The local variables dec list
dect
: The global variables declarations table
proct
: The subroutines table
c
: The body of the subroutine
ic
: The intermediateCode class instance
r
: The return type of the subroutine
val genSub : Syntaxtree.proc ->
Intermediate.dec_table ->
Intermediate.proc_table -> Intermediate.intermediateCode -> unit
Builds the Building entry for the Hashtable and then replace it with the Subroutine entry, which is build by the genSubruotine method.
This is done in order to avoid errors with recursive calls, because until the entry is created, the function call raises
a Not_found exception. In the Building entry there are only the informations to check semantic errors.
Returns The updated subroutines table
p
: The subroutine to create
dect
: The declaration table
proct
: The subroutines table
ic
: The intermediatecCode class instance
val genSubTable : Syntaxtree.proc list ->
Intermediate.dec_table ->
Intermediate.proc_table ->
Intermediate.intermediateCode -> Intermediate.proc_table
Generate the subroutines table from the proc list
Returns The updated subroutines table
procl
: The proc list
dect
: The declarations table
table
: The subroutines table
ic
: The intermediateCode class instance