Skip to content

Commit ae9c73a

Browse files
committed
Test different uninterpreted name resolution scheme
1 parent 7bef2d9 commit ae9c73a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/SAWScript/Builtins.hs

+11-11
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ printGoalSize =
464464
resolveNames :: [String] -> TopLevel (Set VarIndex)
465465
resolveNames nms =
466466
do sc <- getSharedContext
467-
Set.fromList <$> mapM (resolveName sc) nms
467+
Set.fromList . mconcat <$> mapM (resolveName sc) nms
468468

469469
-- | Given a user-provided name, resolve it to some
470470
-- 'ExtCns' that represents an unfoldable 'Constant'
@@ -477,9 +477,10 @@ resolveNames nms =
477477
-- maps to an 'ExtCns', then instead directly look it up
478478
-- in the SAWCore naming environment. If both stages
479479
-- fail, then throw an exception.
480-
resolveName :: SharedContext -> String -> TopLevel VarIndex
480+
resolveName :: SharedContext -> String -> TopLevel [VarIndex]
481481
resolveName sc nm =
482482
do cenv <- rwCryptol <$> getTopLevelRW
483+
scnms <- fmap fst <$> io (scResolveName sc tnm)
483484
let ?fileReader = StrictBS.readFile
484485
res <- io $ CEnv.resolveIdentifier cenv tnm
485486
case res of
@@ -489,14 +490,13 @@ resolveName sc nm =
489490
ImportedName uri _ ->
490491
do resolvedName <- io $ scResolveNameByURI sc uri
491492
case resolvedName of
492-
Just vi -> pure vi
493-
Nothing -> fallback
494-
_ -> fallback
495-
Nothing -> fallback
493+
Just vi -> pure $ vi:scnms
494+
Nothing -> pure scnms
495+
_ -> pure scnms
496+
Nothing -> pure scnms
496497

497498
where
498499
tnm = Text.pack nm
499-
fallback = fst <$> io (scResolveUnambiguous sc tnm)
500500

501501

502502
normalize_term :: TypedTerm -> TopLevel TypedTerm
@@ -506,7 +506,7 @@ normalize_term_opaque :: [String] -> TypedTerm -> TopLevel TypedTerm
506506
normalize_term_opaque opaque tt =
507507
do sc <- getSharedContext
508508
modmap <- io (scGetModuleMap sc)
509-
idxs <- mapM (resolveName sc) opaque
509+
idxs <- mconcat <$> mapM (resolveName sc) opaque
510510
let opaqueSet = Set.fromList idxs
511511
tm' <- io (TM.normalizeSharedTerm sc modmap mempty mempty opaqueSet (ttTerm tt))
512512
pure tt{ ttTerm = tm' }
@@ -557,11 +557,11 @@ extract_uninterp ::
557557
TopLevel (TypedTerm, [(String,[(TypedTerm,TypedTerm)])])
558558
extract_uninterp unints opaques tt =
559559
do sc <- getSharedContext
560-
idxs <- mapM (resolveName sc) unints
560+
idxs <- mconcat <$> mapM (resolveName sc) unints
561561
let unintSet = Set.fromList idxs
562562
mmap <- io (scGetModuleMap sc)
563563

564-
opaqueSet <- Set.fromList <$> mapM (resolveName sc) opaques
564+
opaqueSet <- Set.fromList . mconcat <$> mapM (resolveName sc) opaques
565565

566566
boundECRef <- io (newIORef Set.empty)
567567
let ?recordEC = \ec -> modifyIORef boundECRef (Set.insert ec)
@@ -1036,7 +1036,7 @@ rewritePrim ss (TypedTerm schema t) = do
10361036
unfold_term :: [String] -> TypedTerm -> TopLevel TypedTerm
10371037
unfold_term unints (TypedTerm schema t) = do
10381038
sc <- getSharedContext
1039-
unints' <- mapM (resolveName sc) unints
1039+
unints' <- mconcat <$> mapM (resolveName sc) unints
10401040
t' <- io $ scUnfoldConstants sc unints' t
10411041
return (TypedTerm schema t')
10421042

0 commit comments

Comments
 (0)