Changeset 14534 for src/Pugs/Prim.hs

Show
Ignore:
Timestamp:
10/27/06 02:36:49 (2 years ago)
Author:
audreyt
Message:

* Pugs.Prim: Attribute initializers now carries through to derived classes:

class C { has $.x = 9 };
class D is C;
D.new.x; # 9

Same applies for "does".

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim.hs

    r14492 r14534  
    12581258    fetch   <- doHash meta hash_fetchVal 
    12591259 
     1260    attrs   <- fetch "attrs" 
     1261 
    12601262    name    <- fromVal =<< fetch "name" :: Eval String 
    12611263    roles   <- fromVals =<< fetch "does" :: Eval [String] 
     1264    supers  <- fromVals =<< fetch "is" :: Eval [String] 
    12621265 
    12631266    -- Role flattening -- copy over things there and put it to symbol table 
     
    12661269    -- XXX - also, copy over the inheritance chain from role's metaobject 
    12671270    mixinRoles name roles 
     1271 
     1272    -- Merge in slot definitions in "attrs" 
     1273    defs        <- join $ doHash attrs hash_fetch 
     1274    parentAttrs <- forM (roles ++ supers) $ fetchMetaInfo "attrs" 
     1275    store       <- doHash attrs hash_store 
     1276    store $ Map.unions (defs:parentAttrs) 
     1277     
    12681278    return cls 
    12691279 
     
    12731283    named   <- fromVal n 
    12741284 
    1275     meta    <- readRef =<< fromVal =<< evalExp (_Var (':':'*':showType typ)) 
    1276     fetch   <- doHash meta hash_fetchVal 
    1277     defs    <- fromVal =<< fetch "attrs" 
    1278  
     1285    defs    <- fetchMetaInfo "attrs" (showType typ) 
    12791286    attrs   <- liftIO $ H.new (==) H.hashString 
    12801287    writeIVar (IHash attrs) (named `Map.union` defs) 
     
    13691376    split' [] xs n = VList $ (map (VStr . (:[])) (take (n-1) xs)) ++ [ VStr $ drop (n-1) xs ] 
    13701377    split' glue xs n = VList $ map VStr $ split_n glue xs n 
     1378 
     1379-- XXX - The "String" below wants to be Type. 
     1380fetchMetaInfo :: Value a => String -> [Char] -> Eval a 
     1381fetchMetaInfo key typ = do 
     1382    meta    <- readRef =<< fromVal =<< evalExp (_Var (':':'*':typ)) 
     1383    fetch   <- doHash meta hash_fetchVal 
     1384    fromVal =<< fetch key 
    13711385 
    13721386-- |Implementation of 4-arity primitive operators and functions.