aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend/PrintCsyntax.ml
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-11-12 13:42:22 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-11-12 13:42:22 +0000
commitce4951549999f403446415c135ad1403a16a15c3 (patch)
treecac9bbb2fea29fce331916b277c38ed8fe29e471 /cfrontend/PrintCsyntax.ml
parentdcb9f48f51cec5e864565862a700c27df2a1a7e6 (diff)
downloadcompcert-kvx-ce4951549999f403446415c135ad1403a16a15c3.tar.gz
compcert-kvx-ce4951549999f403446415c135ad1403a16a15c3.zip
Globalenvs: allocate one-byte block with permissions Nonempty for each
function definition, so that comparisons between function pointers are correctly defined. AST, Globalenvs, and many other files: represent programs as a list of (function or variable) definitions instead of two lists, one for functions and the other for variables. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2067 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend/PrintCsyntax.ml')
-rw-r--r--cfrontend/PrintCsyntax.ml27
1 files changed, 14 insertions, 13 deletions
diff --git a/cfrontend/PrintCsyntax.ml b/cfrontend/PrintCsyntax.ml
index 54903217..78585450 100644
--- a/cfrontend/PrintCsyntax.ml
+++ b/cfrontend/PrintCsyntax.ml
@@ -372,7 +372,7 @@ let print_function p id f =
print_stmt p f.fn_body;
fprintf p "@;<0 -2>}@]@ @ "
-let print_fundef p (id, fd) =
+let print_fundef p id fd =
match fd with
| External(EF_external(_,_), args, res) ->
fprintf p "extern %s;@ @ "
@@ -414,7 +414,7 @@ let print_init p = function
let re_string_literal = Str.regexp "__stringlit_[0-9]+"
-let print_globvar p (id, v) =
+let print_globvar p id v =
let name1 = extern_atom id in
let name2 = if v.gvar_readonly then "const " ^ name1 else name1 in
let name3 = if v.gvar_volatile then "volatile " ^ name2 else name2 in
@@ -439,6 +439,11 @@ let print_globvar p (id, v) =
end;
fprintf p ";@]@ @ "
+let print_globdef p (id, gd) =
+ match gd with
+ | Gfun f -> print_fundef p id f
+ | Gvar v -> print_globvar p id v
+
(* Collect struct and union types *)
let rec collect_type = function
@@ -519,17 +524,14 @@ let collect_function f =
List.iter (fun (id, ty) -> collect_type ty) f.fn_vars;
collect_stmt f.fn_body
-let collect_fundef (id, fd) =
- match fd with
- | External(_, args, res) -> collect_type_list args; collect_type res
- | Internal f -> collect_function f
-
-let collect_globvar (id, v) =
- collect_type v.gvar_info
+let collect_globdef (id, gd) =
+ match gd with
+ | Gfun(External(_, args, res)) -> collect_type_list args; collect_type res
+ | Gfun(Internal f) -> collect_function f
+ | Gvar v -> collect_type v.gvar_info
let collect_program p =
- List.iter collect_globvar p.prog_vars;
- List.iter collect_fundef p.prog_funct
+ List.iter collect_globdef p.prog_defs
let declare_struct_or_union p (name, fld) =
fprintf p "%s;@ @ " name
@@ -550,8 +552,7 @@ let print_program p prog =
fprintf p "@[<v 0>";
StructUnionSet.iter (declare_struct_or_union p) !struct_unions;
StructUnionSet.iter (print_struct_or_union p) !struct_unions;
- List.iter (print_globvar p) prog.prog_vars;
- List.iter (print_fundef p) prog.prog_funct;
+ List.iter (print_globdef p) prog.prog_defs;
fprintf p "@]@."
let destination : string option ref = ref None