treat functors with PI '.'/2 as lists (#1570)
This commit is contained in:
@@ -1466,17 +1466,20 @@ impl<I: Indexer> CodeOffsets<I> {
|
|||||||
atom_tbl: &mut AtomTable,
|
atom_tbl: &mut AtomTable,
|
||||||
) {
|
) {
|
||||||
match optimal_arg {
|
match optimal_arg {
|
||||||
|
&Term::Clause(_, atom!("."), ref terms) if terms.len() == 2 => {
|
||||||
|
clause_index_info.opt_arg_index_key = OptArgIndexKey::List(self.optimal_index, 0);
|
||||||
|
self.index_list(index);
|
||||||
|
}
|
||||||
|
&Term::Cons(..) | &Term::Literal(_, Literal::String(_)) | &Term::PartialString(..) => {
|
||||||
|
clause_index_info.opt_arg_index_key = OptArgIndexKey::List(self.optimal_index, 0);
|
||||||
|
self.index_list(index);
|
||||||
|
}
|
||||||
&Term::Clause(_, name, ref terms) => {
|
&Term::Clause(_, name, ref terms) => {
|
||||||
clause_index_info.opt_arg_index_key =
|
clause_index_info.opt_arg_index_key =
|
||||||
OptArgIndexKey::Structure(self.optimal_index, 0, name.clone(), terms.len());
|
OptArgIndexKey::Structure(self.optimal_index, 0, name.clone(), terms.len());
|
||||||
|
|
||||||
self.index_structure(name, terms.len(), index);
|
self.index_structure(name, terms.len(), index);
|
||||||
}
|
}
|
||||||
&Term::Cons(..) | &Term::Literal(_, Literal::String(_)) | &Term::PartialString(..) => {
|
|
||||||
clause_index_info.opt_arg_index_key = OptArgIndexKey::List(self.optimal_index, 0);
|
|
||||||
|
|
||||||
self.index_list(index);
|
|
||||||
}
|
|
||||||
&Term::Literal(_, constant) => {
|
&Term::Literal(_, constant) => {
|
||||||
let overlapping_constants = self.index_constant(atom_tbl, constant, index);
|
let overlapping_constants = self.index_constant(atom_tbl, constant, index);
|
||||||
|
|
||||||
|
|||||||
@@ -371,8 +371,14 @@ impl Machine {
|
|||||||
c
|
c
|
||||||
}
|
}
|
||||||
(HeapCellValueTag::Str, st) => {
|
(HeapCellValueTag::Str, st) => {
|
||||||
let arity = cell_as_atom_cell!(self.machine_st.heap[st]).get_arity();
|
let (name, arity) = cell_as_atom_cell!(self.machine_st.heap[st])
|
||||||
if arity == 0 { c } else { s }
|
.get_name_and_arity();
|
||||||
|
|
||||||
|
match (name, arity) {
|
||||||
|
(atom!("."), 2) => l,
|
||||||
|
(_, 0) => c,
|
||||||
|
_ => s,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(HeapCellValueTag::Cons, ptr) => {
|
(HeapCellValueTag::Cons, ptr) => {
|
||||||
match ptr.get_tag() {
|
match ptr.get_tag() {
|
||||||
@@ -2812,6 +2818,19 @@ impl Machine {
|
|||||||
self.machine_st.s_offset = 0;
|
self.machine_st.s_offset = 0;
|
||||||
self.machine_st.mode = MachineMode::Read;
|
self.machine_st.mode = MachineMode::Read;
|
||||||
}
|
}
|
||||||
|
(HeapCellValueTag::Str, s) => {
|
||||||
|
let (name, arity) = cell_as_atom_cell!(self.machine_st.heap[s])
|
||||||
|
.get_name_and_arity();
|
||||||
|
|
||||||
|
if name == atom!(".") && arity == 2 {
|
||||||
|
self.machine_st.s = HeapPtr::HeapCell(s+1);
|
||||||
|
self.machine_st.s_offset = 0;
|
||||||
|
self.machine_st.mode = MachineMode::Read;
|
||||||
|
} else {
|
||||||
|
self.machine_st.backtrack();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
(HeapCellValueTag::Lis, l) => {
|
(HeapCellValueTag::Lis, l) => {
|
||||||
self.machine_st.s = HeapPtr::HeapCell(l);
|
self.machine_st.s = HeapPtr::HeapCell(l);
|
||||||
self.machine_st.s_offset = 0;
|
self.machine_st.s_offset = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user