Changeset 15373

Show
Ignore:
Timestamp:
02/27/07 18:56:54 (21 months ago)
Author:
audreyt
Message:

* First step in MO bridge:

vv('12345').reverse # '54321' (newVal)
vv('12345').reverse.reverse # '12345' (newVal)

It's the only method defined (and works) at the moment.
More tomorrow.

Location:
src/Pugs
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Class.hs

    r15095 r15373  
    1919    , module MO.Util 
    2020    ) where 
    21 import MO.Run 
     21import MO.Run hiding (__) 
    2222import MO.Compile 
    2323import MO.Compile.Class 
     
    7474        fun str   -- Note that we expect "fun" to be monadic 
    7575    } 
     76 
     77inv ./ meth = ivDispatch inv $ MkMethodInvocation meth (mkArgs []) 
  • src/Pugs/Eval/Var.hs

    r15297 r15373  
    1717import Pugs.Config 
    1818import Pugs.Monads 
     19import Pugs.Class 
    1920import qualified Pugs.Val as Val 
    2021import qualified Data.ByteString.Char8 as Buf 
     
    236237                -- callMethod methName [] 
    237238                -- inv ./ meth = ivDispatch inv $ MkMethodInvocation meth (mkArgs []) 
    238                 return . castV $ "CCall " ++ show methName ++ " " ++ show capt 
     239                case invVV of 
     240                    Val.VPure p -> return . runIdentity $ do 
     241                        obj <- mkObj p 
     242                        res <- fromObjBox =<< obj ./ cast methName 
     243                        return . castV $ Val.VPure (res `asTypeOf` p) 
     244                    _       -> do 
     245                        return . castV $ "CCall " ++ show methName ++ " " ++ show capt 
    239246            } 
    240247 
  • src/Pugs/Val/Base.hs

    r15297 r15373  
    131131    asNum = cast . parseInt -- XXX - wrong 
    132132    asInt = cast . parseInt 
    133     fromObj (MkInvocant x _) = undefined 
     133    fromObj (MkInvocant x _) = fromTypeable x 
    134134    classOf _ = mkBoxClass "Str" 
    135135        [ "reverse"    ... (MkStr . Char8.reverse . unStr)