summaryrefslogtreecommitdiff
path: root/compiler/deSugar
diff options
context:
space:
mode:
authorFacundo Domínguez <facundo.dominguez@tweag.io>2017-02-07 18:55:34 -0300
committerFacundo Domínguez <facundo.dominguez@tweag.io>2017-02-09 08:11:57 -0300
commitb9bebd8cedccd7e8dd6df89b5504cd8f1e7a675b (patch)
treee68affa56ec2a8d169c2a4d9639052c5ea66ee5e /compiler/deSugar
parentafaf6d58f2c1b131eecee65d69d5dfbf10dc1b0b (diff)
downloadhaskell-b9bebd8cedccd7e8dd6df89b5504cd8f1e7a675b.tar.gz
Implement addCStub in template-haskell.
Summary: addCStub allows injecting C code in the current module to be included in the final object file. Test Plan: ./validate Reviewers: simonpj, goldfire, austin, bgamari Reviewed By: bgamari Subscribers: bitonic, duncan, mboes, thomie Differential Revision: https://phabricator.haskell.org/D3106
Diffstat (limited to 'compiler/deSugar')
-rw-r--r--compiler/deSugar/Desugar.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/deSugar/Desugar.hs b/compiler/deSugar/Desugar.hs
index 1cd7979128..5111141770 100644
--- a/compiler/deSugar/Desugar.hs
+++ b/compiler/deSugar/Desugar.hs
@@ -289,6 +289,7 @@ deSugar hsc_env
tcg_imp_specs = imp_specs,
tcg_dependent_files = dependent_files,
tcg_ev_binds = ev_binds,
+ tcg_th_cstubs = th_cstubs_var,
tcg_fords = fords,
tcg_rules = rules,
tcg_vects = vects,
@@ -373,6 +374,9 @@ deSugar hsc_env
-- past desugaring. See Note [Identity versus semantic module].
; MASSERT( id_mod == mod )
+ ; cstubs <- readIORef th_cstubs_var
+ ; let ds_fords' = foldl' appendStubC ds_fords (map text cstubs)
+
; let mod_guts = ModGuts {
mg_module = mod,
mg_hsc_src = hsc_src,
@@ -393,7 +397,7 @@ deSugar hsc_env
mg_patsyns = patsyns,
mg_rules = ds_rules_for_imps,
mg_binds = ds_binds,
- mg_foreign = ds_fords,
+ mg_foreign = ds_fords',
mg_hpc_info = ds_hpc_info,
mg_modBreaks = modBreaks,
mg_vect_decls = ds_vects,