Changeset 14489 for src/Pugs/Eval.hs

Show
Ignore:
Timestamp:
10/24/06 17:19:16 (2 years ago)
Author:
audreyt
Message:

* Restore support for:

if EXPR -> $x {

...

}
elsif EXPR -> $x {

...

}
else -> $x {

...

}

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval.hs

    r14483 r14489  
    463463    evalExp $ App (_Var "&Pugs::Internals::but_block") Nothing [obj, block] 
    464464 
    465 reduceSyn name [cond, bodyIf, bodyElse] 
    466     | "if"     <- name = doCond id 
    467     | "unless" <- name = doCond not 
    468     where 
    469     doCond :: (Bool -> Bool) -> Eval Val 
    470     doCond f = do 
    471         vbool     <- enterRValue $ enterEvalContext (cxtItem "Bool") cond 
    472         vb        <- fromVal vbool 
    473         if (f vb) 
    474             then reduce bodyIf 
    475             else reduce bodyElse 
     465reduceSyn "if" [cond, bodyIf, bodyElse] = do 
     466    vbool     <- enterRValue $ enterEvalContext (cxtItem "Bool") cond 
     467    vb        <- fromVal vbool 
     468    reduce $ if vb then bodyIf else bodyElse 
     469 
     470reduceSyn "cond" [cond, bodyIf, bodyElse] = do 
     471    topic <- enterRValue $ enterEvalContext (cxtItem "Bool") cond 
     472    vb    <- fromVal topic 
     473    sub   <- fromCodeExp $ if vb then bodyIf else bodyElse 
     474    apply sub Nothing [App (_Var "&VAR") (Just (Val topic)) []] 
    476475 
    477476reduceSyn "for" [list, body] = enterLoop $ do 
     
    14961495        return $ mkCode 
    14971496            { subEnv        = Just env 
    1498             , subType       = SubBlock 
     1497            , subType       = SubPrim   -- This is a pseudoblock with no scope 
    14991498            , subParams     = [defaultScalarParam] 
    15001499            , subBody       = x 
    15011500            } 
     1501    Noop                        -> fromCodeExp (Syn "block" [Noop]) 
    15021502    _                           -> fromClosure x 
    15031503    where