Changeset 6424 for src/Pugs/Compile.hs

Show
Ignore:
Timestamp:
08/23/05 22:18:24 (3 years ago)
Author:
iblech
Message:

* Pugs.PIL1: Added pSubLValue/pLValue to PSub and PCode, indicating the

difference between "sub foo {...}" and "sub foo is rw {...}".

* Pugs.Compile: Extract the (subLValue vcode) and put in in the appropriate

field of PSub/PCode.

* Pugs.CodeGen?.PIR: Accomodate for the above changes.
* Pugs.Parser: Parse traits for anonymous subs, too (i.e. "sub () is rw

{...}" parses and works now).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Compile.hs

    r6248 r6424  
    105105                name' | ':' `elem` name = name 
    106106                      | otherwise = "main::" ++ name -- XXX wrong 
    107             return [PSub initL SubPrim [] bodyC] 
     107            return [PSub initL SubPrim [] False bodyC] 
    108108        canCompile _ = return [] 
    109109        doCode name vsub = case subBody vsub of 
     
    117117    compile (name, decls) = do 
    118118        let bodyC = [ PStmts . PStmt . PExp $ PApp tcVoid (PExp (PVar sub)) Nothing [] 
    119                     | PSub sub _ _ _ <- decls 
     119                    | PSub sub _ _ _ _ <- decls 
    120120                    ] 
    121         return (PSub name SubPrim [] (combine bodyC PNil):decls) 
     121        return (PSub name SubPrim [] False (combine bodyC PNil):decls) 
    122122 
    123123instance Compile (SubName, VCode) [PIL_Decl] where 
     
    126126            bodyC   = PStmts (PStmt . PExp $ storeC) PNil 
    127127            exportL = "__export_" ++ (render $ varText name) 
    128         return [PSub exportL SubPrim [] bodyC] 
     128        return [PSub exportL SubPrim [] False bodyC] 
    129129    compile (name, vsub) = do 
    130130        bodyC   <- enter cxtItemAny . compile $ case subBody vsub of 
     
    132132            body                -> body 
    133133        paramsC <- compile $ subParams vsub 
    134         return [PSub name (subType vsub) paramsC bodyC] 
     134        return [PSub name (subType vsub) paramsC (subLValue vsub) bodyC] 
    135135 
    136136instance Compile (String, [(TVar Bool, TVar VRef)]) PIL_Expr where 
     
    228228 
    229229pBlock :: PIL_Stmts -> PIL_Expr 
    230 pBlock = PCode SubBlock [] 
     230pBlock = PCode SubBlock [] False 
    231231 
    232232{- 
     
    356356            exp                 -> exp 
    357357        paramsC <- compile $ subParams sub 
    358         return $ PCode (subType sub) paramsC bodyC 
     358        return $ PCode (subType sub) paramsC (subLValue sub) bodyC 
    359359    compile (Syn "module" _) = compile Noop 
    360360    compile (Syn "match" exp) = compile $ Syn "rx" exp -- wrong