Files
mercury/tests/hard_coded
Peter Wang bab9106220 Fix codegen for subtype field names in high-level data grades.
Fix a bug where the compiler generated incorrect code in C# and Java
grades when a subtype type definition did not repeat the field names of
its base type. Subtypes use the same data represention with their base
type, so in target code we must use the names of fields from the
base type instead of the subtype.

compiler/hlds_data.m:
    Add a field to ctor_arg_repn to tell if a constructor argument
    belongs to a subtype, and if so, the field name of the corresponding
    constructor argument in the base type (if any).

compiler/du_type_layout.m:
    Fill in the field appropriately for the ctor_arg_repn of a subtype
    constructor argument.

    Rename predicates which only deal with non-subtype du types,
    for clarity.

    Conform to changes elsewhere.

compiler/ml_code_util.m:
    Make ml_gen_hld_field_name use the field name from the base type
    if generating the field name for a subtype constructor argument.

compiler/ml_type_gen.m:
    Pass MaybeBaseTypeCtor to ml_gen_hld_field_name.

compiler/add_special_pred.m:
compiler/equiv_type_hlds.m:
compiler/hlds_out_type_table.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_util.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/type_ctor_info.m:
    Conform to changes.

compiler/mlds.m:
    Add comment.

compiler/tag_switch_util.m:
    Delete comment about the bug that this change fixes.

tests/hard_coded/Mmakefile:
tests/hard_coded/subtype_field_names.exp:
tests/hard_coded/subtype_field_names.m:
    Add test case.

NEWS.md:
    Announce change.
2024-05-02 12:32:39 +10:00
..
2023-07-01 02:25:53 +10:00
2023-07-22 23:24:54 +10:00
2024-03-16 23:31:09 +11:00
2024-03-16 23:31:09 +11:00