Changeset 15296 for src/Pugs/Eval

Show
Ignore:
Timestamp:
02/18/07 15:56:10 (21 months ago)
Author:
audreyt
Message:

* Convert VStr from String to ByteString?, and Syn from

String to ID, in Pugs. Benchmark shows the perf gain is 5%,
so it's not worth the trouble of writing a GHC 6.7-compatible
processor. The next commit will revert this commit.

Files:
1 modified

Legend:

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

    r15242 r15296  
    1 {-# OPTIONS_GHC -fglasgow-exts -cpp -fallow-overlapping-instances -funbox-strict-fields #-} 
     1{-# OPTIONS_GHC -fglasgow-exts -cpp -fallow-overlapping-instances -funbox-strict-fields -foverloaded-strings #-} 
    22 
    33module Pugs.Eval.Var ( 
     
    4343            retError "no such ENV variable" name 
    4444        _           -> do 
    45             rv   <- enterLValue (evalExp $ Syn "{}" [_Var "%*ENV", Val (VStr $ cast name)]) 
     45            rv   <- enterLValue (evalExp $ _Syn "{}" [_Var "%*ENV", Val (VStr $ cast name)]) 
    4646            tvar <- liftSTM . newTVar =<< fromVal rv 
    4747            return (Just tvar) 
     
    9898        vref   <- liftSTM (readTVar tvref) 
    9999        let val = VRef vref 
    100         return (cast key, val) 
     100        return (__(cast key), val) 
    101101    padEntryToHashEntry (_, []) = fail "Nonexistant var in pad?" 
    102102 
     
    466466        meta    <- readRef ref 
    467467        fetch   <- doHash meta hash_fetchVal 
    468         fmap (map (cast :: String -> Pkg)) (fromVal =<< fetch "is") 
     468        fmap (map (cast :: VStr -> Pkg)) (fromVal =<< fetch "is") 
    469469 
    470470{-| 
     
    491491    return $ subReturns sub 
    492492inferExpType (App (Var var) (Just inv) _) 
    493     | var == cast "&new" 
     493    | var == _cast "&new" 
    494494    = inferExpType $ unwrap inv 
    495495inferExpType (App (Var name) invs args) = do 
     
    548548magicalMap :: Map Var (Eval (Maybe Val)) 
    549549magicalMap = Map.fromList 
    550     [ (cast "$?FILE"     , posSym posName) 
    551     , (cast "$?LINE"     , posSym posBeginLine) 
    552     , (cast "$?COLUMN"   , posSym posBeginColumn) 
    553     , (cast "$?POSITION" , posSym pretty) 
    554     , (cast "$?MODULE"   , constSym "Main") 
    555     , (cast "$?OS"       , constSym (getConfig "osname")) 
    556     , (cast "$?CLASS"    , fmap (Just . VType . cast) (asks envPackage)) 
    557     , (cast ":?CLASS"    , fmap (Just . VType . cast) (asks envPackage)) 
    558     , (cast "$?PACKAGE"  , fmap (Just . VType . cast) (asks envPackage)) 
    559     , (cast ":?PACKAGE"  , fmap (Just . VType . cast) (asks envPackage)) 
    560     , (cast "$?ROLE"     , fmap (Just . VType . cast) (asks envPackage)) 
    561     , (cast ":?ROLE"     , fmap (Just . VType . cast) (asks envPackage)) 
     550    [ (_cast "$?FILE"     , posSym posName) 
     551    , (_cast "$?LINE"     , posSym posBeginLine) 
     552    , (_cast "$?COLUMN"   , posSym posBeginColumn) 
     553    , (_cast "$?POSITION" , posSym pretty) 
     554    , (_cast "$?MODULE"   , constSym "Main") 
     555    , (_cast "$?OS"       , constSym (getConfig "osname")) 
     556    , (_cast "$?CLASS"    , fmap (Just . VType . cast) (asks envPackage)) 
     557    , (_cast ":?CLASS"    , fmap (Just . VType . cast) (asks envPackage)) 
     558    , (_cast "$?PACKAGE"  , fmap (Just . VType . cast) (asks envPackage)) 
     559    , (_cast ":?PACKAGE"  , fmap (Just . VType . cast) (asks envPackage)) 
     560    , (_cast "$?ROLE"     , fmap (Just . VType . cast) (asks envPackage)) 
     561    , (_cast ":?ROLE"     , fmap (Just . VType . cast) (asks envPackage)) 
    562562    ] 
    563563 
     
    566566 
    567567constSym :: String -> Eval (Maybe Val) 
    568 constSym = return . Just . VStr 
     568constSym = return . Just . _VStr 
    569569 
    570570findSyms :: Var -> Eval [(Var, Val)]