-
Notifications
You must be signed in to change notification settings - Fork 0
/
TigerTemp.hs
38 lines (28 loc) · 933 Bytes
/
TigerTemp.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{-# Language UndecidableInstances #-}
module TigerTemp where
import Control.Monad.State
import TigerSymbol
import TigerUnique
type Label = Symbol
type Temp = Symbol
makeStringT :: Temp -> String
makeStringT = unpack
makeStringL :: Label -> String
makeStringL = unpack
detgenTemp :: Integer -> Temp
detgenTemp i = pack ("T" ++ show i)
detgenLabel :: Integer -> Label
detgenLabel i = pack ("L" ++ show i)
-- | Clase generadora de temps, y labels
class TLGenerator w where
newTemp :: w Temp
newLabel :: w Label
--instance (Monad p , UniqueGenerator p) => TLGenerator p where
-- newTemp = detgenTemp <$> mkUnique
-- newLabel = detgenLabel <$> mkUnique
instance TLGenerator StGen where
newTemp = detgenTemp <$> mkUnique
newLabel = detgenLabel <$> mkUnique
instance (MonadTrans t, TLGenerator m, Monad m) => TLGenerator (t m) where
newTemp = lift newTemp
newLabel = lift newLabel