The heap simply grows with each added value, currently no garbage collection is
done. Lists are represented simply as linked lists, by first storing the pointer
to the next list element and then the current list element. Tuples are simply
-stored by staring the two values in succession.
+stored by storing the two values in succession.
When calling a functions its arguments are placed on the stack, after which
-a \tt{bsr} instruction calls the function. The functions can then load its
+a \tt{bsr} instruction calls the function. The function can then load its
arguments, if and when these are needed in an expression, by copying them
from below its stack frame.
are trivially pass-by-value, whilst lists and tuples can behave as both,
depending on the usage. E.g. assigning a new list/tuple to an argument will
behave as pass-by-value, whilst changing the argument through a field selector
-will behave as pass by reference.
+will behave as pass by reference, thus the pointer is passed by value.
-Listing~\ref{lst:stackFunCall} shows the layout of the stack executing the
+Listing~\ref{lst:stackFunCall} shows the layout of the stack when executing the
two functions. the layout shown is the layout of the stack just before
-the \tt{add} instruction to add x and y. Note that, in compliance with \SSM{}s
+the \tt{add} instruction to add x and y in plus. Note that, in compliance with
+\SSM{}s
calling model, the return address of a function is saved below the stack frame
-of that function. When plus has returned the two arguments are popped of the
+of that function. When plus has returned, the two arguments are popped of the
stack and the value in \tt{RR} (for functions which do not return \tt{Void})
is placed on the stack.
\subsection{Generation}
The code generation phase transforms a well typed \AST{} to either an error,
-or an \tt{SSMProgram}The latter is a list of labels and instructions. The
+or an \tt{SSMProgram}. The latter is a list of labels and instructions. The
generation happens within a
\CI{WriterT SSMProgram (StateT (Addressbook, [Label]) (Either GenError)) a}
environment. Which we have implemented as a \tt{RWST} with \tt{()} for the
introduced a separate type of expression called a \SI{FuncType}, this type
encodes a function with arity $0$.
-As all other data types a function type object occupies one item on the stack
+As all other data types, a function type object occupies one item on the stack
which contains a heap pointer. The heap pointer points to a position on the
heap that stores, in increasing addresses, the function identification number,
the number of arguments already given and finally the argument values.