summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-24 09:46:07 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-05-24 09:46:07 +0000
commit3fa79790e617d87584598746296e626e0ce3b256 (patch)
treedcdc926130d9ed8d302eedf8215d065c0e787eed /common
parent285d908c5dbd90bff7f03618c7a9e0fa5e287c94 (diff)
Refactoring: move symbol_offset into Genv.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2503 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'common')
-rw-r--r--common/Globalenvs.v17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/Globalenvs.v b/common/Globalenvs.v
index 4e155e3..3b077e0 100644
--- a/common/Globalenvs.v
+++ b/common/Globalenvs.v
@@ -102,6 +102,16 @@ Record t: Type := mkgenv {
Definition find_symbol (ge: t) (id: ident) : option block :=
PTree.get id ge.(genv_symb).
+(** [symbol_address ge id ofs] returns a pointer into the block associated
+ with [id], at byte offset [ofs]. [Vundef] is returned if no block is associated
+ to [id]. *)
+
+Definition symbol_address (ge: t) (id: ident) (ofs: int) : val :=
+ match find_symbol ge id with
+ | Some b => Vptr b ofs
+ | None => Vundef
+ end.
+
(** [find_funct_ptr ge b] returns the function description associated with
the given address. *)
@@ -267,6 +277,13 @@ End GLOBALENV_PRINCIPLES.
(** ** Properties of the operations over global environments *)
+Theorem shift_symbol_address:
+ forall ge id ofs n,
+ symbol_address ge id (Int.add ofs n) = Val.add (symbol_address ge id ofs) (Vint n).
+Proof.
+ intros. unfold symbol_address. destruct (find_symbol ge id); auto.
+Qed.
+
Theorem find_funct_inv:
forall ge v f,
find_funct ge v = Some f -> exists b, v = Vptr b Int.zero.