Skip to content

Commit f743436

Browse files
committed
ENHANCED: use push_prolog_flag/2 for xref-flag scoping
boot/autoload.pl exports/5, library/prolog_xref.pl with_xref/1 and library/prolog_source.pl read_directives. Drops the fallback for "xref flag might not exist" and the state term threading OldXref, both handled by push/pop.
1 parent 786ec52 commit f743436

3 files changed

Lines changed: 10 additions & 19 deletions

File tree

boot/autoload.pl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,10 @@
527527
exports(File, Module, Exports, _Meta, _Public).
528528

529529
exports(File, Module, Exports, Meta, Public) :-
530-
( current_prolog_flag(xref, Old)
531-
-> true
532-
; Old = false
533-
),
534530
setup_call_cleanup(
535-
set_prolog_flag(xref, true),
531+
push_prolog_flag(xref, true),
536532
snapshot(exports_(File, Module, Exports, Meta, Public)),
537-
set_prolog_flag(xref, Old)).
533+
pop_prolog_flag(xref)).
538534

539535
exports_(File, Module, Exports, Meta, Public) :-
540536
State = state(true, _, [], [], []),

library/prolog_source.pl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -651,15 +651,14 @@
651651
phrase(read_directives(In, Options, [true]), Directives),
652652
read_directives_cleanup(In, State)).
653653

654-
read_directives_setup(TempModule, Path, In, state(OldM, OldXref)) :-
654+
read_directives_setup(TempModule, Path, In, OldM) :-
655655
prolog_open_source(Path, In),
656656
'$set_source_module'(OldM, TempModule),
657-
current_prolog_flag(xref, OldXref),
658-
set_prolog_flag(xref, true).
657+
push_prolog_flag(xref, true).
659658

660-
read_directives_cleanup(In, state(OldM, OldXref)) :-
659+
read_directives_cleanup(In, OldM) :-
661660
'$set_source_module'(OldM),
662-
set_prolog_flag(xref, OldXref),
661+
pop_prolog_flag(xref),
663662
prolog_close_source(In).
664663

665664
read_directives(In, Options, State) -->

library/prolog_xref.pl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,10 @@
437437
with_xref(0).
438438

439439
with_xref(Goal) :-
440-
current_prolog_flag(xref, Xref),
441-
( Xref == true
442-
-> call(Goal)
443-
; setup_call_cleanup(
444-
set_prolog_flag(xref, true),
445-
Goal,
446-
set_prolog_flag(xref, Xref))
447-
).
440+
setup_call_cleanup(
441+
push_prolog_flag(xref, true),
442+
Goal,
443+
pop_prolog_flag(xref)).
448444

449445

450446
%! set_initial_mode(+Stream, +Options) is det.

0 commit comments

Comments
 (0)