This module combines multiple External Core modules into
a single module, including both datatype and value definitions.
-}
-module Language.Core.Merge(merge) where
+module Language.Core.Merge(merge,uniqueNamesIn,nonUniqueNamesIn) where
import Language.Core.Core
import Language.Core.CoreUtils
-}
uniqueNamesIn :: [Vdef] -> [Tdef] -> [Qual Var]
uniqueNamesIn topBinds allTdefs = res
+ where vars = vdefNamesQ topBinds
+ dcons = tdefDcons allTdefs
+ tcons = tdefTcons allTdefs
+ uniqueVars = vars \\ dupsUnqual vars
+ uniqueDcons = dcons \\ dupsUnqual dcons
+ uniqueTcons = tcons \\ dupsUnqual tcons
+ res = uniqueVars ++ uniqueDcons ++ uniqueTcons
+
+nonUniqueNamesIn :: [Vdef] -> [Tdef] -> [Qual Var]
+nonUniqueNamesIn topBinds allTdefs = dupsUnqual allNames
where allNames = vdefNamesQ topBinds ++ tdefNames allTdefs
- dups = dupsUnqual allNames
- res = allNames \\ dups
-
+
-- This takes each top-level name of the form Foo.Bar.blah and
-- renames it to FoozuBarzublah (note we *don't* make it exported!
-- This is so we know which names were in the original program and
-- We don't alter unqualified names, since we just need to make sure
-- everything can go in the Main module.
fixupName _ _ vr@(Nothing,_) = vr
--- Nor do we alter anything defined in the Main module
--- or in the primitive or Bool modules
--- (because we basically treat the Bool type as primitive.)
+-- Nor do we alter anything defined in the Main module or the primitive module.
fixupName _ _ vr@(Just mn, _) | mn == mainMname || mn == wrapperMainMname ||
- mn == primMname || mn == boolMname = vr
+ mn == primMname = vr
-- For a variable that is defined by only one module in scope, we
-- give it a name that is just its unqualified name, without the original
-- module and package names.