% $Id: MV.oz,v 1.4 2009/09/10 02:21:56 leavens Exp leavens $ % Values and the meaning function for Value Expressions % AUTHOR: Gary T. Leavens % Representation of Values: % ::= record(>) % | closure(> ) % | num() % | bool() % | loc() % ::= % > ::= an Oz record containing locations for all fields. \insert 'Environment.oz' declare fun {MV Exp Env} %% ENSURES: Result is the meaning of Exp in Env case Exp of varIdExp(V ...) then loc({ApplyEnv Env V}) [] atomExp(A ...) then record(A) [] boolExp(B ...) then bool(B) [] numExp(N ...) then num(N) [] recordExp(atomExp(L) FieldList ...) andthen {All FieldList NamedColonField} then record({List.toRecord L {Map FieldList fun {$ colonFld(FN varIdExp(V))} FN#{ApplyEnv Env V} end}}) [] procExp(Formals Body ...) then closure({Map Formals fun {$ varIdPat(V)} V end} Body Env) else raise unknownValueExp(Exp) end end end fun {NamedColonField F} %% ENSURES: Result is true if F is a named field (like x:E) case F of colonFld(_ varIdExp(_)) then true else false end end