@@ -425,10 +425,8 @@ withStackTraceFrame str val =
425425 withStackTraceFrame str `fmap` doProofScript m
426426 in
427427 VProofScript m'
428- VDo _pos _env _stmts ->
429- -- Blah. Let's just ignore it for now... XXX.
430- -- (but with luck we'll be able to throw this code out before anyone cares)
431- val
428+ VDo pos _ env stmts ->
429+ VDo pos (Just str) env stmts
432430 VBindOnce v1 v2 ->
433431 let v1' = withStackTraceFrame str v1
434432 v2' = withStackTraceFrame str v2
@@ -515,7 +513,7 @@ interpretExpr expr =
515513 VArray <$> traverse interpretExpr es
516514 SS. Block pos stmts -> do
517515 env <- getLocalEnv
518- return $ VDo pos env stmts
516+ return $ VDo pos Nothing env stmts
519517 SS. Tuple _ es ->
520518 VTuple <$> traverse interpretExpr es
521519 SS. Record _ bs ->
@@ -622,8 +620,8 @@ interpretStmts stmts =
622620 -- (or whichever value for whichever monad)
623621 let v'' :: m Value = return v'
624622 return $ mkValue v''
625- VDo _blkpos env stmts' ->
626- withLocalEnvAny env (interpretStmts stmts')
623+ VDo _blkpos mname env stmts' ->
624+ withLocalEnvAny env (interpretStmts' mname stmts')
627625 VBindOnce m1 v2 -> do
628626 v1 <- actionFromValue m1
629627 m2 <- liftTopLevel $ applyValue " Value in a VBindOnce, via force" v2 v1
@@ -689,6 +687,20 @@ interpretStmts stmts =
689687 let env' = LocalTypedef (getVal name) ty : env
690688 withLocalEnv env' (interpretStmts ss)
691689
690+ -- Wrapper around interpretStmts for inserting a stack trace frame, in the
691+ -- old style. XXX remove along with the old stack trace code...
692+ interpretStmts' :: InterpreterMonad m => Maybe String -> [SS. Stmt ] -> m Value
693+ interpretStmts' mname stmts = do
694+ trace <- liftTopLevel $ gets rwStackTrace
695+ case mname of
696+ Nothing -> pure ()
697+ Just name -> liftTopLevel $ modify (\ rw -> rw { rwStackTrace = name : trace })
698+ v <- interpretStmts stmts
699+ case mname of
700+ Nothing -> pure ()
701+ Just _ -> liftTopLevel $ modify (\ rw -> rw { rwStackTrace = trace })
702+ return v
703+
692704-- Execute a top-level bind.
693705processStmtBind ::
694706 InterpreterMonad m =>
@@ -1025,8 +1037,8 @@ instance IsValue a => IsValue (TopLevel a) where
10251037instance FromValue a => FromValue (TopLevel a ) where
10261038 fromValue (VTopLevel action) = fmap fromValue action
10271039 fromValue (VReturn v) = return (fromValue v)
1028- fromValue (VDo _pos env stmts) = do
1029- v <- withLocalEnv env (interpretStmts stmts)
1040+ fromValue (VDo _pos mname env stmts) = do
1041+ v <- withLocalEnv env (interpretStmts' mname stmts)
10301042 fromValue v
10311043 fromValue (VBindOnce m1 v2) = do
10321044 v1 <- fromValue m1
@@ -1044,8 +1056,8 @@ instance FromValue a => FromValue (ProofScript a) where
10441056 -- the type system should keep this from happening.
10451057 fromValue (VTopLevel m) = ProofScript (lift (lift (fmap fromValue m)))
10461058 fromValue (VReturn v) = return (fromValue v)
1047- fromValue (VDo _pos env stmts) = do
1048- v <- withLocalEnvProof env (interpretStmts stmts)
1059+ fromValue (VDo _pos mname env stmts) = do
1060+ v <- withLocalEnvProof env (interpretStmts' mname stmts)
10491061 fromValue v
10501062 fromValue (VBindOnce m1 v2) = ProofScript $ do
10511063 v1 <- unProofScript (fromValue m1)
@@ -1059,8 +1071,8 @@ instance IsValue a => IsValue (LLVMCrucibleSetupM a) where
10591071instance FromValue a => FromValue (LLVMCrucibleSetupM a ) where
10601072 fromValue (VLLVMCrucibleSetup m) = fmap fromValue m
10611073 fromValue (VReturn v) = return (fromValue v)
1062- fromValue (VDo _pos env stmts) = do
1063- v <- withLocalEnvLLVM env (interpretStmts stmts)
1074+ fromValue (VDo _pos mname env stmts) = do
1075+ v <- withLocalEnvLLVM env (interpretStmts' mname stmts)
10641076 fromValue v
10651077 fromValue (VBindOnce m1 v2) = LLVMCrucibleSetupM $ do
10661078 v1 <- runLLVMCrucibleSetupM (fromValue m1)
@@ -1074,8 +1086,8 @@ instance IsValue a => IsValue (JVMSetupM a) where
10741086instance FromValue a => FromValue (JVMSetupM a ) where
10751087 fromValue (VJVMSetup m) = fmap fromValue m
10761088 fromValue (VReturn v) = return (fromValue v)
1077- fromValue (VDo _pos env stmts) = do
1078- v <- withLocalEnvJVM env (interpretStmts stmts)
1089+ fromValue (VDo _pos mname env stmts) = do
1090+ v <- withLocalEnvJVM env (interpretStmts' mname stmts)
10791091 fromValue v
10801092 fromValue (VBindOnce m1 v2) = JVMSetupM $ do
10811093 v1 <- runJVMSetupM (fromValue m1)
@@ -1089,8 +1101,8 @@ instance IsValue a => IsValue (MIRSetupM a) where
10891101instance FromValue a => FromValue (MIRSetupM a ) where
10901102 fromValue (VMIRSetup m) = fmap fromValue m
10911103 fromValue (VReturn v) = return (fromValue v)
1092- fromValue (VDo _pos env stmts) = do
1093- v <- withLocalEnvMIR env (interpretStmts stmts)
1104+ fromValue (VDo _pos mname env stmts) = do
1105+ v <- withLocalEnvMIR env (interpretStmts' mname stmts)
10941106 fromValue v
10951107 fromValue (VBindOnce m1 v2) = MIRSetupM $ do
10961108 v1 <- runMIRSetupM (fromValue m1)
0 commit comments