Changeset 15379
- Timestamp:
- 02/28/07 22:06:20 (21 months ago)
- Location:
- src
- Files:
-
- 10 modified
-
MO/Compile.hs (modified) (1 diff)
-
MO/Compile/Class.hs (modified) (4 diffs)
-
MO/Compile/Role.hs (modified) (3 diffs)
-
MO/Run.hs (modified) (3 diffs)
-
MO/Util.hs (modified) (5 diffs)
-
Pugs/AST/Eval.hs (modified) (1 diff)
-
Pugs/Class.hs (modified) (1 diff)
-
Pugs/Class/C3.hs (modified) (3 diffs)
-
Pugs/Internals/Cast.hs (modified) (1 diff)
-
UTF8.hs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/MO/Compile.hs
r15378 r15379 4 4 5 5 import MO.Base 6 import MO.Util 6 import MO.Util () 7 7 8 8 type MethodName = ID -
src/MO/Compile/Class.hs
r15378 r15379 3 3 module MO.Compile.Class where 4 4 5 import MO.Base 5 import MO.Base () 6 6 import MO.Compile 7 7 import MO.Compile.Attribute … … 14 14 import qualified Pugs.Class.C3 as C3 (linearize) 15 15 16 import Data.Maybe (maybeToList, fromJust)17 16 import qualified Data.Map as Map 18 17 … … 77 76 78 77 instance (Typeable1 m, Monad m) => Typeable (AnyClass m) where 79 typeOf x= typeOf (undefined :: m AnyClass_Type)78 typeOf _ = typeOf (undefined :: m AnyClass_Type) 80 79 81 80 instance (Typeable1 m, Monad m) => Eq (AnyClass m) where … … 126 125 x == y = clsName x == clsName y 127 126 instance (Typeable1 m, Monad m) => Typeable (MI m) where 128 typeOf x= typeOf (undefined :: m MI_Type)127 typeOf _ = typeOf (undefined :: m MI_Type) 129 128 130 129 emptyMI :: (Typeable1 m, Monad m) => MI m -
src/MO/Compile/Role.hs
r14701 r15379 3 3 module MO.Compile.Role where 4 4 5 import MO.Base 5 import MO.Base () 6 6 import MO.Compile 7 import MO.Run 7 import MO.Run () 8 8 import MO.Util 9 9 import MO.Compile.Attribute … … 18 18 deriving (Eq) 19 19 20 emptyRole :: Role m 20 21 emptyRole = MkRole 21 22 { roRoles = [] … … 28 29 parent_roles = roRoles 29 30 31 role_public_methods, role_private_methods :: Role m -> Collection (AnyMethod m) 30 32 role_public_methods = roPublicMethods 31 33 role_private_methods = roPrivateMethods 34 35 role_attributes :: Role m -> [Attribute m] 32 36 role_attributes = roAttributes 33 37 -
src/MO/Run.hs
r15378 r15379 56 56 57 57 instance (Typeable1 m, Monad m) => Typeable (AnyResponder m) where 58 typeOf x= typeOf (undefined :: m AnyResponder_Type)58 typeOf _ = typeOf (undefined :: m AnyResponder_Type) 59 59 60 60 class Monad m => ResponderInterface m a | a -> m where … … 75 75 76 76 mtMethod :: Monad m => MethodTable a -> MethodInvocation m -> m (MethodCompiled a) 77 mtMethod table inv@(MkMethodInvocation n _) = case M.lookup n (mtMethods table) of77 mtMethod table (MkMethodInvocation n _) = case M.lookup n (mtMethods table) of 78 78 Just r -> return r 79 79 _ -> fail $ "No such method: " ++ show n … … 94 94 95 95 instance (Typeable1 m, Monad m) => Typeable (Invocant m) where 96 typeOf x= typeOf (undefined :: m Invocant_Type)96 typeOf _ = typeOf (undefined :: m Invocant_Type) 97 97 98 98 ivDispatch :: (Typeable1 m, Monad m) => Invocant m -> MethodInvocation m -> m (Invocant m) -
src/MO/Util.hs
r15378 r15379 8 8 import Data.Map (Map) 9 9 import qualified Data.Map as Map 10 import Control.Monad (when , fmap, Functor(..))10 import Control.Monad (when) 11 11 import Debug.Trace (trace) 12 import Data.List (nub)13 12 import Data.Typeable 14 13 import GHC.Exts (unsafeCoerce#, Word(W#), Word#) … … 50 49 51 50 cmap :: (Ord a, Ord b) => (a -> b) -> Collection a -> Collection b 52 cmap f c@MkCollection { cByName = bn } =51 cmap f MkCollection { cByName = bn } = 53 52 let l = map (\(x,y) -> (x, f y)) (Map.toList bn) 54 53 in newCollection l … … 58 57 -- names. Must check how Set work and what MO's remove wanted. 59 58 remove :: (Monad m, Ord a) => ID -> a -> Collection a -> m (Collection a) 60 remove name obj c@MkCollection{ cByObject = bo, cByName = bn } = do59 remove name obj MkCollection{ cByObject = bo, cByName = bn } = do 61 60 return $ MkCollection { cByObject = Set.delete obj bo 62 61 , cByName = Map.delete name bn … … 71 70 72 71 insert :: (Ord a) => ID -> a -> Collection a -> Collection a 73 insert name obj c@MkCollection{ cByObject = bo, cByName = bn } =72 insert name obj MkCollection{ cByObject = bo, cByName = bn } = 74 73 MkCollection { cByObject = Set.insert obj bo 75 74 , cByName = Map.insert name obj bn … … 106 105 107 106 includes_any :: Ord a => Collection a -> [a] -> Bool 108 includes_any c[] = False107 includes_any _ [] = False 109 108 includes_any c (x:xs) = (includes c x) || (includes_any c xs) 110 109 111 110 includes_any_name :: Ord a => Collection a -> [ID] -> Bool 112 includes_any_name c[] = False111 includes_any_name _ [] = False 113 112 includes_any_name c (x:xs) = (includes_name c x) || (includes_any_name c xs) 114 113 115 114 includes_all :: Ord a => Collection a -> [a] -> Bool 116 includes_all c[] = False115 includes_all _ [] = False 117 116 includes_all c (x:xs) = (includes c x) && (includes_any c xs) 118 117 -
src/Pugs/AST/Eval.hs
r15374 r15379 117 117 strMsg = errStr 118 118 119 liftEval :: ReaderT Env SIO a -> Eval a 119 120 liftEval m = EvalT $ do 120 121 a <- ContT (m >>=) -
src/Pugs/Class.hs
r15374 r15379 85 85 } 86 86 87 (./) :: (Typeable1 m, Monad m) => Invocant m -> String -> m (Invocant m) 87 88 inv ./ meth = ivDispatch inv $ MkMethodInvocation meth (mkArgs []) -
src/Pugs/Class/C3.hs
r14853 r15379 49 49 candidates = nub (map head l) 50 50 51 -- | Auxiliar function for the merge operation, given a candidate list,51 -- | Auxiliary function for the merge operation, given a candidate list, 52 52 -- find a good candidate, return 'Nothing' if none of them can be used, 53 53 -- meaning an impossible merge due conflict. If it finds one, calls … … 56 56 merge_round _ [] = return [] 57 57 merge_round [] _ = fail "merge conflict" 58 merge_round (c:cs) l @(x:xs)58 merge_round (c:cs) l 59 59 | good c l = do 60 60 a <- merge clean_list … … 67 67 -- |Returns 'True' if a candidate element isn't present in the tail 68 68 -- of each list. 69 good c[] = True69 good _ [] = True 70 70 good c (x:xs) 71 71 | c `elem` (tail x) = False -
src/Pugs/Internals/Cast.hs
r15295 r15379 13 13 import GHC.Exts (unsafeCoerce#, Word(W#), Word#) 14 14 import Data.ByteString (ByteString) 15 import Data.Sequence (Seq , singleton)15 import Data.Sequence (Seq) 16 16 import Numeric (showHex) 17 17 import Data.Foldable (toList) -
src/UTF8.hs
r14081 r15379 184 184 ,isPrefixOf,isSuffixOf,isSubstringOf 185 185 186 ,copy187 186 ,getContents, putStr, putStrLn 188 187 ,readFile, {-mmapFile,-} writeFile … … 513 512 514 513 inits :: ByteString -> [ByteString] 515 inits bs@(PS x s l) = [PS x s n | n <- rawIndices bs]514 inits bs@(PS x s _) = [PS x s n | n <- rawIndices bs] 516 515 517 516 tails :: ByteString -> [ByteString] … … 572 571 -- spanEnd 573 572 spanEnd :: (Char -> Bool) -> ByteString -> (ByteString, ByteString) 574 spanEnd p= error "not implemented yet"573 spanEnd _ = error "not implemented yet" 575 574 576 575 -- lines … … 653 652 | otherwise = unsafeCreate (n * numBytes c) $ \p -> go n p 654 653 where 655 go 0 p= return ()654 go 0 _ = return () 656 655 go n p = do 657 656 k <- putUTF8 p c … … 677 676 -- elemIndexLast 678 677 elemIndexLast :: Char -> ByteString -> Maybe Int 679 elemIndexLast c= undefined678 elemIndexLast _ = undefined 680 679 681 680 -- findIndex … … 799 798 is <- unsafeInterleaveIO $ go (k+i) (q `plusPtr` i) (m-i) 800 799 return (k:is) 801 800 801 breakFirst :: Char -> ByteString -> Maybe (ByteString, ByteString) 802 802 breakFirst c xs = let (x,y) = breakChar c xs in 803 803 if null y then Nothing else Just (x, tail y) … … 808 808 -- use regular findSubstrings and map results back 809 809 findSubstrings :: ByteString -> ByteString -> [Int] 810 findSubstrings b1 b2 @(PS x s l)| null b1 = [0 .. length b2]811 | otherwise =812 [ i | (i,b) <- P.zip [0..] (tails b2), b1 `isPrefixOf` b ]810 findSubstrings b1 b2 | null b1 = [0 .. length b2] 811 | otherwise = 812 [ i | (i,b) <- P.zip [0..] (tails b2), b1 `isPrefixOf` b ] 813 813 814 814
