read from streams.

This commit is contained in:
Mark Thom
2019-04-13 18:40:17 -06:00
parent ed17867be0
commit ae90554378
25 changed files with 1657 additions and 1318 deletions

View File

@@ -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;