make load_context_path/2 handle .pl file extensions, remove commented out code

This commit is contained in:
Mark Thom
2021-02-05 13:13:54 -07:00
parent 2d7f31a60d
commit 1bc8e9aebf
4 changed files with 16 additions and 42 deletions

View File

@@ -150,11 +150,6 @@ impl InlinedClauseType {
#[derive(Debug, Copy, Clone, Eq, PartialEq)] #[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum SystemClauseType { pub enum SystemClauseType {
// AbolishClause,
// AbolishModuleClause,
// AssertDynamicPredicateToBack,
// AssertDynamicPredicateToFront,
// AtEndOfExpansion,
AtomChars, AtomChars,
AtomCodes, AtomCodes,
AtomLength, AtomLength,
@@ -189,8 +184,6 @@ pub enum SystemClauseType {
DynamicModuleResolution(usize), DynamicModuleResolution(usize),
EnqueueAttributeGoal, EnqueueAttributeGoal,
EnqueueAttributedVar, EnqueueAttributedVar,
// ExpandGoal,
// ExpandTerm,
FetchGlobalVar, FetchGlobalVar,
FetchGlobalVarWithOffset, FetchGlobalVarWithOffset,
FirstStream, FirstStream,
@@ -207,16 +200,13 @@ pub enum SystemClauseType {
GetAttrVarQueueDelimiter, GetAttrVarQueueDelimiter,
GetAttrVarQueueBeyond, GetAttrVarQueueBeyond,
GetBValue, GetBValue,
// GetClause,
GetContinuationChunk, GetContinuationChunk,
// GetModuleClause,
GetNextDBRef, GetNextDBRef,
GetNextOpDBRef, GetNextOpDBRef,
IsPartialString, IsPartialString,
LookupDBRef, LookupDBRef,
LookupOpDBRef, LookupOpDBRef,
Halt, Halt,
// ModuleHeadIsDynamic,
GetLiftedHeapFromOffset, GetLiftedHeapFromOffset,
GetLiftedHeapFromOffsetDiff, GetLiftedHeapFromOffsetDiff,
GetSCCCleaner, GetSCCCleaner,
@@ -225,10 +215,7 @@ pub enum SystemClauseType {
InstallInferenceCounter, InstallInferenceCounter,
LiftedHeapLength, LiftedHeapLength,
LoadLibraryAsStream, LoadLibraryAsStream,
// ModuleAssertDynamicPredicateToFront,
// ModuleAssertDynamicPredicateToBack,
ModuleExists, ModuleExists,
// ModuleRetractClause,
NextEP, NextEP,
NoSuchPredicate, NoSuchPredicate,
NumberToChars, NumberToChars,
@@ -254,7 +241,6 @@ pub enum SystemClauseType {
ResetContinuationMarker, ResetContinuationMarker,
ResetGlobalVarAtKey, ResetGlobalVarAtKey,
ResetGlobalVarAtOffset, ResetGlobalVarAtOffset,
// RetractClause,
RestoreCutPolicy, RestoreCutPolicy,
SetCutPoint(RegType), SetCutPoint(RegType),
SetInput, SetInput,

View File

@@ -296,11 +296,13 @@ use_module(Module, Exports) :-
%% If use_module is invoked in an existing load context, use its %% If use_module is invoked in an existing load context, use its
%% directory. Otherwise, use the relative path of Path. %% directory. Otherwise, use the relative path of Path.
load_context_path(Module, Path) :- load_context_path(Module, Path) :-
( prolog_load_context(directory, CurrentDir) -> ( prolog_load_context(directory, CurrentDir) ->
atom_concat(CurrentDir, Path, Module) atom_concat(CurrentDir, Path, Module)
; ; atom_concat(_, '.pl', Module) ->
Module = Path Module = Path
; atom_concat(Module, '.pl', Path)
). ).
@@ -311,23 +313,21 @@ use_module(Module, Exports, Evacuable) :-
( atom(Library) -> ( atom(Library) ->
( '$load_compiled_library'(Library, Evacuable) -> %% TODO: What about Exports? ( '$load_compiled_library'(Library, Evacuable) -> %% TODO: What about Exports?
true true
; ; '$load_library_as_stream'(Library, Stream, Path),
'$load_library_as_stream'(Library, Stream, Path),
file_load(Stream, Path, Subevacuable), file_load(Stream, Path, Subevacuable),
'$use_module'(Evacuable, Subevacuable, Exports) '$use_module'(Evacuable, Subevacuable, Exports)
) )
; var(Library) -> ; var(Library) ->
instantiation_error(load/1) instantiation_error(load/1)
; ; type_error(atom, Library, load/1)
type_error(atom, Library, load/1)
) )
; atom(Module) -> ; ( atom(Module) ->
load_context_path(Module, Path), load_context_path(Module, Path),
open(Path, read, Stream), open(Path, read, Stream),
file_load(Stream, Path, Subevacuable), file_load(Stream, Path, Subevacuable),
'$use_module'(Evacuable, Subevacuable, Exports) '$use_module'(Evacuable, Subevacuable, Exports)
; ; type_error(atom, Library, load/1)
type_error(atom, Library, load/1) )
). ).
@@ -387,7 +387,6 @@ strip_module_(M0, G0, M1, G1) :-
; M0 = M1, ; M0 = M1,
G0 = G1 G0 = G1
). ).
strip_module(Goal, M, G) :- strip_module(Goal, M, G) :-
strip_module_(_, Goal, M, G). strip_module_(_, Goal, M, G).

View File

@@ -1098,13 +1098,6 @@ impl MachineState {
return Ok(()); return Ok(());
} }
} }
/*
&SystemClauseType::AtEndOfExpansion => {
if self.cp == LocalCodePtr::TopLevel(0, 0) {
self.at_end_of_expansion = true;
}
}
*/
&SystemClauseType::AtomChars => { &SystemClauseType::AtomChars => {
let a1 = self[temp_v!(1)]; let a1 = self[temp_v!(1)];

View File

@@ -1,9 +1,5 @@
:- module('$toplevel', [argv/1, :- module('$toplevel', [argv/1,
copy_term/3, copy_term/3]).
predicate_property/2,
prolog_load_context/2]).
:- use_module(library(loader)).
:- use_module(library(charsio)). :- use_module(library(charsio)).
:- use_module(library(iso_ext)). :- use_module(library(iso_ext)).