aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend/PrintClight.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/PrintClight.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/PrintClight.ml')
-rw-r--r--cfrontend/PrintClight.ml25
1 files changed, 13 insertions, 12 deletions
diff --git a/cfrontend/PrintClight.ml b/cfrontend/PrintClight.ml
index 7b9f3d35..0e8b4949 100644
--- a/cfrontend/PrintClight.ml
+++ b/cfrontend/PrintClight.ml
@@ -249,7 +249,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;@ @ "
@@ -259,6 +259,11 @@ let print_fundef p (id, fd) =
| Internal f ->
print_function p id f
+let print_globdef p (id, gd) =
+ match gd with
+ | Gfun f -> print_fundef p id f
+ | Gvar v -> print_globvar p id v (* from PrintCsyntax *)
+
(* Collect struct and union types *)
let rec collect_expr e =
@@ -307,17 +312,14 @@ let collect_function f =
List.iter (fun (id, ty) -> collect_type ty) f.fn_temps;
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
@@ -338,8 +340,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