Changeset 3956

Show
Ignore:
Timestamp:
05/27/05 04:31:40 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
5515
Message:

* new callconv -- pugs apply now takes Cxt

Location:
src
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Run/Perl5.hs

    r3948 r3956  
    99import Pugs.Prim.Eval 
    1010import Pugs.Embed.Perl5 
     11import Pugs.Types 
    1112import Foreign 
    1213import Foreign.C.Types 
     
    1819 
    1920foreign export ccall "pugs_Apply" 
    20     pugs_apply :: PugsVal -> PugsVal -> Ptr PugsVal -> IO PerlSV 
     21    pugs_apply :: PugsVal -> PugsVal -> Ptr PugsVal -> CInt -> IO PerlSV 
    2122 
    2223foreign export ccall "pugs_ValToSv" 
     
    6061    mkVal val 
    6162 
    62 pugs_apply :: PugsVal -> PugsVal -> Ptr PugsVal -> IO PerlSV 
    63 pugs_apply subPtr invPtr argsPtr = do 
     63pugs_apply :: PugsVal -> PugsVal -> Ptr PugsVal -> CInt -> IO PerlSV 
     64pugs_apply subPtr invPtr argsPtr cxt = do 
    6465    -- print "DEREF #0" 
    6566    env     <- askPerl5Env 
     
    7475            VStr name   -> Var name 
    7576            _           -> Val sub 
    76     val <- runEvalIO env $ evalExp (App subExp (fmap Val inv) (map Val args)) 
     77    val <- runEvalIO env $ 
     78        evalExp (Cxt (cxtEnum cxt) $ App subExp (fmap Val inv) (map Val args)) 
    7779    case val of 
    7880        PerlSV sv   -> return sv 
  • src/Pugs/Types.hs

    r3887 r3956  
    8181enumCxt (CxtSlurpy _) = 1 
    8282 
     83cxtEnum :: (Show a, Num a) => a -> Cxt 
     84cxtEnum 128 = CxtVoid 
     85cxtEnum 0   = cxtItemAny 
     86cxtEnum 1   = cxtSlurpyAny 
     87cxtEnum n   = error ("Invalid cxt: " ++ show n) 
     88 
    8389-- |Make a type value representing the type with the specified name. 
    8490-- Recognises conjunctive (&) and disjunctive (|) types. 
  • src/perl5/perl5.c

    r3955 r3956  
    5252    stack[i-2] = NULL; 
    5353     
    54     ST(0) = pugs_Apply(val, inv, stack); 
     54    ST(0) = pugs_Apply(val, inv, stack, GIMME_V); 
    5555    sv_dump (ret); 
    5656    free (stack); 
  • src/perl5/pugsembed.c

    r3948 r3956  
    2323    isa[0] = pugs_PvToVal("Code"); 
    2424    isa[1] = NULL; 
    25     if (SvTRUE(pugs_Apply(pugs_PvToVal("&isa"), val, isa))) { 
     25    if (SvTRUE(pugs_Apply(pugs_PvToVal("&isa"), val, isa, G_SCALAR))) { 
    2626        if (__init) { 
    2727            stack[0] = sv; 
  • src/perl5/pugsembed.h

    r3948 r3956  
    88 
    99extern Val *pugs_Eval ( char *code ); 
    10 extern SV *pugs_Apply ( Val *sub, Val *inv, Val **args ); 
     10extern SV *pugs_Apply ( Val *sub, Val *inv, Val **args, int cxt ); 
    1111 
    1212extern Val *pugs_IvToVal ( IV iv );