Changeset 4001 for src/Pugs/Prim/Eval.hs

Show
Ignore:
Timestamp:
05/27/05 22:49:53 (4 years ago)
Author:
iblech
svk:copy_cache_prev:
5515
Message:

* Implement evalfile()
* Added a test for evalfile (t/builtins/evalfile.t).
* Test for nothing() added, too (already in the previous commit, sorry)

(t/builtins/nothing.t).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/Eval.hs

    r3833 r4001  
    22    -- used by Pugs.Prim 
    33    op1EvalHaskell, 
    4     opEval, 
     4    opEval, opEvalfile, 
    55    opRequire, 
    66    -- used by Pugs.Eval -- needs factored somewhere bettwen 
     
    2828                str <- liftIO $ readFile pathName 
    2929                opEval (Just dumpEnv) pathName (decodeUTF8 str) 
     30 
     31opEvalfile :: String -> Eval Val 
     32opEvalfile filename = do 
     33    ok <- liftIO $ doesFileExist filename 
     34    if (not ok) 
     35        then fail $ "Can't locate " ++ filename ++ "." 
     36        else do 
     37            contents <- liftIO $ readFile filename 
     38            opEval Nothing filename $ decodeUTF8 contents 
    3039 
    3140op1EvalHaskell :: Val -> Eval Val