Skip to content

Commit

Permalink
Well-typed substitutions for singleton types
Browse files Browse the repository at this point in the history
  • Loading branch information
zoep committed Dec 3, 2024
1 parent 48a2009 commit 49fcecd
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions src/Act/HEVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -330,36 +330,15 @@ substExp subst expr = case expr of
NEq pn st a b -> NEq pn st (substExp subst a) (substExp subst b)

ITE pn a b c -> ITE pn (substExp subst a) (substExp subst b) (substExp subst c)
TEntry pn whn k entry -> undefined -- expr -- TODO must do ixs too

-- -- Substituion of a bare calldata variable
-- Var _ _ st _ (VVar _ _ x) -> case M.lookup x subst of
-- Just (TExp st' exp') -> maybe (error "Internal error: type missmatch") (\Refl -> exp') $ testEquality st st'
-- Nothing -> error "Internal error: Ill-defined substitution"

-- -- Substituion of a variable, when this variable is used as a pointer to contract
-- Var p tm st vt vref -> case substVarRef subst vref of
-- Left ref -> TEntry p tm (Item st vt ref) -- TODO deal with timings. Right now we can only refer to Pre
-- Right ref -> Var p tm st vt ref
TEntry _ _ SCalldata (Item st _ (CVar _ _ x)) -> case M.lookup x subst of
Just (TExp st' exp') -> maybe (error "Internal error: type missmatch") (\Refl -> exp') $ testEquality st st'
Nothing -> error "Internal error: Ill-defined substitution"
TEntry pn whn _ item -> case substItem subst item of
ETItem k' item' -> TEntry pn whn k' item'

Create pn a b -> Create pn a (substArgs subst b)

-- substVarRef :: M.Map Id TypedExp -> VarRef -> Either StorageRef VarRef
-- substVarRef subst (VVar _ _ x) =
-- case M.lookup x subst of
-- Just (TExp _ (TEntry _ _ (Item _ _ ref))) -> Left ref
-- Just (TExp _ (Var _ _ _ _ ref)) -> Right ref
-- Just _ -> error "Internal error: cannot access fields of non-pointer var"
-- Nothing -> error "Internal error: ill-formed substitution"
-- substVarRef subst (VField pn vref c x) =
-- case substVarRef subst vref of
-- Left ref -> Left $ SField pn ref c x
-- Right ref -> Right $ VField pn ref c x
-- substVarRef subst (VMapping pn vref ixs) =
-- case substVarRef subst vref of
-- Left ref -> Left $ SMapping pn ref (substArgs subst ixs)
-- Right ref -> Right $ VMapping pn ref (substArgs subst ixs)


returnsToExpr :: Monad m => ContractMap -> Maybe TypedExp -> ActT m (EVM.Expr EVM.Buf)
returnsToExpr _ Nothing = pure $ EVM.ConcreteBuf ""
Expand Down Expand Up @@ -752,7 +731,7 @@ checkConstructors solvers initcode runtimecode (Contract ctor@(Constructor _ ifa
res2 <- lift $ checkResult calldata (Just sig) =<< checkInputSpaces solvers solbehvs actbehvs
pure $ checks *> res1 *> res2 *> Success cmap
where
removeFails branches = filter isSuccess $ branches
removeFails branches = filter isSuccess branches


checkBehaviours :: forall m. App m => SolverGroup -> Contract -> ContractMap -> ActT m (Error String ())
Expand Down

0 comments on commit 49fcecd

Please sign in to comment.