Skip to content

Commit

Permalink
Allow thread and shared vars as params to symbolics in assigns
Browse files Browse the repository at this point in the history
  • Loading branch information
bensimner authored and MattWindsor91 committed Feb 2, 2017
1 parent 315f92a commit b0150c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 0 additions & 2 deletions AST.fs
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,6 @@ let node (streamname : string)
: Node<'a> =
{ Position = { StreamName = streamname; Line = line; Column = column }; Node = a }

let unwrap { Node = n } = n;

/// <summary>
/// Type-constrained version of <c>func</c> for <c>AFunc</c>s.
/// </summary>
Expand Down
17 changes: 12 additions & 5 deletions Modeller.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ open Starling.Core.Definer
open Starling.Core.TypeSystem
open Starling.Core.Expr
open Starling.Core.Var
open Starling.Core.Var.VarMap
open Starling.Core.Symbolic
open Starling.Core.Model
open Starling.Core.View
Expand Down Expand Up @@ -1360,8 +1361,8 @@ let modelIntLValueOrSymbol
(env : VarMap) (idxEnv : VarMap) (marker : Var -> 'Var) (ex : Expression)
: Result<TypedIntExpr<Sym<'Var>>, PrimError> =
match ex with
| RValue r ->
match unwrap r with
| RValue r ->
match r.Node with
| Symbolic _ -> wrapMessages BadExpr (modelIntExpr env idxEnv marker) r
| _ -> fail (NeedLValue r)
| LValue l -> wrapMessages BadExpr (modelIntExpr env idxEnv marker) l
Expand Down Expand Up @@ -1447,9 +1448,15 @@ let modelIntLoad
(Exact (typedIntToType dstE))
(Exact (typedIntToType srcE)))

bind2 modelWithExprs
(modelIntLValue ctx.ThreadVars ctx.ThreadVars id dest)
(modelIntLValueOrSymbol ctx.SharedVars ctx.ThreadVars id src)
match combine ctx.ThreadVars ctx.SharedVars with
// { there might be a nicer way of doing this
| Bad [] -> Bad []
| Bad (x :: xs) -> mergeMessages (List.map SymVarError xs) <| fail (SymVarError x)
// }
| Ok(rv, _) ->
bind2 modelWithExprs
(modelIntLValue ctx.ThreadVars ctx.ThreadVars id dest)
(modelIntLValueOrSymbol rv ctx.ThreadVars id src)

/// Converts a Boolean store to a Prim.
let modelBoolStore
Expand Down

0 comments on commit b0150c3

Please sign in to comment.