remove string/1, use a more general test for the partial_string/1 type test (#328)
This commit is contained in:
@@ -75,7 +75,6 @@ pub enum InlinedClauseType {
|
||||
IsCompound(RegType),
|
||||
IsInteger(RegType),
|
||||
IsRational(RegType),
|
||||
IsString(RegType),
|
||||
IsFloat(RegType),
|
||||
IsNonVar(RegType),
|
||||
IsVar(RegType),
|
||||
@@ -105,7 +104,6 @@ ref_thread_local! {
|
||||
m.insert(("compound", 1), ClauseType::Inlined(InlinedClauseType::IsCompound(r1)));
|
||||
m.insert(("integer", 1), ClauseType::Inlined(InlinedClauseType::IsInteger(r1)));
|
||||
m.insert(("rational", 1), ClauseType::Inlined(InlinedClauseType::IsRational(r1)));
|
||||
m.insert(("string", 1), ClauseType::Inlined(InlinedClauseType::IsString(r1)));
|
||||
m.insert(("float", 1), ClauseType::Inlined(InlinedClauseType::IsFloat(r1)));
|
||||
m.insert(("nonvar", 1), ClauseType::Inlined(InlinedClauseType::IsNonVar(r1)));
|
||||
m.insert(("var", 1), ClauseType::Inlined(InlinedClauseType::IsVar(r1)));
|
||||
@@ -140,7 +138,6 @@ impl InlinedClauseType {
|
||||
&InlinedClauseType::IsCompound(..) => "compound",
|
||||
&InlinedClauseType::IsInteger(..) => "integer",
|
||||
&InlinedClauseType::IsRational(..) => "rational",
|
||||
&InlinedClauseType::IsString(..) => "string",
|
||||
&InlinedClauseType::IsFloat(..) => "float",
|
||||
&InlinedClauseType::IsNonVar(..) => "nonvar",
|
||||
&InlinedClauseType::IsVar(..) => "var",
|
||||
|
||||
@@ -443,18 +443,6 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<TermMarker> {
|
||||
code.push(fail!());
|
||||
}
|
||||
},
|
||||
&InlinedClauseType::IsString(..) => match terms[0].as_ref() {
|
||||
&Term::Constant(_, Constant::String(..)) => {
|
||||
code.push(succeed!());
|
||||
}
|
||||
&Term::Var(ref vr, ref name) => {
|
||||
let r = self.mark_non_callable(name.clone(), 1, term_loc, vr, code);
|
||||
code.push(is_string!(r));
|
||||
}
|
||||
_ => {
|
||||
code.push(fail!());
|
||||
}
|
||||
},
|
||||
&InlinedClauseType::IsNonVar(..) => match terms[0].as_ref() {
|
||||
&Term::AnonVar => {
|
||||
code.push(fail!());
|
||||
|
||||
@@ -2364,14 +2364,16 @@ impl MachineState {
|
||||
Some(iter.first_to_expire)
|
||||
}
|
||||
|
||||
pub(super) fn reset_block(&mut self, addr: Addr) {
|
||||
pub(super)
|
||||
fn reset_block(&mut self, addr: Addr) {
|
||||
match self.store(addr) {
|
||||
Addr::Usize(b) => self.block = b,
|
||||
_ => self.fail = true,
|
||||
};
|
||||
}
|
||||
|
||||
pub(super) fn execute_inlined(&mut self, inlined: &InlinedClauseType) {
|
||||
pub(super)
|
||||
fn execute_inlined(&mut self, inlined: &InlinedClauseType) {
|
||||
match inlined {
|
||||
&InlinedClauseType::CompareNumber(cmp, ref at_1, ref at_2) => {
|
||||
let n1 = try_or_fail!(self, self.get_number(at_1));
|
||||
@@ -2466,14 +2468,6 @@ impl MachineState {
|
||||
}
|
||||
};
|
||||
}
|
||||
&InlinedClauseType::IsString(r1) => {
|
||||
let d = self.store(self.deref(self[r1]));
|
||||
|
||||
match d {
|
||||
Addr::PStrLocation(..) => self.p += 1,
|
||||
_ => self.fail = true,
|
||||
};
|
||||
}
|
||||
&InlinedClauseType::IsNonVar(r1) => {
|
||||
let d = self.store(self.deref(self[r1]));
|
||||
|
||||
|
||||
@@ -1196,15 +1196,20 @@ impl MachineState {
|
||||
}
|
||||
}
|
||||
&SystemClauseType::IsPartialString => {
|
||||
let pstr = self.store(self.deref(self[temp_v!(1)]));
|
||||
let mut heap_pstr_iter = self.heap_pstr_iter(self[temp_v!(1)]);
|
||||
|
||||
match pstr {
|
||||
Addr::PStrLocation(..) => {
|
||||
}
|
||||
_ => {
|
||||
self.fail = true;
|
||||
}
|
||||
}
|
||||
while let Some(_) = heap_pstr_iter.next() {}
|
||||
|
||||
self.fail =
|
||||
match heap_pstr_iter.focus() {
|
||||
Addr::AttrVar(_) | Addr::HeapCell(_) | Addr::StackCell(..) |
|
||||
Addr::EmptyList => {
|
||||
false
|
||||
}
|
||||
_ => {
|
||||
true
|
||||
}
|
||||
};
|
||||
}
|
||||
&SystemClauseType::PartialStringTail => {
|
||||
let pstr = self.store(self.deref(self[temp_v!(1)]));
|
||||
|
||||
@@ -225,12 +225,6 @@ macro_rules! is_nonvar {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! is_string {
|
||||
($r:expr) => {
|
||||
call_clause!(ClauseType::Inlined(InlinedClauseType::IsString($r)), 1, 0)
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! is_var {
|
||||
($r:expr) => {
|
||||
call_clause!(ClauseType::Inlined(InlinedClauseType::IsVar($r)), 1, 0)
|
||||
|
||||
Reference in New Issue
Block a user