generate module-level expansion code along with rest of module code
This commit is contained in:
@@ -920,7 +920,17 @@ fn compile_work_impl(
|
||||
mut indices: IndexStore,
|
||||
mut results: GatherResult,
|
||||
) -> Result<(), SessionError> {
|
||||
let mut module_code = compiler.generate_code(
|
||||
if let Some(ref mut module) = &mut compiler.module {
|
||||
// compile the module-level goal and term expansions and store
|
||||
// their locations to the module's code_dir.
|
||||
let decls = module.take_local_expansions();
|
||||
|
||||
if !decls.is_empty() {
|
||||
results.worker_results.extend(decls.into_iter());
|
||||
}
|
||||
}
|
||||
|
||||
let module_code = compiler.generate_code(
|
||||
results.worker_results,
|
||||
wam,
|
||||
&mut indices.code_dir,
|
||||
@@ -972,16 +982,6 @@ fn compile_work_impl(
|
||||
wam.indices.use_module(&mut wam.code_repo, wam.machine_st.flags, &module)?;
|
||||
wam.indices.insert_module(module);
|
||||
} else {
|
||||
// compile the module-level goal and term expansions and store
|
||||
// their locations to the module's code_dir.
|
||||
let offset = module_code.len() + toplvl_code.len();
|
||||
let decls = module.take_local_expansions();
|
||||
|
||||
if !decls.is_empty() {
|
||||
let code = compiler.generate_code(decls, &wam, &mut indices.code_dir, offset)?;
|
||||
module_code.extend(code.into_iter());
|
||||
}
|
||||
|
||||
add_module_code(wam, module, module_code, indices);
|
||||
}
|
||||
|
||||
|
||||
@@ -3080,14 +3080,15 @@ impl MachineState {
|
||||
| (
|
||||
HeapCellValue::Addr(v1 @ Addr::StackCell(..)),
|
||||
HeapCellValue::Addr(v2 @ Addr::HeapCell(_)),
|
||||
) => match (var_pairs.get(&v1).cloned(), var_pairs.get(&v2).cloned()) {
|
||||
(Some(ref v2_p), Some(ref v1_p)) if *v1_p == v1 && *v2_p == v2 => continue,
|
||||
(Some(_), _) | (_, Some(_)) => return true,
|
||||
(None, None) => {
|
||||
var_pairs.insert(v1.clone(), v2.clone());
|
||||
var_pairs.insert(v2, v1);
|
||||
}
|
||||
},
|
||||
) =>
|
||||
match (var_pairs.get(&v1).cloned(), var_pairs.get(&v2).cloned()) {
|
||||
(Some(ref v2_p), Some(ref v1_p)) if *v1_p == v1 && *v2_p == v2 => continue,
|
||||
(Some(_), _) | (_, Some(_)) => return true,
|
||||
(None, None) => {
|
||||
var_pairs.insert(v1.clone(), v2.clone());
|
||||
var_pairs.insert(v2, v1);
|
||||
}
|
||||
},
|
||||
(HeapCellValue::Addr(a1), HeapCellValue::Addr(a2)) => {
|
||||
if a1 != a2 {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user