pub fn project_onto_key(&mut self, value: HeapCellValue) -> Result<HeapCellValue, MachineStub> {
        let stub_gen = || functor_stub(atom!("keysort"), 2);
        let store_v = self.store(self.deref(value));

        if store_v.is_var() {
            let err = self.instantiation_error();
            return Err(self.error_form(err, stub_gen()));
        }

        read_heap_cell!(store_v,
            (HeapCellValueTag::Str, s) => {
                let (name, arity) = cell_as_atom_cell!(self.heap[s]).get_name_and_arity();

                if name == atom!("-") && arity == 2 {
                    Ok(heap_loc_as_cell!(s + 1))
                } else {
                    let err = self.type_error(ValidType::Pair, self.heap[s]);
                    Err(self.error_form(err, stub_gen()))
                }
            }
            _ => {
                let err = self.type_error(ValidType::Pair, store_v);
                Err(self.error_form(err, stub_gen()))
            }
        )
    }
// see 8.4.4.3 of Draft Technical Corrigendum 2 for an error guide.
see 8.4.4.3 of Draft Technical Corrigendum 2 for an error guide.
see 8 . 4 . 4 . 3 of Draft Technical Corrigendum 2 for an error guide .
pub fn project_onto_key(&mut self, value: HeapCellValue) -> Result<HeapCellValue, MachineStub> {
        let stub_gen = || functor_stub(atom!("keysort"), 2);
        let store_v = self.store(self.deref(value));
        if store_v.is_var() {
            let err = self.instantiation_error();
            return Err(self.error_form(err, stub_gen()));
        }
        read_heap_cell!(store_v,
            (HeapCellValueTag::Str, s) => {
                let (name, arity) = cell_as_atom_cell!(self.heap[s]).get_name_and_arity();
                if name == atom!("-") && arity == 2 {
                    Ok(heap_loc_as_cell!(s + 1))
                } else {
                    let err = self.type_error(ValidType::Pair, self.heap[s]);
                    Err(self.error_form(err, stub_gen()))
                }
            }
            _ => {
                let err = self.type_error(ValidType::Pair, store_v);
                Err(self.error_form(err, stub_gen()))
            }
        )
    }
pub fn project_onto_key ( & mut self , value : HeapCellValue ) -> Result < HeapCellValue , MachineStub > { let stub_gen = | | functor_stub ( atom ! ( " " ) , 2 ) ; let store_v = self . store ( self . deref ( value ) ) ; if store_v . is_var ( ) { let err = self . instantiation_error ( ) ; return Err ( self . error_form ( err , stub_gen ( ) ) ) ; } read_heap_cell ! ( store_v ( HeapCellValueTag Str s ) { let ( name arity ) cell_as_atom_cell ( self heap [ s ] ) get_name_and_arity ( ) if name atom ( " " ) arity 2 { Ok ( heap_loc_as_cell ( s 1 ) ) } else { let err self type_error ( ValidType Pair self heap [ s ] ) Err ( self error_form ( err stub_gen ( ) ) ) } } { let err self type_error ( ValidType Pair store_v ) Err ( self error_form ( err stub_gen ( ) ) ) } ) }
see 8.4.4.3 of Draft Technical Corrigendum 2 for an error guide.
see 8 . 4 . 4 . 3 of Draft Technical Corrigendum 2 for an error guide .
&mut self
value
HeapCellValue
&mut self
value
HeapCellValue