CallAttributeGoals,
CharCode,
CharsToNumber,
+ CloneAttributeGoals,
CodesToNumber,
CopyTermWithoutAttrVars,
CheckCutPoint,
&SystemClauseType::CallAttributeGoals => clause_name!("$call_attribute_goals"),
&SystemClauseType::CharCode => clause_name!("$char_code"),
&SystemClauseType::CharsToNumber => clause_name!("$chars_to_number"),
+ &SystemClauseType::CloneAttributeGoals => clause_name!("$clone_attribute_goals"),
&SystemClauseType::CodesToNumber => clause_name!("$codes_to_number"),
&SystemClauseType::CopyTermWithoutAttrVars => clause_name!("$copy_term_without_attr_vars"),
&SystemClauseType::CheckCutPoint => clause_name!("$check_cp"),
("$call_attribute_goals", 2) => Some(SystemClauseType::CallAttributeGoals),
("$char_code", 2) => Some(SystemClauseType::CharCode),
("$chars_to_number", 2) => Some(SystemClauseType::CharsToNumber),
+ ("$clone_attribute_goals", 1) => Some(SystemClauseType::CloneAttributeGoals),
("$codes_to_number", 2) => Some(SystemClauseType::CodesToNumber),
("$copy_term_without_attr_vars", 2) => Some(SystemClauseType::CopyTermWithoutAttrVars),
("$check_cp", 1) => Some(SystemClauseType::CheckCutPoint),
term_variables(Source, Vars),
gather_modules(Vars, Modules, _),
call_attribute_goals(Modules, call_query_var_goals, Vars),
- '$fetch_attribute_goals'(Goals0),
+ '$clone_attribute_goals'(Goals0),
'$copy_term_without_attr_vars'([Source | Goals0], [Dest | Goals]).
Ok(())
}
+ fn fetch_attribute_goals(&mut self, mut attr_goals: Vec<Addr>) {
+ attr_goals.sort_unstable_by(|a1, a2| self.compare_term_test(a1, a2));
+ self.term_dedup(&mut attr_goals);
+
+ let attr_goals = Addr::HeapCell(self.heap.to_list(attr_goals.into_iter()));
+ let target = self[temp_v!(1)].clone();
+
+ self.unify(attr_goals, target);
+ }
+
fn create_instruction_functors(&mut self, code: &Code, first_idx: usize) -> Vec<Addr> {
let mut queue = VecDeque::new();
let mut functors = vec![];
for i in (arity + 1 .. arity + narity + 1).rev() {
self.registers[i] = self.registers[i - arity].clone();
}
-
+
for i in 1 .. arity + 1 {
self.registers[i] = self.heap[a + i].as_addr(a + i);
}
);
}
}
- Addr::Con(Constant::Atom(name, _)) => {
+ Addr::Con(Constant::Atom(name, _)) => {
return self.module_lookup(indices, (name, narity), module_name, true)
}
addr => {
&SystemClauseType::TruncateIfNoLiftedHeapGrowth => {
self.truncate_if_no_lifted_heap_diff(|_| Addr::Con(Constant::EmptyList))
}
+ &SystemClauseType::CloneAttributeGoals => {
+ let attr_goals = self.attr_var_init.attribute_goals.clone();
+ self.fetch_attribute_goals(attr_goals);
+ }
&SystemClauseType::FetchAttributeGoals => {
- let mut attr_goals = self.attr_var_init.attribute_goals.clone();
-
- attr_goals.sort_unstable_by(|a1, a2| self.compare_term_test(a1, a2));
- self.term_dedup(&mut attr_goals);
-
- let attr_goals = Addr::HeapCell(self.heap.to_list(attr_goals.into_iter()));
- let target = self[temp_v!(1)].clone();
-
- self.unify(attr_goals, target);
+ let attr_goals = mem::replace(&mut self.attr_var_init.attribute_goals, vec![]);
+ self.fetch_attribute_goals(attr_goals);
}
&SystemClauseType::GetAttributedVariableList => {
let attr_var = self.store(self.deref(self[temp_v!(1)].clone()));
let var_list_addr = Addr::HeapCell(self.heap.to_list(iter));
let list_addr = self[temp_v!(2)].clone();
-
+
self.unify(var_list_addr, list_addr);
} else {
self.fail = true;
ContinueResult::ContinueQuery => ';',
ContinueResult::Conclude => '.'
};
-
+
let target = self[temp_v!(1)].clone();
self.unify(Addr::Con(Constant::Char(c)), target);
}