Skip to content

Commit

Permalink
Merge pull request #10 from distrap/srk/chores
Browse files Browse the repository at this point in the history
More chores
  • Loading branch information
sorki authored Dec 16, 2023
2 parents e4a337f + 802a976 commit 25d621f
Show file tree
Hide file tree
Showing 65 changed files with 200 additions and 333 deletions.
7 changes: 7 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ packages:
ivory-artifact
ivory-backend-c
ivory-eval
ivory-examples
ivory-hw
ivory-model-check
ivory-opts
ivory-quickcheck
ivory-serialize
ivory-stdlib
ivory-tasty

-- until next release but only due to warnings and strict CI
source-repository-package
type: git
location: https://github.com/mainland/language-c-quote
tag: a27ebb2fa84aa6a378bcbf244a156c58fe86df5d
35 changes: 35 additions & 0 deletions cabal.project.local.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ivory
ghc-options: -Wall -Werror -Wunused-packages

package ivory-artifact
ghc-options: -Wall -Werror -Wunused-packages

package ivory-backend-c
ghc-options: -Wall -Werror -Wunused-packages

package ivory-eval
ghc-options: -Wall -Werror -Wunused-packages

package ivory-examples
ghc-options: -Wall -Werror -Wunused-packages

package ivory-hw
ghc-options: -Wall -Werror -Wunused-packages

package ivory-model-check
ghc-options: -Wall -Werror -Wunused-packages

package ivory-opts
ghc-options: -Wall -Werror -Wunused-packages

package ivory-quickcheck
ghc-options: -Wall -Werror -Wunused-packages

package ivory-serialize
ghc-options: -Wall -Werror -Wunused-packages

package ivory-stdlib
ghc-options: -Wall -Werror -Wunused-packages

package ivory-tasty
ghc-options: -Wall -Werror -Wunused-packages
1 change: 0 additions & 1 deletion ivory-artifact/Makefile

This file was deleted.

Empty file removed ivory-artifact/Makefile.deps
Empty file.
2 changes: 0 additions & 2 deletions ivory-artifact/Setup.hs

This file was deleted.

7 changes: 3 additions & 4 deletions ivory-artifact/ivory-artifact.cabal
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cabal-version: 2.2
name: ivory-artifact
synopsis: Manage additional data files during Ivory compilation.
description: Mostly used by other Ivory libraries and backends and typically shouldn't have to be used directly by the user.
Expand All @@ -7,12 +8,11 @@ maintainer: [email protected]
category: Language
homepage: http://ivorylang.org
build-type: Simple
cabal-version: >= 1.10
license: BSD3
license: BSD-3-Clause
license-file: LICENSE
source-repository this
type: git
location: https://github.com/GaloisInc/ivory
location: https://github.com/distrap/ivory
tag: hackage-0.1.0.4

library
Expand All @@ -24,7 +24,6 @@ library
filepath,
directory,
text,
utf8-string,
HStringTemplate
hs-source-dirs: src
default-language: Haskell2010
Expand Down
2 changes: 0 additions & 2 deletions ivory-backend-c/Makefile

This file was deleted.

2 changes: 0 additions & 2 deletions ivory-backend-c/Setup.hs

This file was deleted.

19 changes: 4 additions & 15 deletions ivory-backend-c/ivory-backend-c.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
-- Initial ivory.cabal generated by cabal init. For further documentation,
-- see http://haskell.org/cabal/users-guide/

cabal-version: 2.2
name: ivory-backend-c
version: 0.1.0.9
author: Galois, Inc.
Expand All @@ -10,15 +8,14 @@ synopsis: Ivory C backend.
description: Ivory compiler, to a subset of C99.
homepage: http://ivorylang.org
build-type: Simple
cabal-version: >= 1.10
data-files: runtime/ivory.h,
runtime/ivory_templates.h,
runtime/ivory_asserts.h
license: BSD3
license: BSD-3-Clause
license-file: LICENSE
source-repository this
type: git
location: https://github.com/GaloisInc/ivory
location: https://github.com/distrap/ivory
tag: hackage-0.1.0.4

