Skip to content

Commit aa4297e

Browse files
authored
Merge pull request #1804 from GaloisInc/heapster/frame-def
Heapster: Generate definitions for recursive function frames
2 parents c5c4051 + e4b37c0 commit aa4297e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

heapster-saw/src/Verifier/SAW/Heapster/SAWTranslation.hs

+15-4
Original file line numberDiff line numberDiff line change
@@ -5142,6 +5142,11 @@ lrtsOpenTerm lrts =
51425142
(ctorOpenTerm "Prelude.Nil1" [tp])
51435143
lrts
51445144

5145+
-- | Make the type @List1 LetRecType@ of recursive function frames
5146+
frameTypeOpenTerm :: OpenTerm
5147+
frameTypeOpenTerm = dataTypeOpenTerm "Prelude.List1" [dataTypeOpenTerm
5148+
"Prelude.LetRecType" []]
5149+
51455150
-- | FIXME HERE NOW: docs
51465151
tcTranslateAddCFGs ::
51475152
HasPtrWidth w => SharedContext -> ModuleName -> PermEnv -> ChecksFlag ->
@@ -5164,16 +5169,22 @@ tcTranslateAddCFGs sc mod_name env checks endianness dlevel cfgs_and_perms =
51645169
("With type:\n" ++ permPrettyString emptyPPInfo fun_perm) $
51655170
tcCFG ?ptrWidth tmp_env1 endianness dlevel fun_perm cfg
51665171

5167-
-- Next, generate a list of all the LetRecTypes in all of the functions,
5168-
-- along with a list of indices into that list of where the LRTs of each
5169-
-- function are in that list
5172+
-- Next, generate a frame, i.e., a list of all the LetRecTypes in all of the
5173+
-- functions, along with a list of indices into that list of where the LRTs
5174+
-- of each function are in that list, and make a definition for the frame
51705175
let gen_lrts_ixs (i::Natural) (SomeTypedCFG _ _ tcfg : tcfgs') =
51715176
let lrts = translateCFGLRTs env tcfg in
51725177
(i, lrts) : gen_lrts_ixs (i + fromIntegral (length lrts)) tcfgs'
51735178
gen_lrts_ixs _ [] = []
51745179
let (fun_ixs, lrtss) = unzip $ gen_lrts_ixs 0 tcfgs
51755180
let lrts = concat lrtss
5176-
let frame = lrtsOpenTerm lrts
5181+
frame_tm <- completeNormOpenTerm sc $ lrtsOpenTerm lrts
5182+
let frame_ident =
5183+
mkSafeIdent mod_name (someCFGAndPermToName (head cfgs_and_perms)
5184+
++ "__frame")
5185+
frame_tp <- completeNormOpenTerm sc frameTypeOpenTerm
5186+
scInsertDef sc mod_name frame_ident frame_tp frame_tm
5187+
let frame = globalOpenTerm frame_ident
51775188
let stack = singleFunStack frame
51785189

51795190
-- Now, generate a SAW core tuple of all the bodies of mutually recursive

0 commit comments

Comments
 (0)