Skip to content

Commit

Permalink
"print" command now uses the current ascii mode and number base.
Browse files Browse the repository at this point in the history
Fixes #28 and fixes #29.
  • Loading branch information
Brian Huffman committed Aug 3, 2015
1 parent d72c220 commit af16997
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/SAWScript/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import Cryptol.TypeCheck.PP (ppWithNames)
import Cryptol.TypeCheck.Solve (defaultReplExpr)
import Cryptol.TypeCheck.Subst (apSubst, listSubst)
import Cryptol.Utils.PP
import qualified Cryptol.Eval.Value as V (defaultPPOpts, ppValue)
import qualified Cryptol.Eval.Value as V (defaultPPOpts, ppValue, PPOpts(..))

import qualified Text.PrettyPrint.ANSI.Leijen as PP

Expand Down Expand Up @@ -346,8 +346,14 @@ print_value (VTerm t) = do
unless (null (getAllExts (ttTerm t))) $
fail "term contains symbolic variables"
t' <- io $ defaultTypedTerm sc cfg t
io $ rethrowEvalError $ print $ V.ppValue V.defaultPPOpts (evaluateTypedTerm sc t')
print_value v = io $ putStrLn (showsPrecValue defaultPPOpts 0 v "")
opts <- fmap rwPPOpts getTopLevelRW
let opts' = V.defaultPPOpts { V.useAscii = ppOptsAscii opts
, V.useBase = ppOptsBase opts
}
io $ rethrowEvalError $ print $ V.ppValue opts' (evaluateTypedTerm sc t')
print_value v = do
opts <- fmap rwPPOpts getTopLevelRW
io $ putStrLn (showsPrecValue opts 0 v "")

rethrowEvalError :: IO a -> IO a
rethrowEvalError m = run `X.catch` rethrow
Expand Down

0 comments on commit af16997

Please sign in to comment.