## lowhalf-ramregion.pkg
#
# This module implements the lowhalf annotations for describing
# memory aliasing and control dependence.
#
# -- Allen Leung
# Compiled by:
#
src/lib/compiler/back/low/lib/lowhalf.libpackage lowhalf_ramregion
: Lowhalf_Ramregion # Lowhalf_Ramregion is from
src/lib/compiler/back/low/aliasing/lowhalf-ramregion.api{
#
Mutability = READONLY
| IMMUTABLE | MUTABLE;
Ramregion
= ROOT
| RAMREGION (Int, Mutability, String, Ramregion)
| UNION List( Ramregion )
;
counter = REF 0;
memory = ROOT;
fun new (name, mut, parent)
=
{ id = *counter;
counter := id + 1;
RAMREGION (*counter, mut, name, parent);
};
union = UNION;
stack = new("stack", MUTABLE, memory);
heap = new("heap", MUTABLE, memory);
data = new("data", MUTABLE, memory);
readonly = new("readonly", READONLY, data);
fun to_string ROOT => "root";
to_string (RAMREGION(_, _, name, ROOT)) => name;
to_string (RAMREGION(_, _, name, parent)) => to_string parent + "." + name;
to_string (UNION rs)
=>
string::cat (
fold_backward
\\ (r,[]) => [to_string r];
(r, s) => to_string r ! "+" ! s;
end
[]
rs
);
end;
};