diff options
| author | Alasdair | 2018-08-18 01:23:02 +0100 |
|---|---|---|
| committer | Alasdair | 2018-08-18 01:25:06 +0100 |
| commit | 3414ffbc4d62f5cb019def6a6e9931319ac1ffa7 (patch) | |
| tree | 4b703f42d6ede80a889f4016812aefa3f8353435 /src/bytecode_util.ml | |
| parent | 79176c7ac58900c95db5db9cf75978e91e9a453c (diff) | |
Correctly handle specialising polymorphic types in nested unions
Ensure that this works even when the union types are dependent in the wrong order, before topologically sorting definitions. We do this by calling fix_variant_ctyps on all cdefs by passing a list of
prior cdefs to specialize_variants.
Diffstat (limited to 'src/bytecode_util.ml')
| -rw-r--r-- | src/bytecode_util.ml | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bytecode_util.ml b/src/bytecode_util.ml index fa41e1e1..4320e945 100644 --- a/src/bytecode_util.ml +++ b/src/bytecode_util.ml @@ -626,6 +626,11 @@ let cdef_map_instr f = function | CDEF_spec (id, ctyps, ctyp) -> CDEF_spec (id, ctyps, ctyp) | CDEF_type tdef -> CDEF_type tdef +let ctype_def_map_ctyp f = function + | CTD_enum (id, ids) -> CTD_enum (id, ids) + | CTD_struct (id, ctors) -> CTD_struct (id, List.map (fun (field, ctyp) -> (field, f ctyp)) ctors) + | CTD_variant (id, ctors) -> CTD_variant (id, List.map (fun (field, ctyp) -> (field, f ctyp)) ctors) + (** Map over each ctyp in a cdef using map_instr_ctyp *) let cdef_map_ctyp f = function | CDEF_reg_dec (id, ctyp, instrs) -> CDEF_reg_dec (id, f ctyp, List.map (map_instr_ctyp f) instrs) @@ -634,7 +639,7 @@ let cdef_map_ctyp f = function | CDEF_startup (id, instrs) -> CDEF_startup (id, List.map (map_instr_ctyp f) instrs) | CDEF_finish (id, instrs) -> CDEF_finish (id, List.map (map_instr_ctyp f) instrs) | CDEF_spec (id, ctyps, ctyp) -> CDEF_spec (id, List.map f ctyps, f ctyp) - | CDEF_type tdef -> CDEF_type tdef (* FIXME *) + | CDEF_type tdef -> CDEF_type (ctype_def_map_ctyp f tdef) (* Map over all sequences of instructions contained within an instruction *) let rec map_instrs f (I_aux (instr, aux)) = |
