Tue Oct 24 20:51:33 BRST 2006 Caio Marcelo * Walking (slowly :o) ) towards t/mi.t. Also some work on type "Method". hunk ./MO/Compile.hs 1 +{-# OPTIONS_GHC -fglasgow-exts #-} + hunk ./MO/Compile.hs 5 --- TODO: How to do the coercing stuff :P +import MO.Base + +import qualified MO.C3 (linearize) + + + +class Class c where + superclasses :: c -> [AnyClass] + class_precedence_list :: c -> [AnyClass] + all_class_methods :: c -> [AnyMethod] + all_instance_methods :: c -> [AnyMethod] + +data AnyClass = forall c. Class c => AnyClass c + +data MI + = MkMI + { miParents :: [AnyClass] + , miClassMethods :: [AnyMethod] + , miInstanceMethods :: [AnyMethod] + } + +instance Class MI where + superclasses mi = miParents mi + class_precedence_list mi = [] -- call C3 + all_class_methods mi = miClassMethods mi + all_instance_methods mi = miInstanceMethods mi + +data SI + = MkSI + { siParent :: AnyClass + , siClassMethods :: [AnyMethod] + , siInstanceMethods :: [AnyMethod] + } + +instance Class SI where + superclasses si = [siParent si] + class_precedence_list si = [] -- call C3 + all_class_methods si = siClassMethods si + all_instance_methods si = siInstanceMethods si + + +-- Method and friends + +class Method m where + name :: m -> String + compile :: m -> AnyMethodDefinition + +data AnyMethod = forall m. Method m => AnyMethod m + +data SimpleMethod + = MkSimpleMethod + { smName :: String + , smDefinition :: AnyMethodDefinition + } + +instance Method SimpleMethod where + name = smName + compile = smDefinition + + +-- TODO: How to do the coercing stuff? :P +-- just instance MethodDefinition Code(Ref) ? hunk ./MO/Compile.hs 68 +data AnyMethodDefinition = forall a. MethodDefinition a => AnyMethodDefinition a + + +data MethodCompiled + = forall c. Code c => MkMethodCompiled { mcBody :: c } + +instance MethodDefinition MethodCompiled + + + hunk ./MO/Run.hs 38 - { mtMethods :: M.Map String Method + { mtMethods :: M.Map String AnyMethod hunk ./MO/Run.hs 43 -mtMethod :: Monad m => MethodTable -> MethodInvocation -> m Method +mtMethod :: Monad m => MethodTable -> MethodInvocation -> m AnyMethod hunk ./MO/Run.hs 50 - MkSimple c <- mtMethod mt inv + AnyMethod method <- mtMethod mt inv + let AnyMethodDefinition md = compile method + + -- let c = ? + -- + -- FIXME: looks like the perl code (Run/RI/MethodTable.pm) expects that + -- every method definition has a body, so in MO.Compile, body isn't + -- just for MethodCompiled, but is part of MethodDefinition. + hunk ./MO/Run.hs 82 --- -data Method = forall c. Code c => MkSimple { meBody :: c } - -instance C.MethodDefinition Method -