Changeset 5355

Show
Ignore:
Timestamp:
07/10/05 12:56:06 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
7349
Message:

* initial work for getting Compile Exp right (still a couple to be filled)

Location:
src/Pugs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST/Internals.hs

    r5167 r5355  
    5656    retError, retControl, retEmpty, retIVar, readIVar, writeIVar, 
    5757    fromVals, refType, 
    58     lookupPad, padToList, 
     58    lookupPad, padToList, listToPad, 
    5959    mkPrim, mkSub, showRat, 
    6060    cxtOfSigil, typeOfSigil, 
     
    10781078-} 
    10791079data Pad = MkPad !(Map Var ([(TVar Bool, TVar VRef)])) 
    1080     deriving (Show, Eq, Ord, Typeable) 
     1080    deriving (Eq, Ord, Typeable) 
     1081 
     1082instance Show Pad where 
     1083    show pad = "MkPad (padToList " ++ show (padToList pad) ++ ")" 
    10811084 
    10821085-- | Look up a symbol in a 'Pad', returning the ref it is bound to. 
     
    11031106padToList :: Pad -> [(Var, [(TVar Bool, TVar VRef)])] 
    11041107padToList (MkPad map) = Map.assocs map 
     1108 
     1109listToPad :: [(Var, [(TVar Bool, TVar VRef)])] -> Pad 
     1110listToPad = MkPad . Map.fromList 
    11051111 
    11061112{- Eval Monad -} 
  • src/Pugs/Compile/Pugs.hs

    r5266 r5355  
    6464                , text ("return (Pad " ++ show scope ++ " pad exp)") 
    6565                ] 
     66    compile (Pos pos exp) = compileShow2 "Pos" pos exp 
     67    compile (Cxt cxt exp) = compileShow2 "Cxt" cxt exp 
    6668    compile exp = return $ text "return" $+$ parens (text $ show exp) 
     69 
     70compileShow2 :: Show a => String -> a -> Exp -> Eval Doc 
     71compileShow2 con anno exp = do 
     72    expC <- compile exp 
     73    return $ prettyDo 
     74        [ prettyBind "exp" expC 
     75        , text ("return (" ++ con ++ " " ++ show anno ++ " exp)") 
     76        ] 
    6777 
    6878instance Compile Pad where 
     
    140150            $(liftM TH.ListE $  
    141151              mapM (\name -> [|(name, tshow $ 
    142                                 $(TH.varE $ TH.mkName name) code)|]) $ 
     152                                $(TH.varE $ TH.mkName name) code{ subEnv = Nothing })|]) $ 
    143153              ["isMulti", "subName", "subType", "subEnv", "subAssoc", 
    144154              "subParams", "subBindings", "subSlurpLimit", 
     
    151161#else  
    152162    compile code | subType code == SubPrim = return $ text "mkPrim" 
    153     compile code = return $ text $ show code 
     163    compile code = return $ text $ show code{ subType = Nothing } 
    154164#endif  
    155165