Enum in Obc should also be qualnames
This commit is contained in:
parent
3d02b85bd6
commit
0b12e6a4ae
4 changed files with 8 additions and 6 deletions
|
@ -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 }
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue