evaluate if expressions

This commit is contained in:
darkf 2013-10-23 14:43:30 -07:00
parent 669b4a09a9
commit 767e3eedab
1 changed files with 6 additions and 0 deletions

View File

@ -119,6 +119,12 @@ eval (ListConst v) =
eval (TupleConst v) = mapM eval v >>= return . TupleV
eval (IfExpr c t e) = eval c >>= \cond ->
case cond of
BoolV True -> eval t
BoolV False -> eval e
_ -> error "if: condition must be a boolean"
eval (Var var) = get >>= \(_,env) ->
case lookup env var of
Just v -> return v