Skip to content

Commit

Permalink
Improvise ghost methods documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aakp10 committed Sep 28, 2020
1 parent c112e1b commit 1c9ddc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions prusti-contracts/src/ghost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ macro_rules! implement_ghost_type_generic {
_type: PhantomData<T>
}
impl <T: Ghost> $ghost_type<T> {
/// Constructor for generic ghost types.
/// #Examples
/// ```rust
/// let seq_inst: GhostSeq<GhostInt> = GhostSeq::new();
/// ```
Expand Down Expand Up @@ -74,6 +76,8 @@ impl Not for GhostBool {
implement_ghost_type_generic!(GhostSeq);
// wrappers around standard operations on GhostSeq
impl<T: Ghost> GhostSeq<T> {
/// Push an item of type `T` to the ghost sequence
/// #Examples
/// ```rust
/// let seq: GhostSeq<i32> = GhostSeq::new();
/// seq.push(10);
Expand All @@ -82,6 +86,8 @@ impl<T: Ghost> GhostSeq<T> {
GhostSeq::new()
}

/// Pop an item from a ghost sequence instance
/// #Examples
/// ```rust
/// let seq: GhostSeq<i32> = GhostSeq::new();
/// seq.push(10);
Expand All @@ -91,9 +97,11 @@ impl<T: Ghost> GhostSeq<T> {
GhostSeq::new()
}

/// Concatenate two instances of ghost sequence
/// #Examples
/// ```rust
/// let seq1: GhostSeq<i32> = GhostSeq::new();
/// seq1.append(seq2);
/// seq1.chain(seq2);
/// ```
pub fn chain(self, other: GhostSeq<T>) -> Self {
GhostSeq::new()
Expand Down Expand Up @@ -144,4 +152,4 @@ impl<T: Ghost> GhostMultiSet<T> {
pub fn has_element(self, element: T) -> GhostBool {
GhostBool
}
}
}
2 changes: 1 addition & 1 deletion prusti-viper/src/encoder/type_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl<'p, 'v, 'r: 'v, 'tcx: 'v> TypeEncoder<'p, 'v, 'tcx> {
}

fn is_ghost_adt(ghost_adt_def: &ty::AdtDef, item_name: String) -> Option<String> {
// check if Crate: prusti_contracts and Module: ghost
// check if crate is "prusti_contracts" and module is "ghost"
let item_name: Vec<&str> = item_name.split("::").collect();
let crate_name = item_name[0];
let mod_name = item_name[1];
Expand Down

0 comments on commit 1c9ddc1

Please sign in to comment.