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

Show
Ignore:
Timestamp:
07/12/05 08:42:04 (3 years ago)
Author:
gaal
svk:copy_cache_prev:
7349
Message:

* require Bar; require Bar only loads Bar once

Files:
1 modified

Legend:

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

    r5170 r5466  
    1616import Pugs.Config 
    1717import Pugs.Run.Args 
     18import Pugs.Prim.Keyed 
    1819 
    1920data EvalError = EvalErrorFatal 
     
    3334    file        <- fromVal v 
    3435    incs        <- fromVal =<< readVar "@*INC" 
    35     pathName    <- requireInc incs file (errMsg file incs) 
    36     -- %*INC{file} = pathname 
    37     evalExp $ Syn "=" 
    38         [ Syn "{}" 
    39             [ Var "%*INC", Val . VStr $ decodeUTF8 file ] 
    40             , Val . VStr $ decodeUTF8 pathName 
    41         ] 
    42     str         <- liftIO $ readFile pathName 
    43     opEval style pathName (decodeUTF8 str) 
     36    glob        <- askGlobal 
     37    seen        <- findSymRef "%*INC" glob 
     38    loaded      <- existsFromRef seen v 
     39    if (loaded) then (return $ VInt 1) else do -- XXX: SPECME: what do we return here? 
     40        pathName <- requireInc incs file (errMsg file incs) 
     41        -- %*INC{file} = pathname 
     42        evalExp $ Syn "=" 
     43            [ Syn "{}" 
     44                [ Var "%*INC", Val . VStr $ decodeUTF8 file ] 
     45                , Val . VStr $ decodeUTF8 pathName 
     46            ] 
     47        str         <- liftIO $ readFile pathName 
     48        opEval style pathName (decodeUTF8 str) 
    4449    where 
    4550    style = MkEvalStyle