| 1 |
\section{Label Expressions} |
| 2 |
|
| 3 |
A \newdef{label expression} is a constant |
| 4 |
expression defined in terms of labels, or user |
| 5 |
defined \href{constants.html}{constants}. MLRISC uses the type |
| 6 |
\sml{labexp} to represent label expressions. Label expressions |
| 7 |
are defined in the structure |
| 8 |
\mlrischref{instructions/labelExp.sml}{LabelExp}. |
| 9 |
|
| 10 |
The datatype \sml{labexp} has the following definition: |
| 11 |
\begin{SML} |
| 12 |
datatype labexp = |
| 13 |
LABEL of Label.label |
| 14 |
| CONST of Constant.const |
| 15 |
| INT of int |
| 16 |
| PLUS of labexp * labexp |
| 17 |
| MINUS of labexp * labexp |
| 18 |
| MULT of labexp * labexp |
| 19 |
| DIV of labexp * labexp |
| 20 |
| LSHIFT of labexp * word |
| 21 |
| RSHIFT of labexp * word |
| 22 |
| AND of labexp * word |
| 23 |
| OR of labexp * word |
| 24 |
\end{SML} |
| 25 |
|
| 26 |
In addition, the following functions are defined in \sml{labexp}: |
| 27 |
\begin{itemize} |
| 28 |
\item \sml{valueOf : labexp -> int} -- Returns the value associated with |
| 29 |
a label expression |
| 30 |
\item \sml{toString : labexp -> string} -- Return the pretty printed representation of an expression |
| 31 |
\item \sml{hash : labexp -> word} -- Returns the hash value of an expression |
| 32 |
\item \sml{== : labexp * labexp -> bool} -- Tests whether two label expression are lexically identical |
| 33 |
\end{itemize} |
| 34 |
|
| 35 |
The type \sml{labexp} is depends on client defined |
| 36 |
\href{constants.html}{constants} typed. The functor \sml{LabelExp} |
| 37 |
is parameterized as follows. |
| 38 |
\begin{SML} |
| 39 |
functor \mlrischref{instructions/labelExp.sml}{LabelExp}(Constant : \mlrischref{instructions/constant.sig}{CONSTANT}) |
| 40 |
\end{SML} |