on master help sign in
Constructors don't need completely independent tags
commit7b4fb2ad9388e18b8c0e54b4ca93c5f738d2c67f authorEdwin Brady <eb@cs.st-andrews.ac.uk> dateThu 27 Sep 2012, 16:25 (14 years ago) parente88a135
2 files changed+5−3
src/IRTS/Compiler.hs+2−2 src/IRTS/Lang.hs+3−1
src/IRTS/Compiler.hs+2−2
@@ -34,7 +34,7 @@ compile target f tm
3434 hdrs <- getHdrs
3535 let defs = defsIn ++ [(MN 0 "runMain", maindef)]
3636 -- iputStrLn $ showSep "\n" (map show defs)
37− let (nexttag, tagged) = addTags 0 (liftAll defs)
37+ let (nexttag, tagged) = addTags 65536 (liftAll defs)
3838 let ctxtIn = addAlist tagged emptyContext
3939 let defuns = defunctionalise nexttag ctxtIn
4040 -- iputStrLn $ showSep "\n" (map show (toAlist defuns))
@@ -100,7 +100,7 @@ mkLDecl n (Function tm _) = do e <- ir tm
100100 return (declArgs [] n e)
101101mkLDecl n (CaseOp _ _ pats _ _ args sc) = do e <- ir (args, sc)
102102 return (declArgs [] n e)
103−mkLDecl n (TyDecl (DCon t a) _) = return $ LConstructor n (-1) a
103+mkLDecl n (TyDecl (DCon t a) _) = return $ LConstructor n t a
104104mkLDecl n (TyDecl (TCon t a) _) = return $ LConstructor n (-1) a
105105mkLDecl n _ = return (LFun n [] (LError ("Impossible declaration " ++ show n)))
106106
src/IRTS/Lang.hs+3−1
@@ -60,8 +60,10 @@ type LDefs = Ctxt LDecl
6060
6161addTags :: Int -> [(Name, LDecl)] -> (Int, [(Name, LDecl)])
6262addTags i ds = tag i ds []
63− where tag i ((n, LConstructor n' t a) : as) acc
63+ where tag i ((n, LConstructor n' (-1) a) : as) acc
6464 = tag (i + 1) as ((n, LConstructor n' i a) : acc)
65+ tag i ((n, LConstructor n' t a) : as) acc
66+ = tag i as ((n, LConstructor n' t a) : acc)
6567 tag i (x : as) acc = tag i as (x : acc)
6668 tag i [] acc = (i, reverse acc)
6769