on master help sign in
Update to match new port and decl format
ed4be06Evan Czaplicki
compiler/Build/Source.hs+23−22
@@ -14,6 +14,7 @@ import Text.PrettyPrint (Doc)
14import SourceSyntax.Declaration
14import SourceSyntax.Declaration
15import SourceSyntax.Module
15import SourceSyntax.Module
16import qualified SourceSyntax.Expression as Expr
16import qualified SourceSyntax.Expression as Expr
17+import qualified SourceSyntax.Pattern as Pattern
17import qualified SourceSyntax.Type as Type
18import qualified SourceSyntax.Type as Type
18import qualified Parse.Parse as Parse
19import qualified Parse.Parse as Parse
19import qualified Metadata.Prelude as Prelude
20import qualified Metadata.Prelude as Prelude
@@ -23,41 +24,41 @@ import qualified Type.Inference as TI
23import qualified Type.Constrain.Declaration as TcDecl
24import qualified Type.Constrain.Declaration as TcDecl
24import qualified Transform.Canonicalize as Canonical
25import qualified Transform.Canonicalize as Canonical
25
26
26−build :: Bool -> Interfaces -> String -> Either [Doc] (MetadataModule () ())
27+build :: Bool -> Interfaces -> String -> Either [Doc] MetadataModule
27build noPrelude interfaces source =
28build noPrelude interfaces source =
28 do let add = if noPrelude then id else Prelude.add
29 do let add = if noPrelude then id else Prelude.add
29 infixes = Map.fromList . map (\(assoc,lvl,op) -> (op,(lvl,assoc)))
30 infixes = Map.fromList . map (\(assoc,lvl,op) -> (op,(lvl,assoc)))
30 . concatMap iFixities $ Map.elems interfaces
31 . concatMap iFixities $ Map.elems interfaces
31
32
33+ Module names exs ims decls <- do
32− modul@(Module _ _ _ decls') <- add `fmap` Parse.program infixes source
34+ modul@(Module _ _ _ decls) <- add `fmap` Parse.program infixes source
33−
34− -- check for structural errors
35− Module names exs ims decls <-
36− case Check.mistakes decls' of
35+ case Check.mistakes decls of
37− [] -> return modul
36+ [] -> return modul
38− ms -> Left ms
37+ ms -> Left ms
39
38
40 let exports'
39 let exports'
41 | null exs =
40 | null exs =
42− let get = Set.toList . SD.boundVars in
41+ let get = Set.toList . Pattern.boundVars in
43− concat [ get pattern | Definition (Expr.Def pattern _) <- decls ] ++
42+ concat [ get pattern | Definition (Expr.Definition pattern _ _) <- decls ] ++
44 concat [ map fst ctors | Datatype _ _ ctors _ <- decls ] ++
43 concat [ map fst ctors | Datatype _ _ ctors _ <- decls ] ++
45 [ name | TypeAlias name _ (Type.Record _ _) _ <- decls ]
44 [ name | TypeAlias name _ (Type.Record _ _) _ <- decls ]
46 | otherwise = exs
45 | otherwise = exs
47
46
48− metaModule <- Canonical.metadataModule interfaces $ MetadataModule {
47+ metaModule <- Canonical.metadataModule interfaces $
48+ MetadataModule
49− names = names,
49+ { names = names
50− path = FP.joinPath names,
50+ , path = FP.joinPath names
51− exports = exports',
51+ , exports = exports'
52− imports = ims,
52+ , imports = ims
53 -- reorder AST into strongly connected components
53 -- reorder AST into strongly connected components
54− program = SD.sortDefs . Expr.dummyLet $ TcDecl.toExpr decls,
54+ , program = SD.sortDefs . Expr.dummyLet $ TcDecl.toExpr decls
55− types = Map.empty,
55+ , types = Map.empty
56− datatypes = [ (name,vars,ctors,ds) | Datatype name vars ctors ds <- decls ],
56+ , datatypes = [ (name,vars,ctors,ds) | Datatype name vars ctors ds <- decls ]
57− fixities = [ (assoc,level,op) | Fixity assoc level op <- decls ],
57+ , fixities = [ (assoc,level,op) | Fixity assoc level op <- decls ]
58− aliases = [ (name,tvs,tipe,ds) | TypeAlias name tvs tipe ds <- decls ],
58+ , aliases = [ (name,tvs,tipe,ds) | TypeAlias name tvs tipe ds <- decls ]
59+ , sendPorts = [ (name,expr,tipe) | Port (Send name expr tipe) <- decls ]
59− ports = [ (name,tipe,maybe) | Port name tipe maybe <- decls ]
60+ , recvPorts = [ (name,expr,tipe) | Port (Recv name expr tipe) <- decls ]
60− }
61+ }
61
62
62 types <- TI.infer interfaces metaModule
63 types <- TI.infer interfaces metaModule
63
64