Changeset 5355
- Timestamp:
- 07/10/05 12:56:06 (4 years ago)
- svk:copy_cache_prev:
- 7349
- Location:
- src/Pugs
- Files:
-
- 2 modified
-
AST/Internals.hs (modified) (3 diffs)
-
Compile/Pugs.hs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/AST/Internals.hs
r5167 r5355 56 56 retError, retControl, retEmpty, retIVar, readIVar, writeIVar, 57 57 fromVals, refType, 58 lookupPad, padToList, 58 lookupPad, padToList, listToPad, 59 59 mkPrim, mkSub, showRat, 60 60 cxtOfSigil, typeOfSigil, … … 1078 1078 -} 1079 1079 data Pad = MkPad !(Map Var ([(TVar Bool, TVar VRef)])) 1080 deriving (Show, Eq, Ord, Typeable) 1080 deriving (Eq, Ord, Typeable) 1081 1082 instance Show Pad where 1083 show pad = "MkPad (padToList " ++ show (padToList pad) ++ ")" 1081 1084 1082 1085 -- | Look up a symbol in a 'Pad', returning the ref it is bound to. … … 1103 1106 padToList :: Pad -> [(Var, [(TVar Bool, TVar VRef)])] 1104 1107 padToList (MkPad map) = Map.assocs map 1108 1109 listToPad :: [(Var, [(TVar Bool, TVar VRef)])] -> Pad 1110 listToPad = MkPad . Map.fromList 1105 1111 1106 1112 {- Eval Monad -} -
src/Pugs/Compile/Pugs.hs
r5266 r5355 64 64 , text ("return (Pad " ++ show scope ++ " pad exp)") 65 65 ] 66 compile (Pos pos exp) = compileShow2 "Pos" pos exp 67 compile (Cxt cxt exp) = compileShow2 "Cxt" cxt exp 66 68 compile exp = return $ text "return" $+$ parens (text $ show exp) 69 70 compileShow2 :: Show a => String -> a -> Exp -> Eval Doc 71 compileShow2 con anno exp = do 72 expC <- compile exp 73 return $ prettyDo 74 [ prettyBind "exp" expC 75 , text ("return (" ++ con ++ " " ++ show anno ++ " exp)") 76 ] 67 77 68 78 instance Compile Pad where … … 140 150 $(liftM TH.ListE $ 141 151 mapM (\name -> [|(name, tshow $ 142 $(TH.varE $ TH.mkName name) code )|]) $152 $(TH.varE $ TH.mkName name) code{ subEnv = Nothing })|]) $ 143 153 ["isMulti", "subName", "subType", "subEnv", "subAssoc", 144 154 "subParams", "subBindings", "subSlurpLimit", … … 151 161 #else 152 162 compile code | subType code == SubPrim = return $ text "mkPrim" 153 compile code = return $ text $ show code 163 compile code = return $ text $ show code{ subType = Nothing } 154 164 #endif 155 165
