Changeset 14317 for src/Pugs/Eval.hs

Show
Ignore:
Timestamp:
10/17/06 08:24:53 (2 years ago)
Author:
audreyt
svk:copy_cache_prev:
21206
Message:

* Unify "if" and "unless" into the new (Syn "cond") node, which

allows for pointy clauses in conditionals:

if f -> $x {

...

}
elsif g -> $y {

...

}
else -> $z {

...

}

* Bump CompUnit? version; please rm blib6/lib/*.yml before remaking.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval.hs

    r14303 r14317  
    456456    evalExp $ App (_Var "&Pugs::Internals::but_block") Nothing [obj, block] 
    457457 
    458 reduceSyn name [cond, bodyIf, bodyElse] 
    459     | "if"     <- name = doCond id 
    460     | "unless" <- name = doCond not 
    461     where 
    462     doCond :: (Bool -> Bool) -> Eval Val 
    463     doCond f = do 
    464         vbool     <- enterRValue $ enterEvalContext (cxtItem "Bool") cond 
    465         vb        <- fromVal vbool 
    466         if (f vb) 
    467             then reduce bodyIf 
    468             else reduce bodyElse 
     458reduceSyn "if" [cond, bodyIf, bodyElse] = do 
     459    vbool     <- enterRValue $ enterEvalContext (cxtItem "Bool") cond 
     460    vb        <- fromVal vbool 
     461    reduce $ if vb then bodyIf else bodyElse 
     462 
     463reduceSyn "cond" [cond, bodyIf, bodyElse] = do 
     464    topic <- enterRValue $ enterEvalContext (cxtItem "Bool") cond 
     465    vb    <- fromVal topic 
     466    sub   <- fromCodeExp $ if vb then bodyIf else bodyElse 
     467    apply sub Nothing [App (_Var "&VAR") (Just (Val topic)) []] 
    469468 
    470469reduceSyn "for" [list, body] = enterLoop $ do 
     
    14831482        return $ mkCode 
    14841483            { subEnv        = Just env 
    1485             , subType       = SubBlock 
     1484            , subType       = SubPrim   -- This is a pseudoblock with no scope 
    14861485            , subParams     = [defaultScalarParam] 
    14871486            , subBody       = x 
    14881487            } 
     1488    Noop                        -> fromCodeExp (Syn "block" [Noop]) 
    14891489    _                           -> fromClosure x 
    14901490    where