Show
Ignore:
Timestamp:
11/10/05 18:33:20 (3 years ago)
Author:
gaal
Message:

* when CODE:

  • given { when &sub { ... } } works for 0- and 1-arity subs.
  • still TODO: when { bare closure }, as this requires parser tweaking.
  • tests.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/Match.hs

    r7879 r7925  
    1010import Pugs.Types 
    1111import Pugs.Config 
     12import Pugs.Prim.Code 
    1213import qualified RRegex.PCRE as PCRE 
    1314import qualified Data.Map as Map 
     
    8283op2Match :: Val -> Val -> Eval Val 
    8384 
     85op2Match _ y@(VCode _) = do 
     86    (arity :: Int) <- fromVal =<< op1CodeArity y 
     87    res <- fromVal =<< case arity of 
     88        0 -> evalExp $ App (Val y) Nothing [] 
     89        1 -> do 
     90             topic <- readVar "$_" 
     91             evalExp $ App (Val y) Nothing [Val topic] 
     92        _ -> fail ("Unexpected arity in smart match: " ++ (show arity)) 
     93    return $ VBool $ res 
     94 
    8495op2Match x (VRef (MkRef (IScalar sv))) | scalar_iType sv == mkType "Scalar::Const" = do 
    8596    y' <- scalar_fetch' sv