remove string/1, use a more general test for the partial_string/1 type test (#328)

This commit is contained in:
Mark Thom
2020-04-11 22:47:52 -06:00
parent 0499005db5
commit 4f0adad78e
5 changed files with 17 additions and 39 deletions

View File

@@ -75,7 +75,6 @@ pub enum InlinedClauseType {
IsCompound(RegType), IsCompound(RegType),
IsInteger(RegType), IsInteger(RegType),
IsRational(RegType), IsRational(RegType),
IsString(RegType),
IsFloat(RegType), IsFloat(RegType),
IsNonVar(RegType), IsNonVar(RegType),
IsVar(RegType), IsVar(RegType),
@@ -105,7 +104,6 @@ ref_thread_local! {
m.insert(("compound", 1), ClauseType::Inlined(InlinedClauseType::IsCompound(r1))); m.insert(("compound", 1), ClauseType::Inlined(InlinedClauseType::IsCompound(r1)));
m.insert(("integer", 1), ClauseType::Inlined(InlinedClauseType::IsInteger(r1))); m.insert(("integer", 1), ClauseType::Inlined(InlinedClauseType::IsInteger(r1)));
m.insert(("rational", 1), ClauseType::Inlined(InlinedClauseType::IsRational(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(("float", 1), ClauseType::Inlined(InlinedClauseType::IsFloat(r1)));
m.insert(("nonvar", 1), ClauseType::Inlined(InlinedClauseType::IsNonVar(r1))); m.insert(("nonvar", 1), ClauseType::Inlined(InlinedClauseType::IsNonVar(r1)));
m.insert(("var", 1), ClauseType::Inlined(InlinedClauseType::IsVar(r1))); m.insert(("var", 1), ClauseType::Inlined(InlinedClauseType::IsVar(r1)));
@@ -140,7 +138,6 @@ impl InlinedClauseType {
&InlinedClauseType::IsCompound(..) => "compound", &InlinedClauseType::IsCompound(..) => "compound",
&InlinedClauseType::IsInteger(..) => "integer", &InlinedClauseType::IsInteger(..) => "integer",
&InlinedClauseType::IsRational(..) => "rational", &InlinedClauseType::IsRational(..) => "rational",
&InlinedClauseType::IsString(..) => "string",
&InlinedClauseType::IsFloat(..) => "float", &InlinedClauseType::IsFloat(..) => "float",
&InlinedClauseType::IsNonVar(..) => "nonvar", &InlinedClauseType::IsNonVar(..) => "nonvar",
&InlinedClauseType::IsVar(..) => "var", &InlinedClauseType::IsVar(..) => "var",

View File

@@ -443,18 +443,6 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<TermMarker> {
code.push(fail!()); 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() { &InlinedClauseType::IsNonVar(..) => match terms[0].as_ref() {
&Term::AnonVar => { &Term::AnonVar => {
code.push(fail!()); code.push(fail!());

View File

@@ -2364,14 +2364,16 @@ impl MachineState {
Some(iter.first_to_expire) 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) { match self.store(addr) {
Addr::Usize(b) => self.block = b, Addr::Usize(b) => self.block = b,
_ => self.fail = true, _ => self.fail = true,
}; };
} }
pub(super) fn execute_inlined(&mut self, inlined: &InlinedClauseType) { pub(super)
fn execute_inlined(&mut self, inlined: &InlinedClauseType) {
match inlined { match inlined {
&InlinedClauseType::CompareNumber(cmp, ref at_1, ref at_2) => { &InlinedClauseType::CompareNumber(cmp, ref at_1, ref at_2) => {
let n1 = try_or_fail!(self, self.get_number(at_1)); 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) => { &InlinedClauseType::IsNonVar(r1) => {
let d = self.store(self.deref(self[r1])); let d = self.store(self.deref(self[r1]));

View File

@@ -1196,15 +1196,20 @@ impl MachineState {
} }
} }
&SystemClauseType::IsPartialString => { &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 { while let Some(_) = heap_pstr_iter.next() {}
Addr::PStrLocation(..) => {
self.fail =
match heap_pstr_iter.focus() {
Addr::AttrVar(_) | Addr::HeapCell(_) | Addr::StackCell(..) |
Addr::EmptyList => {
false
} }
_ => { _ => {
self.fail = true; true
}
} }
};
} }
&SystemClauseType::PartialStringTail => { &SystemClauseType::PartialStringTail => {
let pstr = self.store(self.deref(self[temp_v!(1)])); let pstr = self.store(self.deref(self[temp_v!(1)]));

View File

@@ -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 { macro_rules! is_var {
($r:expr) => { ($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsVar($r)), 1, 0) call_clause!(ClauseType::Inlined(InlinedClauseType::IsVar($r)), 1, 0)