Show
Ignore:
Timestamp:
05/27/05 05:22:52 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
5515
Message:

* Perl 5 Array and Hash are now accessible from Perl 6.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Types/Array.hs

    r3947 r3961  
    251251    array_deleteElem _ _   = retConstError undef 
    252252 
     253evalPerl5Sub :: String -> [PerlSV] -> Eval Val 
     254evalPerl5Sub code args = do 
     255    env   <- ask 
     256    fmap PerlSV . liftIO $ do 
     257        envSV <- mkVal env 
     258        subSV <- evalPerl5 code envSV (enumCxt cxtItemAny) 
     259        callPerl5 subSV nullSV args envSV (enumCxt cxtItemAny) 
     260 
    253261instance ArrayClass PerlSV where 
    254262    array_iType = const $ mkType "Array::Perl" 
    255     array_fetchVal _  _    = return undef 
    256     array_storeVal _ _ _   = retConstError undef 
     263    array_fetchVal sv idx = do 
     264        idxSV   <- fromVal $ castV idx 
     265        evalPerl5Sub "sub { $_[0]->[$_[1]] }" [sv, idxSV] 
     266    array_storeVal sv idx val = do 
     267        idxSV   <- fromVal $ castV idx 
     268        valSV   <- fromVal val 
     269        evalPerl5Sub "sub { $_[0]->[$_[1]] = $_[2] }" [sv, idxSV, valSV] 
     270        return () 
    257271    array_storeElem _ _ _  = retConstError undef 
    258272    array_deleteElem _ _   = retConstError undef