+mkSRT :: CLabel -> [Id] -> [Id] -> Code
+mkSRT lbl [] these = nopC
+mkSRT lbl ids these
+ = mapFCs remap ids `thenFC` \ ids ->
+ absC (CSRT lbl (map (mkClosureLabel . idName) ids))
+ where
+ -- sigh, better map all the ids against the environment in case they've
+ -- been globalised (see maybeGlobaliseId below).
+ remap id = case filter (==id) these of
+ [] -> getCAddrModeAndInfo id
+ `thenFC` \ (id, _, _) -> returnFC id
+ (id':_) -> returnFC id'
+
+-- if we're splitting the object, we need to globalise all the top-level names
+-- (and then make sure we only use the globalised one in any C label we use
+-- which refers to this name).
+maybeGlobaliseId :: Id -> FCode Id
+maybeGlobaliseId id
+ = moduleName `thenFC` \ mod ->
+ let
+ name = idName id
+
+ -- globalise the name for -split-objs, if necessary
+ real_name | opt_EnsureSplittableC = globaliseName name mod
+ | otherwise = name
+
+ id' = setIdName id real_name
+ in
+ returnFC id'
+
+maybeSplitCode
+ | opt_EnsureSplittableC = CSplitMarker
+ | otherwise = AbsCNop