Changeset 2957

Show
Ignore:
Timestamp:
05/11/05 02:32:56 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
4498
Message:

* $obj.clone() support.
* $obj ~~ Class support.

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST.hs

    r2956 r2957  
    5050    newScalar, newArray, newHandle, newObject, 
    5151    proxyScalar, constScalar, lazyScalar, lazyUndef, constArray, 
    52     retError, retControl, retEmpty, retIVar, writeIVar, 
     52    retError, retControl, retEmpty, retIVar, readIVar, writeIVar, 
    5353    fromVals, refType, 
    5454    mkPad, lookupPad, padToList, diffPads, unionPads, 
  • src/Pugs/AST/Internals.hs

    r2956 r2957  
    11531153 
    11541154data VObject = MkObject 
    1155     { objType   :: VType 
    1156     , objAttrs  :: IHash 
     1155    { objType   :: !VType 
     1156    , objAttrs  :: !IHash 
    11571157    } 
    11581158    deriving (Show, Eq, Ord, Typeable) 
  • src/Pugs/Prim.hs

    r2956 r2957  
    6060op1 :: Ident -> Val -> Eval Val 
    6161op1 "!"    = op1Cast (VBool . not) 
     62op1 "clone" = \x -> do 
     63    (VObject o) <- fromVal x 
     64    attrs   <- readIVar (IHash $ objAttrs o) 
     65    attrs'  <- liftSTM $ newTVar Map.empty 
     66    writeIVar (IHash attrs') attrs 
     67    return $ VObject o{ objAttrs = attrs' } 
    6268op1 "chop" = \x -> do 
    6369    ref <- fromVal x 
     
    11871193\\n   Int       pre     kill    (Int, List)\ 
    11881194\\n   Object    pre     new     (Type: Named)\ 
     1195\\n   Object    pre     clone   (Object)\ 
    11891196\\n   List      pre     Pugs::Internals::runInteractiveCommand    (?Str=$_)\ 
    11901197\\n   List      pre     Pugs::Internals::openFile    (?Str,?Str=$_)\ 
  • src/Pugs/Prim/Match.hs

    r2948 r2957  
    99import Pugs.AST 
    1010import Pugs.Types 
     11import Pugs.Context 
    1112import Pugs.Config 
    1213import qualified RRegex.PCRE as PCRE 
     
    6768    y' <- readRef y 
    6869    op2Match x y' 
     70 
     71op2Match x (VType t) = do 
     72    typ <- evalValType x 
     73    cls <- asks envClasses 
     74    return $ VBool (isaType cls (showType t) typ) 
    6975 
    7076op2Match x (VSubst (rx, subst)) | rxGlobal rx = do 
  • t/oo/class/basic.t

    r2649 r2957  
    1414# L<S12/"Classes"> 
    1515 
    16 eval 'class Foo {}'; 
     16class Foo {}; 
    1717 
    18 my $foo = eval 'Foo.new()'; 
    19 eval_ok('$foo ~~ Foo', '... smartmatch our $foo to the Foo class', :todo); 
     18my $foo = Foo.new(); 
     19ok($foo ~~ Foo, '... smartmatch our $foo to the Foo class'); 
    2020 
    21 my $foo_clone = eval '$foo.clone()'; 
    22 eval_ok('$foo_clone ~~ Foo', '... smartmatch our $foo_clone to the Foo class', :todo<feature>); 
     21my $foo_clone = $foo.clone(); 
     22ok($foo_clone ~~ Foo, '... smartmatch our $foo_clone to the Foo class'); 
    2323 
    2424# L<S12/"Classes" /An \"isa\" is just a trait that happens to be another class\:/>