From 3fa79790e617d87584598746296e626e0ce3b256 Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 24 May 2014 09:46:07 +0000 Subject: Refactoring: move symbol_offset into Genv. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2503 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- common/Globalenvs.v | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'common') 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. -- cgit v1.2.3