library
Expand All @@ -33,23 +30,15 @@ library
other-modules: Paths_ivory_backend_c

build-depends: base >= 4.7 && < 5,
base-compat,
language-c-quote >= 0.13,
srcloc,
mainland-pretty >= 0.2.5,
mainland-pretty >= 0.6,
monadLib >= 3.7,
template-haskell >= 2.8,
bytestring >= 0.10,
directory,
filepath,
process,
containers,
ivory,
ivory-opts,
ivory-artifact
if impl(ghc < 8)
build-depends: semigroups

hs-source-dirs: src
default-language: Haskell2010

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{-# LANGUAGE CPP #-}

module Ivory.Compile.C.CmdlineFrontend.Options where

import Prelude ()
import Prelude.Compat
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup (Semigroup(..))
#endif

import System.Console.GetOpt (ArgDescr (..), ArgOrder (Permute),
OptDescr (..), getOpt, usageInfo)

Expand Down
2 changes: 1 addition & 1 deletion ivory-backend-c/src/Ivory/Compile/C/Gen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ toBody ens stmt =
-> [C.BlockDecl $
case inits of
I.InitStruct []
-> [cdecl| $ty:(toType t) $id:(toVar var); |]
-> [cdecl| $ty:(toType t) $id:(toVar var) = {0}; |]
_ -> [cdecl| $ty:(toType t) $id:(toVar var)
= $init:(toInit inits); |]
]
Expand Down
6 changes: 0 additions & 6 deletions ivory-backend-c/src/Ivory/Compile/C/Modules.hs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE QuasiQuotes #-}

module Ivory.Compile.C.Modules where

import Paths_ivory_backend_c (version)

import Prelude ()
import Prelude.Compat

import Text.PrettyPrint.Mainland
#if MIN_VERSION_mainland_pretty(0,6,0)
import Text.PrettyPrint.Mainland.Class
#endif

import qualified Ivory.Language.Syntax.AST as I

Expand Down
7 changes: 0 additions & 7 deletions ivory-backend-c/src/Ivory/Compile/C/Types.hs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE QuasiQuotes #-}

module Ivory.Compile.C.Types where

import Prelude ()
import Prelude.Compat

import Data.List (nub)
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup (Semigroup(..))
#endif

import Language.C.Quote.GCC
import qualified "language-c-quote" Language.C.Syntax as C
Expand Down
2 changes: 0 additions & 2 deletions ivory-eval/Makefile

This file was deleted.

2 changes: 0 additions & 2 deletions ivory-eval/Setup.hs

This file was deleted.

9 changes: 3 additions & 6 deletions ivory-eval/ivory-eval.cabal
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
cabal-version: 2.2
name: ivory-eval
version: 0.1.0.6
author: Galois, Inc.
copyright: 2014 Galois, Inc.
maintainer: [email protected]
category: Testing
build-type: Simple
cabal-version: >= 1.10
synopsis: Simple concrete evaluator for Ivory programs
description: Warning! This module is experimental and its implementation may change dramatically.
homepage: http://ivorylang.org
license: BSD3
license: BSD-3-Clause
license-file: LICENSE
source-repository head
type: git
location: https://github.com/GaloisInc/ivory
location: https://github.com/distrap/ivory
tag: hackage-0.1.0.4

library
exposed-modules: Ivory.Eval
build-depends: base >= 4.6 && < 5,
base-compat,
containers,
monadLib,
ivory
Expand All @@ -34,11 +33,9 @@ test-suite test
ghc-options: -Wall

build-depends: base >= 4.7 && < 5
, base-compat
, containers
, tasty >= 0.10
, tasty-hunit
, monadLib
, ivory
, ivory-eval

Expand Down
61 changes: 47 additions & 14 deletions ivory-eval/src/Ivory/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,53 @@ module Ivory.Eval
, evalStmt
) where

