deallocate old stack frames (#201), start using tags, fix a panic! associated with partial strings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "scryer-prolog"
|
||||
version = "0.8.109"
|
||||
version = "0.8.110"
|
||||
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
||||
build = "build.rs"
|
||||
repository = "https://github.com/mthom/scryer-prolog"
|
||||
|
||||
@@ -66,6 +66,11 @@ impl AndStack {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn truncate(&mut self, len: usize) {
|
||||
self.0.truncate(len);
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<usize> for AndStack {
|
||||
|
||||
@@ -419,11 +419,12 @@ pub(crate) trait CallPolicy: Any {
|
||||
machine_st.registers[i] = machine_st.or_stack[b][i].clone();
|
||||
}
|
||||
|
||||
// necessary because of restore_snapshot. similarly for other choice instructions.
|
||||
machine_st.num_of_args = n;
|
||||
machine_st.e = machine_st.or_stack[b].e;
|
||||
machine_st.cp = machine_st.or_stack[b].cp.clone();
|
||||
|
||||
machine_st.pop_stack_frames();
|
||||
|
||||
machine_st.or_stack[b].bp = machine_st.p.clone() + offset;
|
||||
|
||||
let old_tr = machine_st.or_stack[b].tr;
|
||||
@@ -468,6 +469,8 @@ pub(crate) trait CallPolicy: Any {
|
||||
machine_st.e = machine_st.or_stack[b].e;
|
||||
machine_st.cp = machine_st.or_stack[b].cp.clone();
|
||||
|
||||
machine_st.pop_stack_frames();
|
||||
|
||||
machine_st.or_stack[b].bp = machine_st.p.clone() + 1;
|
||||
|
||||
let old_tr = machine_st.or_stack[b].tr;
|
||||
@@ -539,6 +542,8 @@ pub(crate) trait CallPolicy: Any {
|
||||
machine_st.b = machine_st.or_stack[b].b;
|
||||
machine_st.or_stack.truncate(machine_st.b);
|
||||
|
||||
machine_st.pop_stack_frames();
|
||||
|
||||
machine_st.hb = machine_st.heap.h;
|
||||
machine_st.p += offset;
|
||||
|
||||
@@ -584,6 +589,8 @@ pub(crate) trait CallPolicy: Any {
|
||||
machine_st.b = machine_st.or_stack[b].b;
|
||||
machine_st.or_stack.truncate(machine_st.b);
|
||||
|
||||
machine_st.pop_stack_frames();
|
||||
|
||||
machine_st.hb = machine_st.heap.h;
|
||||
machine_st.p += 1;
|
||||
|
||||
|
||||
@@ -1860,8 +1860,12 @@ impl MachineState {
|
||||
let offset = match addr {
|
||||
Addr::HeapCell(_) | Addr::StackCell(..) | Addr::AttrVar(..) => v,
|
||||
Addr::Con(Constant::String(ref s)) if !self.flags.double_quotes.is_atom() => {
|
||||
if s.is_empty() && !s.is_expandable() {
|
||||
if s.is_empty() {
|
||||
if s.is_expandable() {
|
||||
v
|
||||
} else {
|
||||
c
|
||||
}
|
||||
} else {
|
||||
l
|
||||
}
|
||||
@@ -3147,6 +3151,21 @@ impl MachineState {
|
||||
self.p += 1;
|
||||
}
|
||||
|
||||
pub(super) fn pop_stack_frames(&mut self) {
|
||||
if self.and_stack.len() > self.e {
|
||||
let and_gi = self.and_stack[self.e].global_index;
|
||||
let or_gi = self
|
||||
.or_stack
|
||||
.top()
|
||||
.map(|or_fr| or_fr.global_index)
|
||||
.unwrap_or(0);
|
||||
|
||||
if and_gi > or_gi {
|
||||
self.and_stack.truncate(self.e + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_call_clause(
|
||||
&mut self,
|
||||
indices: &mut IndexStore,
|
||||
|
||||
Reference in New Issue
Block a user