Skip to content

Commit

Permalink
syntax: remove constant from untyped AST
Browse files Browse the repository at this point in the history
  • Loading branch information
zoep committed Oct 27, 2023
1 parent edbabcc commit 73d1b79
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 10 deletions.
1 change: 0 additions & 1 deletion src/Parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ Precondition : 'iff' nonempty(Expr) { Iff (posn $1) $2 }
| 'iff in range' AbiType nonempty(Expr) { IffIn (posn $1) $2 $3 }

Store : Entry '=>' Expr { Rewrite $1 $3 }
| Entry { Constant $1 }

Entry : id { EVar (posn $1) (name $1) }
| Entry '[' Expr ']' list(Index) { EMapping (posn $2) $1 ($3:$5) }
Expand Down
3 changes: 1 addition & 2 deletions src/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Data.Map (Map,empty,insertWith,unionsWith,unionWith,singleton)
import Syntax.TimeAgnostic as Agnostic
import qualified Syntax.Annotated as Annotated
import qualified Syntax.Typed as Typed
import Syntax.Untyped hiding (Constant,Rewrite,Contract)
import Syntax.Untyped hiding (Rewrite,Contract)
import qualified Syntax.Untyped as Untyped

-----------------------------------------
Expand Down Expand Up @@ -335,7 +335,6 @@ locsFromRewrites rs = [l | Constant l <- rs]

nameFromStorage :: Untyped.Storage -> Id
nameFromStorage (Untyped.Rewrite e _) = nameFromEntry e
nameFromStorage (Untyped.Constant e) = nameFromEntry e

nameFromEntry :: Entry -> Id
nameFromEntry (EVar _ x) = x
Expand Down
1 change: 0 additions & 1 deletion src/Syntax/Untyped.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ newtype Creates = Creates [Assign]

data Storage
= Rewrite Entry Expr
| Constant Entry
deriving (Eq, Show)

data Assign = AssignVal StorageVar Expr | AssignMany StorageVar [Defn] | AssignStruct StorageVar [Defn]
Expand Down
6 changes: 0 additions & 6 deletions src/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ checkPost env@Env{contract,theirs} (U.Post storage maybeReturn) = do
where
checkEntries :: Id -> [U.Storage] -> Err [Rewrite]
checkEntries name entries = for entries $ \case
U.Constant loc -> Constant <$> checkPattern (focus name) loc
U.Rewrite loc val -> Rewrite <$> checkStorageExpr (focus name) loc val

focus :: Id -> Env
Expand Down Expand Up @@ -376,11 +375,6 @@ checkStorageExpr env entry expr =
assert (p, "Expression is expected to be a contract " <> show c <> " but it is a contract " <> show c) (c == c')
validContractType _ _ _ _ = pure ()

checkPattern :: Env -> U.Entry -> Err StorageLocation
checkPattern env entry =
validateEntry env entry `bindValidation` \(vt@(FromVType loctyp), ref) ->
pure $ _Loc (Item loctyp vt ref)

checkIffs :: Env -> [U.IffH] -> Err [Exp ABoolean Untimed]
checkIffs env = foldr check (pure [])
where
Expand Down

0 comments on commit 73d1b79

Please sign in to comment.