import Prelude ()
import Prelude.Compat hiding (and, div, mod,
negate, not, or)
import qualified Prelude.Compat as Prelude

import Prelude
( Bool(..)
, Char
, Double
, Either
, Eq
, Float
, Integer
, Monad
, MonadFail
, Num
, Ord
, String
, Show(..)
, (.)
, ($)
, (<$>)
, (>>)
, (==)
, (/=)
, (<)
, (>)
, (<=)
, (>=)
, (&&)
, (||)
, (+)
, (-)
, (*)
, (/)
, (++)
, error
, fmap
, fst
, fromInteger
, fromIntegral
, mapM
, mapM_
, otherwise
, repeat
, take
, toInteger
, toEnum
, return
)
import qualified Prelude
import Control.Monad (foldM, unless, void)
#if MIN_VERSION_base_compat(0,10,0)
import qualified Control.Monad.Fail.Compat as Fail
#endif
import Data.Int
import qualified Data.Map as Map
import Data.Maybe
Expand All @@ -49,16 +87,11 @@ import MonadLib (ExceptionM (..),
runExceptionT, runId,
runStateT, sets_)

-- XXX: DEBUG
-- import Debug.Trace

type Error = String
type Eval a = StateT EvalState (ExceptionT Error Id) a

#if MIN_VERSION_base_compat(0,10,0)
instance {-# OVERLAPS #-} Fail.MonadFail (StateT EvalState (ExceptionT Error Id)) where
instance {-# OVERLAPS #-} MonadFail (StateT EvalState (ExceptionT Error Id)) where
fail = raise
#endif

runEval :: Eval a -> Either Error a
runEval doThis = fmap fst (runEvalStartingFrom (initState Map.empty) doThis)
Expand Down
17 changes: 9 additions & 8 deletions ivory-eval/test/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

module Main where

import Prelude ()
import Prelude.Compat

import Ivory.Language
import Ivory.Language.Monad

Expand All @@ -32,17 +29,21 @@ tests = testGroup "Tests" [ sumTest, assertTest ]

sumTest :: TestTree
sumTest = testCase "sum" $ do
let Right (_, EvalState st _ _)
let eres
= runEvalStartingFrom (initState mempty)
$ evalBlock $ blockStmts $ snd $ runIvory $ do
r <- local (izero :: Init ('Stored Sint32))
11 `times` \(i :: Ix 12) -> do -- sum [ 10 .. 0 ]
v <- deref r
store r (v + safeCast i)
assertEqual "wrong state!"
(Map.fromList [ ("local0", Sint32 55), ("deref3", Sint32 54)
, ("ix2", Sint32 0), ("ref1", Ref "local0")])
st

case eres of
Right (_, EvalState st _ _) -> do
assertEqual "wrong state!"
(Map.fromList [ ("local0", Sint32 55), ("deref3", Sint32 54)
, ("ix2", Sint32 0), ("ref1", Ref "local0")])
st
Left x -> fail $ "Eval failed with" <> show x

assertTest :: TestTree
assertTest = testCase "assert" $ do
Expand Down
2 changes: 0 additions & 2 deletions ivory-examples/Makefile

This file was deleted.

2 changes: 0 additions & 2 deletions ivory-examples/Setup.hs

This file was deleted.

3 changes: 0 additions & 3 deletions ivory-examples/examples/ConstPtrRef.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ module ConstPtrRef where

import Ivory.Language

import Prelude ()
import Prelude.Compat

test :: Def ('[ConstRef s ('Stored (Ptr 'Global ('Stored Uint8)))] ':-> ())
test = proc "ConstPtrRef_test" $ \refptr -> body $ do
ptr <- deref refptr
Expand Down
3 changes: 0 additions & 3 deletions ivory-examples/examples/FibLoop.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

module FibLoop where

import Prelude ()
import Prelude.Compat

import Ivory.Compile.C.CmdlineFrontend
import Ivory.Language

Expand Down
Loading

0 comments on commit 25d621f

Please sign in to comment.