read from streams.
This commit is contained in:
@@ -2,6 +2,7 @@ use prolog_parser::ast::*;
|
||||
|
||||
use prolog::machine::machine_indices::*;
|
||||
|
||||
use std::mem;
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
pub struct Heap {
|
||||
@@ -21,6 +22,17 @@ impl Heap {
|
||||
self.h += 1;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn take(&mut self) -> Self {
|
||||
let h = self.h;
|
||||
self.h = 0;
|
||||
|
||||
Heap {
|
||||
heap: mem::replace(&mut self.heap, vec![]),
|
||||
h
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn truncate(&mut self, h: usize) {
|
||||
self.h = h;
|
||||
|
||||
Reference in New Issue
Block a user