add qualified imports use_module library modules
This commit is contained in:
@@ -760,7 +760,7 @@ impl SystemClauseType {
|
|||||||
("$conclude_load", 1) => Some(SystemClauseType::REPL(REPLCodePtr::ConcludeLoad)),
|
("$conclude_load", 1) => Some(SystemClauseType::REPL(REPLCodePtr::ConcludeLoad)),
|
||||||
("$use_module", 3) => Some(SystemClauseType::REPL(REPLCodePtr::UseModule)),
|
("$use_module", 3) => Some(SystemClauseType::REPL(REPLCodePtr::UseModule)),
|
||||||
("$declare_module", 3) => Some(SystemClauseType::REPL(REPLCodePtr::DeclareModule)),
|
("$declare_module", 3) => Some(SystemClauseType::REPL(REPLCodePtr::DeclareModule)),
|
||||||
("$load_compiled_library", 2) => {
|
("$load_compiled_library", 3) => {
|
||||||
Some(SystemClauseType::REPL(REPLCodePtr::LoadCompiledLibrary))
|
Some(SystemClauseType::REPL(REPLCodePtr::LoadCompiledLibrary))
|
||||||
}
|
}
|
||||||
("$push_load_state_payload", 1) => {
|
("$push_load_state_payload", 1) => {
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ use_module(Module, Exports, Evacuable) :-
|
|||||||
instantiation_error(load/1)
|
instantiation_error(load/1)
|
||||||
; Module = library(Library) ->
|
; Module = library(Library) ->
|
||||||
( path_atom(Library, LibraryPath) ->
|
( path_atom(Library, LibraryPath) ->
|
||||||
( '$load_compiled_library'(LibraryPath, Evacuable) -> %% TODO: What about Exports?
|
( '$load_compiled_library'(LibraryPath, Exports, Evacuable) ->
|
||||||
true
|
true
|
||||||
; '$load_library_as_stream'(LibraryPath, Stream, Path),
|
; '$load_library_as_stream'(LibraryPath, Stream, Path),
|
||||||
file_load(Stream, Path, Subevacuable),
|
file_load(Stream, Path, Subevacuable),
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ fn import_qualified_module_exports(
|
|||||||
exports: &IndexSet<ModuleExport>,
|
exports: &IndexSet<ModuleExport>,
|
||||||
code_dir: &mut CodeDir,
|
code_dir: &mut CodeDir,
|
||||||
op_dir: &mut OpDir,
|
op_dir: &mut OpDir,
|
||||||
|
meta_predicates: &mut MetaPredicateDir,
|
||||||
) -> Result<(), SessionError> {
|
) -> Result<(), SessionError> {
|
||||||
for export in imported_module.module_decl.exports.iter() {
|
for export in imported_module.module_decl.exports.iter() {
|
||||||
if !exports.contains(export) {
|
if !exports.contains(export) {
|
||||||
@@ -245,6 +246,10 @@ fn import_qualified_module_exports(
|
|||||||
ModuleExport::PredicateKey((ref name, arity)) => {
|
ModuleExport::PredicateKey((ref name, arity)) => {
|
||||||
let key = (name.clone(), *arity);
|
let key = (name.clone(), *arity);
|
||||||
|
|
||||||
|
if let Some(meta_specs) = imported_module.meta_predicates.get(&key) {
|
||||||
|
meta_predicates.insert(key.clone(), meta_specs.clone());
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(src_code_index) = imported_module.code_dir.get(&key) {
|
if let Some(src_code_index) = imported_module.code_dir.get(&key) {
|
||||||
let target_code_index = code_dir
|
let target_code_index = code_dir
|
||||||
.entry(key.clone())
|
.entry(key.clone())
|
||||||
@@ -281,6 +286,7 @@ fn import_qualified_module_exports_into_module(
|
|||||||
exports: &IndexSet<ModuleExport>,
|
exports: &IndexSet<ModuleExport>,
|
||||||
code_dir: &mut CodeDir,
|
code_dir: &mut CodeDir,
|
||||||
op_dir: &mut OpDir,
|
op_dir: &mut OpDir,
|
||||||
|
meta_predicates: &mut MetaPredicateDir,
|
||||||
wam_op_dir: &mut OpDir,
|
wam_op_dir: &mut OpDir,
|
||||||
module_op_exports: &mut ModuleOpExports,
|
module_op_exports: &mut ModuleOpExports,
|
||||||
) -> Result<(), SessionError> {
|
) -> Result<(), SessionError> {
|
||||||
@@ -293,6 +299,10 @@ fn import_qualified_module_exports_into_module(
|
|||||||
ModuleExport::PredicateKey((ref name, arity)) => {
|
ModuleExport::PredicateKey((ref name, arity)) => {
|
||||||
let key = (name.clone(), *arity);
|
let key = (name.clone(), *arity);
|
||||||
|
|
||||||
|
if let Some(meta_specs) = imported_module.meta_predicates.get(&key) {
|
||||||
|
meta_predicates.insert(key.clone(), meta_specs.clone());
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(src_code_index) = imported_module.code_dir.get(&key) {
|
if let Some(src_code_index) = imported_module.code_dir.get(&key) {
|
||||||
let target_code_index = code_dir
|
let target_code_index = code_dir
|
||||||
.entry(key.clone())
|
.entry(key.clone())
|
||||||
@@ -1006,7 +1016,7 @@ impl<'a> LoadState<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn import_qualified_module(
|
pub(super) fn import_qualified_module(
|
||||||
&mut self,
|
&mut self,
|
||||||
module_name: ClauseName,
|
module_name: ClauseName,
|
||||||
exports: IndexSet<ModuleExport>,
|
exports: IndexSet<ModuleExport>,
|
||||||
@@ -1021,6 +1031,7 @@ impl<'a> LoadState<'a> {
|
|||||||
&exports,
|
&exports,
|
||||||
&mut self.wam.indices.code_dir,
|
&mut self.wam.indices.code_dir,
|
||||||
&mut self.wam.indices.op_dir,
|
&mut self.wam.indices.op_dir,
|
||||||
|
&mut self.wam.indices.meta_predicates,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
CompilationTarget::Module(ref defining_module_name) => {
|
CompilationTarget::Module(ref defining_module_name) => {
|
||||||
@@ -1033,6 +1044,7 @@ impl<'a> LoadState<'a> {
|
|||||||
&exports,
|
&exports,
|
||||||
&mut target_module.code_dir,
|
&mut target_module.code_dir,
|
||||||
&mut target_module.op_dir,
|
&mut target_module.op_dir,
|
||||||
|
&mut target_module.meta_predicates,
|
||||||
&mut self.wam.indices.op_dir,
|
&mut self.wam.indices.op_dir,
|
||||||
&mut self.module_op_exports,
|
&mut self.module_op_exports,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -1247,10 +1247,17 @@ impl Machine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (mut loader, evacuable_h) = self.loader_from_heap_evacuable(temp_v!(2));
|
let (mut loader, evacuable_h) = self.loader_from_heap_evacuable(temp_v!(3));
|
||||||
|
|
||||||
let import_module = || {
|
let import_module = || {
|
||||||
|
let export_list = loader.extract_module_export_list_from_heap(temp_v!(2))?;
|
||||||
|
|
||||||
|
if export_list.is_empty() {
|
||||||
loader.load_state.import_module(library)?;
|
loader.load_state.import_module(library)?;
|
||||||
|
} else {
|
||||||
|
loader.load_state.import_qualified_module(library, export_list)?;
|
||||||
|
}
|
||||||
|
|
||||||
LiveTermStream::evacuate(loader)
|
LiveTermStream::evacuate(loader)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user