Changeset 16625

Show
Ignore:
Timestamp:
06/03/07 21:24:28 (18 months ago)
Author:
gaal
Message:

* separate internals functions for loading yaml strings and files

Location:
src/Pugs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim.hs

    r16597 r16625  
    303303        Perl5ErrorString str    -> fail str 
    304304        Perl5ErrorObject err    -> throwError (PerlSV err) 
    305 op1 "Pugs::Internals::eval_p6y" = op1EvalP6Y 
     305op1 "Pugs::Internals::evalfile_p6y" = op1EvalFileP6Y 
     306op1 "Pugs::Internals::eval_p6y"     = op1EvalP6Y 
    306307op1 "Pugs::Internals::eval_haskell" = op1EvalHaskell 
    307308op1 "Pugs::Internals::eval_yaml" = evalYaml 
     
    19441945\\n   Any       pre     Pugs::Internals::eval_haskell unsafe (Str)\ 
    19451946\\n   Any       pre     Pugs::Internals::eval_p6y unsafe (Str)\ 
     1947\\n   Any       pre     Pugs::Internals::evalfile_p6y unsafe (Str)\ 
    19461948\\n   Any       pre     Pugs::Internals::eval_yaml    safe   (Str)\ 
    19471949\\n   Any       pre     Pugs::Internals::emit_yaml    unsafe   (rw!Any)\ 
  • src/Pugs/Prim/Eval.hs

    r16373 r16625  
    22module Pugs.Prim.Eval ( 
    33    -- used by Pugs.Prim 
    4     op1EvalHaskell, op1EvalP6Y, 
     4    op1EvalHaskell, op1EvalP6Y, op1EvalFileP6Y, 
    55    opEval, opEvalFile, 
    66    opRequire, requireInc, 
     
    2020import DrIFT.YAML 
    2121import Data.Yaml.Syck 
     22import qualified Data.ByteString.Char8 as Bytes 
     23 
     24type Bytes        = Bytes.ByteString 
    2225 
    2326data EvalError = EvalErrorFatal 
     
    123126                       , evalResult=EvalResultLastValue} 
    124127 
    125 op1EvalP6Y :: Val -> Eval Val 
    126 op1EvalP6Y fileName = do 
     128 
     129op1EvalP6Y, op1EvalFileP6Y :: Val -> Eval Val 
     130 
     131op1EvalFileP6Y fileName = do 
    127132    fileName' <- fromVal fileName 
     133    file      <- io $ Bytes.readFile fileName' 
     134    op1EvalP6Y' file 
     135 
     136op1EvalP6Y bytecode = do 
     137    bytecode' <- fromVal bytecode 
     138    op1EvalP6Y' $ Bytes.pack bytecode' -- XXX: is this the right pack function? 
     139 
     140op1EvalP6Y' :: Bytes -> Eval Val 
     141op1EvalP6Y' bytecode = do 
    128142    yml  <- io $ (`catchIO` (return . Left . show)) $ 
    129         fmap Right (parseYamlFile fileName') 
     143        fmap Right (parseYamlBytes bytecode) 
    130144    case yml of 
    131145        Right MkNode{ n_elem=ESeq (v:_) } 
    132146            | MkNode{ n_elem=EStr vnum } <- v 
    133147            , vnum /= (packBuf $ show compUnitVersion) -> do 
    134                 err "incompatible version number for compilation unit" 
     148                err $ "incompatible version number for compilation unit: found " ++ 
     149                    unpackBuf vnum ++ ", expecting " ++ (show compUnitVersion) 
    135150        Right yml' -> do 
    136151            globTVar    <- asks envGlobal