Changeset 6801 for src/Pugs/Compile.hs

Show
Ignore:
Timestamp:
09/06/05 17:00:17 (3 years ago)
Author:
iblech
Message:

* Usual svn props.
* t/var/constant.t: Minor fixes.
* Pugs.PIL1, Pugs.Compile: PSub and PCode contain a p[Sub]?IsMulti? field now,

so PIL2JS and PIL-Run can know which subs are multis and which subs are not.

* Pugs.CodeGen?.PIR: Accomodate for the above change.
* PIL2JS: (Simple) multi subs!

  • PIL2JS.js: If necessary, try to call all .variants of a multi to find out whether the parameters match the sub signature. (Hack)
  • PIL::Subs: Emit appropriate code for multis --

multi foo {...} # is compiled as
our &foo ::= PIL2JS.new_multi(); &foo.add_variant({...});

* Test.pm: Removed the skip_rest_anti_multi-hack which was previously needed

for PIL2JS. :)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Compile.hs

    r6682 r6801  
    105105                name' | ':' `elem` name = name 
    106106                      | otherwise = "main::" ++ name -- XXX wrong 
    107             return [PSub initL SubPrim [] False bodyC] 
     107            return [PSub initL SubPrim [] False 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 [] False (combine bodyC PNil):decls) 
     121        return (PSub name SubPrim [] False 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 [] False bodyC] 
     128        return [PSub exportL SubPrim [] False 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 (subLValue vsub) bodyC] 
     134        return [PSub name (subType vsub) paramsC (subLValue vsub) (isMulti vsub) bodyC] 
    135135 
    136136instance Compile (String, [(TVar Bool, TVar VRef)]) PIL_Expr where 
     
    236236 
    237237pBlock :: PIL_Stmts -> PIL_Expr 
    238 pBlock = PCode SubBlock [] False 
     238pBlock = PCode SubBlock [] False False 
    239239 
    240240{- 
     
    372372            exp                 -> exp 
    373373        paramsC <- compile $ subParams sub 
    374         return $ PCode (subType sub) paramsC (subLValue sub) bodyC 
     374        return $ PCode (subType sub) paramsC (subLValue sub) (isMulti sub) bodyC 
    375375    compile (Syn "module" _) = compile Noop 
    376376    compile (Syn "match" exp) = compile $ Syn "rx" exp -- wrong