From 1bc8e9aebf148995662979bb1032a2c104ea1897 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Fri, 5 Feb 2021 13:13:54 -0700 Subject: [PATCH] make load_context_path/2 handle .pl file extensions, remove commented out code --- src/clause_types.rs | 14 -------------- src/loader.pl | 33 ++++++++++++++++----------------- src/machine/system_calls.rs | 7 ------- src/toplevel.pl | 6 +----- 4 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/clause_types.rs b/src/clause_types.rs index ac431691..5a1aefe6 100644 --- a/src/clause_types.rs +++ b/src/clause_types.rs @@ -150,11 +150,6 @@ impl InlinedClauseType { #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum SystemClauseType { - // AbolishClause, - // AbolishModuleClause, - // AssertDynamicPredicateToBack, - // AssertDynamicPredicateToFront, - // AtEndOfExpansion, AtomChars, AtomCodes, AtomLength, @@ -189,8 +184,6 @@ pub enum SystemClauseType { DynamicModuleResolution(usize), EnqueueAttributeGoal, EnqueueAttributedVar, -// ExpandGoal, -// ExpandTerm, FetchGlobalVar, FetchGlobalVarWithOffset, FirstStream, @@ -207,16 +200,13 @@ pub enum SystemClauseType { GetAttrVarQueueDelimiter, GetAttrVarQueueBeyond, GetBValue, -// GetClause, GetContinuationChunk, -// GetModuleClause, GetNextDBRef, GetNextOpDBRef, IsPartialString, LookupDBRef, LookupOpDBRef, Halt, -// ModuleHeadIsDynamic, GetLiftedHeapFromOffset, GetLiftedHeapFromOffsetDiff, GetSCCCleaner, @@ -225,10 +215,7 @@ pub enum SystemClauseType { InstallInferenceCounter, LiftedHeapLength, LoadLibraryAsStream, - // ModuleAssertDynamicPredicateToFront, - // ModuleAssertDynamicPredicateToBack, ModuleExists, - // ModuleRetractClause, NextEP, NoSuchPredicate, NumberToChars, @@ -254,7 +241,6 @@ pub enum SystemClauseType { ResetContinuationMarker, ResetGlobalVarAtKey, ResetGlobalVarAtOffset, - // RetractClause, RestoreCutPolicy, SetCutPoint(RegType), SetInput, diff --git a/src/loader.pl b/src/loader.pl index e7bc3fa4..5f499c7d 100644 --- a/src/loader.pl +++ b/src/loader.pl @@ -296,11 +296,13 @@ use_module(Module, Exports) :- %% If use_module is invoked in an existing load context, use its %% directory. Otherwise, use the relative path of Path. + load_context_path(Module, Path) :- ( prolog_load_context(directory, CurrentDir) -> atom_concat(CurrentDir, Path, Module) - ; - Module = Path + ; atom_concat(_, '.pl', Module) -> + Module = Path + ; atom_concat(Module, '.pl', Path) ). @@ -311,23 +313,21 @@ use_module(Module, Exports, Evacuable) :- ( atom(Library) -> ( '$load_compiled_library'(Library, Evacuable) -> %% TODO: What about Exports? true - ; - '$load_library_as_stream'(Library, Stream, Path), - file_load(Stream, Path, Subevacuable), - '$use_module'(Evacuable, Subevacuable, Exports) + ; '$load_library_as_stream'(Library, Stream, Path), + file_load(Stream, Path, Subevacuable), + '$use_module'(Evacuable, Subevacuable, Exports) ) ; var(Library) -> instantiation_error(load/1) - ; - type_error(atom, Library, load/1) - ) - ; atom(Module) -> - load_context_path(Module, Path), - open(Path, read, Stream), - file_load(Stream, Path, Subevacuable), - '$use_module'(Evacuable, Subevacuable, Exports) - ; - type_error(atom, Library, load/1) + ; type_error(atom, Library, load/1) + ) + ; ( atom(Module) -> + load_context_path(Module, Path), + open(Path, read, Stream), + file_load(Stream, Path, Subevacuable), + '$use_module'(Evacuable, Subevacuable, Exports) + ; type_error(atom, Library, load/1) + ) ). @@ -387,7 +387,6 @@ strip_module_(M0, G0, M1, G1) :- ; M0 = M1, G0 = G1 ). - strip_module(Goal, M, G) :- strip_module_(_, Goal, M, G). diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 2ed49409..8762c764 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -1098,13 +1098,6 @@ impl MachineState { return Ok(()); } } - /* - &SystemClauseType::AtEndOfExpansion => { - if self.cp == LocalCodePtr::TopLevel(0, 0) { - self.at_end_of_expansion = true; - } - } - */ &SystemClauseType::AtomChars => { let a1 = self[temp_v!(1)]; diff --git a/src/toplevel.pl b/src/toplevel.pl index 9513b671..5cf7d5d8 100644 --- a/src/toplevel.pl +++ b/src/toplevel.pl @@ -1,9 +1,5 @@ :- module('$toplevel', [argv/1, - copy_term/3, - predicate_property/2, - prolog_load_context/2]). - -:- use_module(library(loader)). + copy_term/3]). :- use_module(library(charsio)). :- use_module(library(iso_ext)). -- 2.54.0