Skip to content

Commit

Permalink
Do the same thing with bools
Browse files Browse the repository at this point in the history
  • Loading branch information
bensimner authored and MattWindsor91 committed Feb 2, 2017
1 parent b0150c3 commit dfeb2c0
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Modeller.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,18 @@ let modelBoolLValue
| RValue r -> fail (NeedLValue r)
| LValue l -> wrapMessages BadExpr (modelBoolExpr env idxEnv marker) l

// Models a boolean <LValue | Symbolic>
// in an analogous way to ``modelIntLValueOrSymbol``
let modelBoolLValueOrSymbol
(env : VarMap) (idxEnv : VarMap) (marker : Var -> 'Var) (ex : Expression)
: Result<TypedBoolExpr<Sym<'Var>>, PrimError> =
match ex with
| RValue r ->
match r.Node with
| Symbolic _ -> wrapMessages BadExpr (modelBoolExpr env idxEnv marker) r
| _ -> fail (NeedLValue r)
| LValue l -> wrapMessages BadExpr (modelBoolExpr env idxEnv marker) l

/// <summary>
/// Models an integer lvalue given a potentially valid expression and
/// environment.
Expand Down Expand Up @@ -1448,6 +1460,7 @@ let modelIntLoad
(Exact (typedIntToType dstE))
(Exact (typedIntToType srcE)))

// for symbolics, use combined environment for input variables
match combine ctx.ThreadVars ctx.SharedVars with
// { there might be a nicer way of doing this
| Bad [] -> Bad []
Expand Down Expand Up @@ -1482,9 +1495,14 @@ let modelBoolStore
(Exact (typedBoolToType dstE))
(Exact (typedBoolToType srcE)))

bind2 modelWithExprs
(modelBoolLValue ctx.SharedVars ctx.ThreadVars id dest)
(wrapMessages BadExpr (modelBoolExpr ctx.ThreadVars ctx.ThreadVars id) src)
// for symbolics, use combined environment for input variables
match combine ctx.ThreadVars ctx.SharedVars with
| Bad [] -> Bad []
| Bad (x :: xs) -> mergeMessages (List.map SymVarError xs) <| fail (SymVarError x)
| Ok(rv, _) ->
bind2 modelWithExprs
(modelBoolLValue ctx.SharedVars ctx.ThreadVars id dest)
(modelBoolLValueOrSymbol rv ctx.ThreadVars id src)

/// Converts an integral store to a Prim.
let modelIntStore
Expand Down

0 comments on commit dfeb2c0

Please sign in to comment.