diff options
| author | Alasdair Armstrong | 2020-01-10 18:58:55 +0000 |
|---|---|---|
| committer | Alasdair Armstrong | 2020-01-10 19:48:45 +0000 |
| commit | 1257411d702a12cde9d1aef5cdd85e18307812d9 (patch) | |
| tree | f19b3ebf8fe4088435897cd8b6d4c2cdcd38f016 /src/jib | |
| parent | 8809d3154fcd6950c8cc2abc1a946eb6924f7836 (diff) | |
Don't do any C specific name mangling for the cons operator in jib_compile
Instead handle it specially in c_backend, leaving the type information in the IR available for other consumers
Diffstat (limited to 'src/jib')
| -rw-r--r-- | src/jib/c_backend.ml | 15 | ||||
| -rw-r--r-- | src/jib/jib_compile.ml | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/jib/c_backend.ml b/src/jib/c_backend.ml index e54a2d7a..6809d557 100644 --- a/src/jib/c_backend.ml +++ b/src/jib/c_backend.ml @@ -1418,21 +1418,26 @@ let rec codegen_instr fid ctx (I_aux (instr, (_, l))) = ^^ jump 2 2 (separate_map hardline (codegen_instr fid ctx) instrs) ^^ hardline ^^ string " }" - | I_funcall (x, extern, f, args) -> + | I_funcall (x, special_extern, f, args) -> let c_args = Util.string_of_list ", " sgen_cval args in let ctyp = clexp_ctyp x in - let is_extern = Env.is_extern (fst f) ctx.tc_env "c" || extern in + let is_extern = Env.is_extern (fst f) ctx.tc_env "c" || special_extern in let fname = - if Env.is_extern (fst f) ctx.tc_env "c" then - Env.get_extern (fst f) ctx.tc_env "c" - else if extern then + if special_extern then string_of_id (fst f) + else if Env.is_extern (fst f) ctx.tc_env "c" then + Env.get_extern (fst f) ctx.tc_env "c" else sgen_function_uid f in let fname = match fname, ctyp with | "internal_pick", _ -> Printf.sprintf "pick_%s" (sgen_ctyp_name ctyp) + | "cons", _ -> + begin match snd f with + | [ctyp] -> Util.zencode_string ("cons#" ^ string_of_ctyp ctyp) + | _ -> c_error "cons without specified type" + end | "eq_anything", _ -> begin match args with | cval :: _ -> Printf.sprintf "eq_%s" (sgen_ctyp_name (cval_ctyp cval)) diff --git a/src/jib/jib_compile.ml b/src/jib/jib_compile.ml index 996390c6..c751e2db 100644 --- a/src/jib/jib_compile.ml +++ b/src/jib/jib_compile.ml @@ -410,7 +410,7 @@ let rec compile_aval l ctx = function let gs = ngensym () in let mk_cons aval = let setup, cval, cleanup = compile_aval l ctx aval in - setup @ [ifuncall (CL_id (gs, CT_list ctyp)) (mk_id ("cons#" ^ string_of_ctyp ctyp), []) [cval; V_id (gs, CT_list ctyp)]] @ cleanup + setup @ [iextern (CL_id (gs, CT_list ctyp)) (mk_id "cons", [ctyp]) [cval; V_id (gs, CT_list ctyp)]] @ cleanup in [idecl (CT_list ctyp) gs] @ List.concat (List.map mk_cons (List.rev avals)), |
