]> Repositorios git - scryer-prolog.git/commitdiff
make load_context_path/2 handle .pl file extensions, remove commented out code
authorMark Thom <[email protected]>
Fri, 5 Feb 2021 20:13:54 +0000 (13:13 -0700)
committerMark Thom <[email protected]>
Fri, 5 Feb 2021 20:13:54 +0000 (13:13 -0700)
src/clause_types.rs
src/loader.pl
src/machine/system_calls.rs
src/toplevel.pl

index ac431691c19daafe9e36e1b5550516889501bcab..5a1aefe66852527cc5361be60065196bcf9e577e 100644 (file)
@@ -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,
index e7bc3fa4f6cae9e9e02cdd55cc8d74ad78bdd3d9..5f499c7d8ce36ce87767704d19000c1c6a18b430 100644 (file)
@@ -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).
 
index 2ed49409531777eb833ed686e038e0ee8eb90e53..8762c76455b446cb1c0d075dbf453d68677c0565 100644 (file)
@@ -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)];
 
index 9513b671cc0a66ae06bc4bc53fa3c9e593ce6914..5cf7d5d8a78121b2fce0441ef1e976bc5ed00266 100644 (file)
@@ -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)).