pub fn construct_canonical_state(&self) -> Self {
        let mut values = BTreeMap::new();
        let mut references = BTreeMap::new();
        Self::split_locals(&self.locals, &mut values, &mut references);

        let mut locals = BTreeMap::new();
        let mut nonce_map = BTreeMap::new();
        for (idx, nonce) in references {
            nonce_map.insert(nonce, Nonce::new(idx as usize));
            locals.insert(idx, AbstractValue::Reference(Nonce::new(idx as usize)));
        }
        for (idx, (kind, nonce_set)) in values {
            locals.insert(
                idx,
                AbstractValue::Value(kind, Self::map_nonce_set(&nonce_map, &nonce_set)),
            );
        }
        let mut globals = BTreeMap::new();
        for (idx, nonce_set) in &self.globals {
            globals.insert(idx.clone(), Self::map_nonce_set(&nonce_map, &nonce_set));
        }
        let mut borrows = BTreeMap::new();
        for (nonce, borrow_info) in &self.borrows {
            match borrow_info {
                BorrowInfo::BorrowedBy(borrowed_by) => {
                    borrows.insert(
                        nonce_map[&nonce],
                        BorrowInfo::BorrowedBy(Self::map_nonce_set(&nonce_map, &borrowed_by)),
                    );
                }
                BorrowInfo::FieldsBorrowedBy(fields_borrowed_by) => {
                    let mut index_to_nonce_set = BTreeMap::new();
                    for (idx, nonce_set) in fields_borrowed_by {
                        index_to_nonce_set
                            .insert(idx.clone(), Self::map_nonce_set(&nonce_map, &nonce_set));
                    }
                    borrows.insert(
                        nonce_map[&nonce],
                        BorrowInfo::FieldsBorrowedBy(index_to_nonce_set),
                    );
                }
            }
        }
        let partition = self.partition.construct_canonical_partition(&nonce_map);

        AbstractState {
            locals,
            globals,
            borrows,
            partition,
        }
    }
/// returns the canonical representation of self
returns the canonical representation of self
returns the canonical representation of self
pub fn construct_canonical_state(&self) -> Self {
        let mut values = BTreeMap::new();
        let mut references = BTreeMap::new();
        Self::split_locals(&self.locals, &mut values, &mut references);
        let mut locals = BTreeMap::new();
        let mut nonce_map = BTreeMap::new();
        for (idx, nonce) in references {
            nonce_map.insert(nonce, Nonce::new(idx as usize));
            locals.insert(idx, AbstractValue::Reference(Nonce::new(idx as usize)));
        }
        for (idx, (kind, nonce_set)) in values {
            locals.insert(
                idx,
                AbstractValue::Value(kind, Self::map_nonce_set(&nonce_map, &nonce_set)),
            );
        }
        let mut globals = BTreeMap::new();
        for (idx, nonce_set) in &self.globals {
            globals.insert(idx.clone(), Self::map_nonce_set(&nonce_map, &nonce_set));
        }
        let mut borrows = BTreeMap::new();
        for (nonce, borrow_info) in &self.borrows {
            match borrow_info {
                BorrowInfo::BorrowedBy(borrowed_by) => {
                    borrows.insert(
                        nonce_map[&nonce],
                        BorrowInfo::BorrowedBy(Self::map_nonce_set(&nonce_map, &borrowed_by)),
                    );
                }
                BorrowInfo::FieldsBorrowedBy(fields_borrowed_by) => {
                    let mut index_to_nonce_set = BTreeMap::new();
                    for (idx, nonce_set) in fields_borrowed_by {
                        index_to_nonce_set
                            .insert(idx.clone(), Self::map_nonce_set(&nonce_map, &nonce_set));
                    }
                    borrows.insert(
                        nonce_map[&nonce],
                        BorrowInfo::FieldsBorrowedBy(index_to_nonce_set),
                    );
                }
            }
        }
        let partition = self.partition.construct_canonical_partition(&nonce_map);
        AbstractState {
            locals,
            globals,
            borrows,
            partition,
        }
    }
pub fn construct_canonical_state ( & self ) -> Self { let mut values = BTreeMap :: new ( ) ; let mut references = BTreeMap :: new ( ) ; Self :: split_locals ( & self . locals , & mut values , & mut references ) ; let mut locals = BTreeMap :: new ( ) ; let mut nonce_map = BTreeMap :: new ( ) ; for ( idx , nonce ) in references { nonce_map . insert ( nonce , Nonce :: new ( idx as usize ) ) ; locals . insert ( idx , AbstractValue :: Reference ( Nonce :: new ( idx as usize ) ) ) ; } for ( idx , ( kind , nonce_set ) ) in values { locals . insert ( idx , AbstractValue :: Value ( kind , Self :: map_nonce_set ( & nonce_map , & nonce_set ) ) , ) ; } let mut globals = BTreeMap :: new ( ) ; for ( idx , nonce_set ) in & self . globals { globals . insert ( idx . clone ( ) , Self :: map_nonce_set ( & nonce_map , & nonce_set ) ) ; } let mut borrows = BTreeMap :: new ( ) ; for ( nonce , borrow_info ) in & self . borrows { match borrow_info { BorrowInfo :: BorrowedBy ( borrowed_by ) => { borrows . insert ( nonce_map [ & nonce ] , BorrowInfo :: BorrowedBy ( Self :: map_nonce_set ( & nonce_map , & borrowed_by ) ) , ) ; } BorrowInfo :: FieldsBorrowedBy ( fields_borrowed_by ) => { let mut index_to_nonce_set = BTreeMap :: new ( ) ; for ( idx , nonce_set ) in fields_borrowed_by { index_to_nonce_set . insert ( idx . clone ( ) , Self :: map_nonce_set ( & nonce_map , & nonce_set ) ) ; } borrows . insert ( nonce_map [ & nonce ] , BorrowInfo :: FieldsBorrowedBy ( index_to_nonce_set ) , ) ; } } } let partition = self . partition . construct_canonical_partition ( & nonce_map ) ; AbstractState { locals , globals , borrows , partition , } }
returns the canonical representation of self
returns the canonical representation of self
&self