Changeset 22196 for src/Pugs/CodeGen

Show
Ignore:
Timestamp:
09/09/08 22:03:28 (3 months ago)
Author:
pmurias
Message:

[pugs-m0ld] method calls

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/CodeGen/M0ld.hs

    r22186 r22196  
    6363instance EmitM0ld Val where 
    6464    emit (VInt int) r = return $ "my " ++ r ++ " = " ++ (show int) ++ ";\n" 
     65    -- " support 
     66    emit (VStr str) r = return $ "my " ++ r ++ " = " ++ (show str) ++ ";\n" 
    6567    emit other r = placeholder other r 
    6668 
     69methodCall inv method args r = do 
     70    inv_r <- uniqueId 
     71    inv_code <- emit inv inv_r 
     72    args <- mapM (\arg -> do 
     73        id <- uniqueId 
     74        code <- emit arg id 
     75        return (code,id)) args 
     76    return (inv_code ++ (concat $ fmap fst args) ++ "my " ++ r ++ " = " ++ inv_r ++ ".\"" ++ method ++ "\"(" ++ (concat $ fmap snd args) ++ ");\n") 
    6777instance EmitM0ld PIL_LValue where 
    6878    emit lvalue r = case lvalue of 
    69         PApp {pFun=fun,pArgs=args,pInv=Nothing} -> do 
    70             fun_r <- uniqueId 
    71             fun_code <- emit fun fun_r 
    72             args <- mapM (\arg -> do 
    73                 id <- uniqueId 
    74                 code <- emit arg id 
    75                 return (code,id)) args 
    76             return (fun_code ++ (concat $ fmap fst args) ++ "my " ++ r ++ " = " ++ fun_r ++ ".\"postcircumfix:( )\"(" ++ (concat $ fmap snd args) ++ ");\n") 
     79        PApp {pFun=fun,pArgs=args,pInv=Nothing} -> 
     80            methodCall fun "postcircumfix:( )" args r 
     81        PApp {pFun=PExp {pLV = PVar {pVarName = '&':method}},pArgs=args,pInv=Just inv} -> 
     82            methodCall inv method args r 
    7783        PVar {pVarName=name} -> do 
    7884            return $ "my " ++ r ++ " = $scope.\"postcircumfix:{ }\"(\"" ++ name ++ "\");\n"