Changeset 4060 for src/Pugs/Internals.hs

Show
Ignore:
Timestamp:
05/28/05 17:32:25 (4 years ago)
Author:
iblech
svk:copy_cache_prev:
5515
Message:

Pugs.Prim, Pugs.Internals, Pugs.Run: safemode.
If the environment variable %*ENV<PUGS_SAFEMODE> is set to "true", the prims
marked as "unsafe" in the big table of Pugs.Prim are not imported into the pad,
so they can't be used.
Autrijus: The simple substitution of runEvalIO to runEvalSTM isn't so simple as
we've thought, as there're many places where unsafePerformIO is used (e.g. in
the parser)...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Internals.hs

    r3981 r4060  
    7070    possiblyFixOperatorName, 
    7171    maybeM, 
     72    safeMode, 
    7273) where 
    7374 
     
    274275    dropBrackets ('<':(rest@(_:_)))       = if (last rest) == '>' then init rest else '<':rest 
    275276    dropBrackets x                        = x 
     277 
     278{-| 
     279Returns @True@ if the environment variable @PUGS_SAFEMODE@ is set to @true@. In 
     280safemode, most IO prims are forbidden. 
     281-} 
     282safeMode :: Bool 
     283safeMode = case (unsafePerformIO $ getEnv "PUGS_SAFEMODE") of 
     284    Just "true" -> True 
     285    _           -> False