diff --git a/compiler/main/mls2obc.ml b/compiler/main/mls2obc.ml index 9c1d0aa..cf5284d 100644 --- a/compiler/main/mls2obc.ml +++ b/compiler/main/mls2obc.ml @@ -484,8 +484,7 @@ let translate_ty_def { Minils.t_name = name; Minils.t_desc = tdesc; let tdesc = match tdesc with | Minils.Type_abs -> Type_abs | Minils.Type_alias ln -> Type_alias ln - | Minils.Type_enum tag_name_list -> - Type_enum (List.map shortname tag_name_list) + | Minils.Type_enum tag_name_list -> Type_enum tag_name_list | Minils.Type_struct field_ty_list -> Type_struct field_ty_list in { t_name = name; t_desc = tdesc; t_loc = loc } diff --git a/compiler/obc/c/cgen.ml b/compiler/obc/c/cgen.ml index 1c950f9..97464b0 100644 --- a/compiler/obc/c/cgen.ml +++ b/compiler/obc/c/cgen.ml @@ -640,7 +640,7 @@ let decls_of_type_decl otd = | Type_alias ty -> [Cdecl_typedef (ctype_of_otype ty, name)] | Type_enum nl -> let name = !global_name ^ "_" ^ name in - [Cdecl_enum (name, nl); + [Cdecl_enum (name, List.map cname_of_qn nl); Cdecl_function (name ^ "_of_string", Cty_id name, [("s", Cty_ptr Cty_char)]); @@ -667,6 +667,7 @@ let cdefs_and_cdecls_of_type_decl otd = { var_decls = []; block_body = let gen_if t = + let t = cname_of_qn t in let funcall = Cfun_call ("strcmp", [Clhs (Cvar "s"); Cconst (Cstrlit t)]) in let cond = Cbop ("==", funcall, Cconst (Ccint 0)) in @@ -681,6 +682,7 @@ let cdefs_and_cdecls_of_type_decl otd = { var_decls = []; block_body = let gen_clause t = + let t = cname_of_qn t in let fun_call = Cfun_call ("strcpy", [Clhs (Cvar "buf"); Cconst (Cstrlit t)]) in @@ -689,7 +691,8 @@ let cdefs_and_cdecls_of_type_decl otd = Creturn (Clhs (Cvar "buf"))]; } } in ([of_string_fun; to_string_fun], - [Cdecl_enum (name, nl); cdecl_of_cfundef of_string_fun; + [Cdecl_enum (name, List.map cname_of_qn nl); + cdecl_of_cfundef of_string_fun; cdecl_of_cfundef to_string_fun]) | Type_struct fl -> let decls = List.map (fun f -> cname_of_qn f.Signature.f_name, diff --git a/compiler/obc/obc.ml b/compiler/obc/obc.ml index 305243b..e8c061e 100644 --- a/compiler/obc/obc.ml +++ b/compiler/obc/obc.ml @@ -28,7 +28,7 @@ type type_dec = and tdesc = | Type_abs | Type_alias of ty - | Type_enum of name list + | Type_enum of constructor_name list | Type_struct of structure type const_dec = { diff --git a/compiler/obc/obc_printer.ml b/compiler/obc/obc_printer.ml index 7e655cc..04d6bcc 100644 --- a/compiler/obc/obc_printer.ml +++ b/compiler/obc/obc_printer.ml @@ -161,7 +161,7 @@ let print_type_def ff { t_name = name; t_desc = tdesc } = fprintf ff "@[type %a@ = %a@\n@]" print_qualname name print_type ty | Type_enum(tag_name_list) -> fprintf ff "@[type %a = " print_qualname name; - print_list_r print_name "" "|" "" ff tag_name_list; + print_list_r print_qualname "" "|" "" ff tag_name_list; fprintf ff "@\n@]" | Type_struct(f_ty_list) -> fprintf ff "@[type %a = " print_qualname name;