Merge /home/vsc/yap
This commit is contained in:
commit
3efb73f35d
@ -203,13 +203,13 @@ static bool consult(const char *b_file USES_REGS) {
|
||||
} else {
|
||||
YAP_CompileClause(t);
|
||||
}
|
||||
} while (true);
|
||||
yap_error_descriptor_t *errd;
|
||||
if ((errd =
|
||||
Yap_GetException(LOCAL_ActiveError))) {
|
||||
fprintf(stderr, "%s:%ld:0: Error %s %s Found\n", errd->errorFile, (long int) errd->errorLine, errd->classAsText,
|
||||
errd->errorAsText);
|
||||
}
|
||||
} while (true);
|
||||
BACKUP_MACHINE_REGS();
|
||||
YAP_EndConsult(c_stream, &osno, full);
|
||||
if (!Yap_AddAlias(AtomLoopStream, osno)) {
|
||||
|
@ -519,7 +519,7 @@ bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
|
||||
#if YAP_PYTHON
|
||||
// PyThreadState *_save;
|
||||
|
||||
std::cerr << "mgoal " << YAPTerm(t).text() << "\n";
|
||||
//std::cerr << "mgoal " << YAPTerm(t).text() << "\n";
|
||||
// _save = PyEval_SaveThread();
|
||||
#endif
|
||||
CACHE_REGS
|
||||
@ -553,7 +553,7 @@ bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
|
||||
//__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
|
||||
|
||||
result = (bool)YAP_EnterGoal(ap, nullptr, &q);
|
||||
std::cerr << "mgoal " << YAPTerm(t).text() << "\n";
|
||||
//std::cerr << "mgoal " << YAPTerm(t).text() << "\n";
|
||||
|
||||
YAP_LeaveGoal(result && !release, &q);
|
||||
// PyEval_RestoreThread(_save);
|
||||
|
@ -70,13 +70,12 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
|
||||
#endif
|
||||
YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL), /**<
|
||||
read-only atom, it describes the ISA used in this version of YAP.
|
||||
Available from YAP_AEH.
|
||||
Available from YAP_ARCH.
|
||||
*/
|
||||
|
||||
YAP_FLAG(ARGV_FLAG, "argv", false, argv, "@boot", NULL),
|
||||
YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true,
|
||||
booleanFlag, "true", NULL),
|
||||
/**< `arithmetic_exceptions`
|
||||
/**<
|
||||
|
||||
Read-write flag telling whether arithmetic exceptions generate
|
||||
Prolog exceptions. If enabled:
|
||||
@ -97,7 +96,7 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
|
||||
ProbLog.
|
||||
*/
|
||||
YAP_FLAG(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", bqs),
|
||||
/**>
|
||||
/**<
|
||||
If _Value_ is unbound, tell whether a back quoted list of characters
|
||||
token is converted to a list of atoms, `chars`, to a list of integers,
|
||||
`codes`, or to a single atom, `atom`. If _Value_ is bound, set to
|
||||
|
@ -990,16 +990,11 @@ leaving the current stream position unaltered.
|
||||
*/
|
||||
static Int peek_code(USES_REGS1) { /* at_end_of_stream */
|
||||
/* the next character is a EOF */
|
||||
int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "peek/2");
|
||||
int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "peek_code/2");
|
||||
Int ch;
|
||||
|
||||
if (sno < 0)
|
||||
return FALSE;
|
||||
if (GLOBAL_Stream[sno].status & Binary_Stream_f) {
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_code/2");
|
||||
return FALSE;
|
||||
}
|
||||
if ((ch = Yap_peek(sno)) < 0) {
|
||||
#ifdef PEEK_EOF
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
|
13
os/streams.c
13
os/streams.c
@ -683,7 +683,7 @@ static xarg *generate_property(int sno, Term t2,
|
||||
}
|
||||
|
||||
static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
bool det;
|
||||
bool det = false;
|
||||
xarg *args;
|
||||
int i = IntOfTerm(EXTRA_CBACK_ARG(2, 1));
|
||||
stream_property_choices_t p = STREAM_PROPERTY_END;
|
||||
@ -705,7 +705,7 @@ static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
|
||||
if (LOCAL_Error_TYPE == DOMAIN_ERROR_GENERIC_ARGUMENT)
|
||||
LOCAL_Error_TYPE = DOMAIN_ERROR_STREAM_PROPERTY_OPTION;
|
||||
Yap_Error(LOCAL_Error_TYPE, t2, NULL);
|
||||
Yap_ThrowError(LOCAL_Error_TYPE, t2, NULL);
|
||||
return false;
|
||||
}
|
||||
cut_fail();
|
||||
@ -714,16 +714,17 @@ static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
if (IsAtomTerm(args[STREAM_PROPERTY_ALIAS].tvalue)) {
|
||||
// one solution only
|
||||
i = Yap_CheckAlias(AtomOfTerm(args[STREAM_PROPERTY_ALIAS].tvalue));
|
||||
free(args) UNLOCK(GLOBAL_Stream[i].streamlock);
|
||||
UNLOCK(GLOBAL_Stream[i].streamlock);
|
||||
if (i < 0 || !Yap_unify(ARG1, Yap_MkStream(i))) {
|
||||
free(args);
|
||||
cut_fail();
|
||||
}
|
||||
cut_succeed();
|
||||
det = true;
|
||||
}
|
||||
LOCK(GLOBAL_Stream[i].streamlock);
|
||||
rc = do_stream_property(i, args PASS_REGS);
|
||||
UNLOCK(GLOBAL_Stream[i].streamlock);
|
||||
if (IsVarTerm(t1)) {
|
||||
if (!det && IsVarTerm(t1)) {
|
||||
if (rc)
|
||||
rc = Yap_unify(ARG1, Yap_MkStream(i));
|
||||
if (p == STREAM_PROPERTY_END) {
|
||||
@ -743,7 +744,7 @@ static Int cont_stream_property(USES_REGS1) { /* current_stream */
|
||||
}
|
||||
} else {
|
||||
// done
|
||||
det = (p == STREAM_PROPERTY_END);
|
||||
det = det || (p == STREAM_PROPERTY_END);
|
||||
}
|
||||
free(args);
|
||||
if (rc) {
|
||||
|
@ -41,7 +41,6 @@ jupyter_cell( Caller, _, Line ) :-
|
||||
E=error(A,B),
|
||||
system_error(A,B)
|
||||
).
|
||||
jupyter_cell(_,_,_).
|
||||
|
||||
restreams(call) :-
|
||||
streams(true).
|
||||
@ -207,4 +206,4 @@ plot_inline :-
|
||||
|
||||
:- endif.
|
||||
|
||||
:- ( start_low_level_trace ).
|
||||
%:- ( start_low_level_trace ).
|
||||
|
@ -121,9 +121,11 @@ print_message(L,E) :-
|
||||
).
|
||||
|
||||
'$undefp0'([M|G], _Action) :-
|
||||
stream_property( loop_stream, file_name(F)),
|
||||
stream_property( loop_stream, line_number(L)),
|
||||
format(user_error,'~a:~d error undefined: call to ~w~n',[F,L,M:G]),
|
||||
stream_property( loop_stream, [file_name(F), line_number(L)]),
|
||||
format(user_error,'~a:~d error undefined:',[F,L]),
|
||||
fail
|
||||
;
|
||||
format(user_error,' call to ~w~n',[M:G]),
|
||||
fail.
|
||||
|
||||
:- '$undefp_handler'('$undefp0'(_,_),prolog).
|
||||
|
147
pl/consult.yap
147
pl/consult.yap
@ -220,10 +220,10 @@ SWI-compatible option where if _Autoload_ is `true` undefined
|
||||
% compilation_mode(compact,source,assert_all) => implemented
|
||||
% register(true, false) => implemented
|
||||
%
|
||||
load_files(Files,Opts) :-
|
||||
once( '$load_files'(Files,Opts,load_files(Files,Opts)) ),
|
||||
fail.
|
||||
load_files(_Files,_Opts).
|
||||
load_files(Files0,Opts) :-
|
||||
'$yap_strip_module'(Files0,M,Files),
|
||||
'$load_files'(Files,M,Opts,M:load_files(Files,Opts)).
|
||||
|
||||
|
||||
'$lf_option'(autoload, 1, false).
|
||||
'$lf_option'(derived_from, 2, false).
|
||||
@ -234,7 +234,14 @@ load_files(_Files,_Opts).
|
||||
'$lf_option'(qcompile, 7, Current) :-
|
||||
'__NB_getval__'('$qcompile', Current, Current = never).
|
||||
'$lf_option'(silent, 8, _).
|
||||
'$lf_option'(skip_unix_header, 9, true).
|
||||
'$lf_option'(skip_unix_header, 9, Skip) :-
|
||||
stream_property(Stream,[alias(loop_stream),tty(TTy),reposition(Rep)]),
|
||||
( Rep == true
|
||||
->
|
||||
(TTy = true -> Skip = false ; Skip = true)
|
||||
;
|
||||
Skip = false
|
||||
).
|
||||
'$lf_option'(compilation_mode, 10, Flag) :-
|
||||
current_prolog_flag(source, YFlag),
|
||||
( YFlag == false -> Flag = compact ; Flag = source ).
|
||||
@ -273,44 +280,70 @@ load_files(_Files,_Opts).
|
||||
'$lf_option'(Op, Id, _),
|
||||
setarg( Id, TOpts, Val ).
|
||||
|
||||
'$load_files'(Files, Opts, Call) :-
|
||||
(
|
||||
'__NB_getval__'('$lf_status', OldTOpts, fail)
|
||||
'$load_files'([user], M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user, M, [stream(S)|Opts], Call).
|
||||
'$load_files'(user, M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user, M, [stream(S)|Opts], Call).
|
||||
'$load_files'([-user], M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user, M, [consult(reconsult),stream(S)|Opts], Call).
|
||||
'$load_files'(-user, M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user, M, [consult(reconsult),stream(S)|Opts], Call).
|
||||
'$load_files'([user_input], M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user_input, M, [stream(S)|Opts], Call).
|
||||
'$load_files'(user_input, M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user_input, M, [stream(S)|Opts], Call).
|
||||
'$load_files'([-user_input], M,Opts, Call) :-
|
||||
current_input(S),
|
||||
'$load_files__'(user_input, M, [consult(reconsult),stream(S)|Opts], Call).
|
||||
'$load_files'(-user_input, M,Opts, Call) :-
|
||||
'$load_files__'(user_input, M, [consult(reconsult),stream(S)|Opts], Call).
|
||||
'$load_files'(Files, M, Opts, Call) :-
|
||||
'$load_files__'(Files, M, Opts, Call).
|
||||
'$load_files__'(Files, M, Opts, Call) :-
|
||||
'$lf_option'(last_opt, LastOpt),
|
||||
( '__NB_getval__'('$lf_status', OldTOpts, fail),
|
||||
nonvar(OldTOpts)
|
||||
->
|
||||
'$lf_opt'('$context_module', OldTOpts, Context),
|
||||
'$lf_opt'(autoload, OldTOpts, OldAutoload)
|
||||
;
|
||||
'$lf_option'(last_opt, LastOpt),
|
||||
functor( OldTOpts, opt, LastOpt )
|
||||
),
|
||||
'$lf_option'(last_opt, LastOpt),
|
||||
functor( TOpts, opt, LastOpt ),
|
||||
( source_location(ParentF, Line) -> true ; ParentF = user_input, Line = -1 ),
|
||||
'$lf_opt'('$location', TOpts, ParentF:Line),
|
||||
'$lf_opt'('$files', TOpts, Files),
|
||||
'$lf_opt'('$call', TOpts, Call),
|
||||
'$lf_opt'('$options', TOpts, Opts),
|
||||
'$lf_opt'('$parent_topts', TOpts, OldTOpts),
|
||||
'$process_lf_opts'(Opts,TOpts,Files,Call),
|
||||
'$lf_default_opts'(1, LastOpt, TOpts),
|
||||
'$lf_opt'(stream, TOpts, Stream),
|
||||
( nonvar(Stream) ->
|
||||
'$set_lf_opt'('$from_stream', TOpts, true )
|
||||
;
|
||||
'$check_files'(Files,load_files(Files,Opts))
|
||||
),
|
||||
'$check_use_module'(Call,UseModule),
|
||||
'$lf_opt'('$use_module', TOpts, UseModule),
|
||||
'$current_module'(M0),
|
||||
( '$lf_opt'(autoload, TOpts, Autoload),
|
||||
var(Autoload) ->
|
||||
Autoload = OldAutoload
|
||||
;
|
||||
true
|
||||
),
|
||||
% make sure we can run consult
|
||||
'$init_consult',
|
||||
'$lf'(Files, M0, Call, TOpts).
|
||||
'$lf_opt'(autoload, OldTOpts, OldAutoload),
|
||||
'$lf_opt'('$context_module', OldTOpts, OldContextModule)
|
||||
;
|
||||
current_prolog_flag(autoload, OldAutoload),
|
||||
functor( OldTOpts, opt, LastOpt ),
|
||||
'$lf_opt'(autoload, OldTOpts, OldAutoload),
|
||||
'$lf_opt'('$context_module', OldTOpts, OldContextModule)
|
||||
),
|
||||
functor( TOpts, opt, LastOpt ),
|
||||
( source_location(ParentF, Line) -> true ; ParentF = user_input, Line = -1 ),
|
||||
'$lf_opt'('$location', TOpts, ParentF:Line),
|
||||
'$lf_opt'('$files', TOpts, Files),
|
||||
'$lf_opt'('$call', TOpts, Call),
|
||||
'$lf_opt'('$options', TOpts, Opts),
|
||||
'$lf_opt'('$parent_topts', TOpts, OldTOpts),
|
||||
'$process_lf_opts'(Opts,TOpts,Files,Call),
|
||||
'$lf_default_opts'(1, LastOpt, TOpts),
|
||||
'$lf_opt'(stream, TOpts, Stream),
|
||||
( nonvar(Stream) ->
|
||||
'$set_lf_opt'('$from_stream', TOpts, true )
|
||||
;
|
||||
'$check_files'(Files,load_files(Files,Opts))
|
||||
),
|
||||
'$check_use_module'(Call,UseModule),
|
||||
'$lf_opt'('$use_module', TOpts, UseModule),
|
||||
( '$lf_opt'(autoload, TOpts, Autoload),
|
||||
var(Autoload) ->
|
||||
Autoload = OldAutoload
|
||||
;
|
||||
true
|
||||
),
|
||||
% make sure we can run consult
|
||||
'$init_consult',
|
||||
'$lf'(Files, M, Call, TOpts).
|
||||
|
||||
'$check_files'(Files, Call) :-
|
||||
var(Files), !,
|
||||
@ -432,32 +465,12 @@ load_files(_Files,_Opts).
|
||||
'$lf'(V,_,Call, _ ) :- var(V), !,
|
||||
'$do_error'(instantiation_error,Call).
|
||||
'$lf'([], _, _, _) :- !.
|
||||
'$lf'(M:X, _, Call, TOpts) :- !,
|
||||
(
|
||||
atom(M)
|
||||
->
|
||||
'$lf'(X, M, Call, TOpts)
|
||||
;
|
||||
'$do_error'(type_error(atom,M),Call)
|
||||
).
|
||||
'$lf'([F|Fs], Mod, Call, TOpts) :- !,
|
||||
% clean up after each consult
|
||||
( '$lf'(F,Mod,Call, TOpts), fail;
|
||||
'$lf'(Fs, Mod, Call, TOpts), fail;
|
||||
true
|
||||
).
|
||||
'$lf'(user, Mod, Call, TOpts) :-
|
||||
!,
|
||||
stream_property( S, alias( user_input )),
|
||||
'$set_lf_opt'('$from_stream', TOpts, true),
|
||||
'$set_lf_opt'( stream , TOpts, S),
|
||||
'$lf'(S, Mod, Call, TOpts).
|
||||
'$lf'(user_input, Mod, Call, TOpts ) :-
|
||||
!,
|
||||
stream_property( S, alias( user_input )),
|
||||
'$set_lf_opt'('$from_stream', TOpts, true),
|
||||
'$set_lf_opt'( stream , TOpts, S),
|
||||
'$lf'(S, Mod, Call, TOpts).
|
||||
'$lf'(File, Mod, Call, TOpts) :-
|
||||
'$lf_opt'(stream, TOpts, Stream),
|
||||
b_setval('$user_source_file', File),
|
||||
@ -1103,7 +1116,7 @@ just goes through every loaded file and verifies whether reloading is needed.
|
||||
|
||||
make :-
|
||||
recorded('$lf_loaded','$lf_loaded'(F1,_M,reconsult,_,_,_,_),_),
|
||||
'$load_files'(F1, [if(changed)],make),
|
||||
load_files(F1, [if(changed)]),
|
||||
fail.
|
||||
make.
|
||||
|
||||
@ -1264,11 +1277,11 @@ use_module(M,F,Is) :-
|
||||
'$use_module'(M,M1,F,Is) :-
|
||||
nonvar(F), !,
|
||||
( var(M) ->
|
||||
'$load_files'(M1:F, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is)),
|
||||
load_files(M1:F, [if(not_loaded),must_be_module(true),imports(Is)]),
|
||||
absolute_file_name( F, F1, [expand(true),file_type(prolog)] ),
|
||||
recorded('$module','$module'(F1,M,_,_,_),_)
|
||||
;
|
||||
'$load_files'(M1:F, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is))
|
||||
load_files(M1:F, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is))
|
||||
).
|
||||
'$use_module'(M,M1,F,Is) :-
|
||||
nonvar(M), !,
|
||||
@ -1276,11 +1289,11 @@ use_module(M,F,Is) :-
|
||||
(
|
||||
recorded('$module','$module'(F0,M,_,_,_),_)
|
||||
->
|
||||
'$load_files'(M1:F0, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is))
|
||||
load_files(M1:F0, [if(not_loaded),must_be_module(true),imports(Is)])
|
||||
;
|
||||
nonvar(F0)
|
||||
->
|
||||
'$load_files'(M1:F, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is))
|
||||
load_files(M1:F, [if(not_loaded),must_be_module(true),imports(Is)])
|
||||
;
|
||||
'$do_error'(instantiation_error,use_module(M,F,Is))
|
||||
).
|
||||
|
@ -45,7 +45,6 @@
|
||||
'$include'/2,
|
||||
'$initialization'/1,
|
||||
'$initialization'/2,
|
||||
'$load_files'/3,
|
||||
'$require'/2,
|
||||
'$set_encoding'/1,
|
||||
'$use_module'/3]).
|
||||
|
@ -232,9 +232,9 @@ beautify_hidden_goal('$process_directive'(Gs,_Mode,_VL),prolog) -->
|
||||
[(:- Gs)].
|
||||
beautify_hidden_goal('$loop'(Stream,Option),prolog) -->
|
||||
[execute_load_file(Stream, consult=Option)].
|
||||
beautify_hidden_goal('$load_files'(Files,Opts,?),prolog) -->
|
||||
[load_files(Files,Opts)].
|
||||
beautify_hidden_goal('$load_files'(_,_,Name),prolog) -->
|
||||
beautify_hidden_goal('$load_files'(Files,M,Opts,?),prolog) -->
|
||||
[load_files(M:Files,Opts)].
|
||||
beautify_hidden_goal('$load_files'(_,_,_,Name),prolog) -->
|
||||
[Name].
|
||||
beautify_hidden_goal('$reconsult'(Files,Mod),prolog) -->
|
||||
[reconsult(Mod:Files)].
|
||||
|
25
pl/init.yap
25
pl/init.yap
@ -33,17 +33,20 @@
|
||||
nb_setval('$chr_toplevel_show_store',false).
|
||||
|
||||
'$init_consult' :-
|
||||
set_value('$open_expands_filename',true),
|
||||
nb_setval('$assert_all',off),
|
||||
nb_setval('$if_level',0),
|
||||
nb_setval('$endif',off),
|
||||
nb_setval('$initialization_goals',off),
|
||||
nb_setval('$included_file',[]),
|
||||
nb_setval('$loop_streams',[]),
|
||||
\+ '$undefined'('$init_preds',prolog),
|
||||
'$init_preds',
|
||||
fail.
|
||||
'$init_consult'.
|
||||
set_value('$open_expands_filename',true),
|
||||
nb_setval('$assert_all',off),
|
||||
nb_setval('$if_level',0),
|
||||
nb_setval('$endif',off),
|
||||
nb_setval('$initialization_goals',off),
|
||||
nb_setval('$included_file',[]),
|
||||
nb_setval('$loop_streams',[]),
|
||||
(
|
||||
'$undefined'('$init_preds',prolog)
|
||||
->
|
||||
true
|
||||
;
|
||||
'$init_preds'
|
||||
).
|
||||
|
||||
'$init_win_graphics' :-
|
||||
'$undefined'(window_title(_,_), system), !.
|
||||
|
@ -201,8 +201,8 @@ The state of the module system after this error is undefined.
|
||||
|
||||
|
||||
**/
|
||||
use_module(F) :- '$load_files'(F,
|
||||
[if(not_loaded),must_be_module(true)], use_module(F)).
|
||||
use_module(F) :- load_files(F,
|
||||
[if(not_loaded),must_be_module(true)]).
|
||||
|
||||
|
||||
/**
|
||||
@ -235,7 +235,7 @@ Unfortunately it is still not possible to change argument order.
|
||||
|
||||
**/
|
||||
use_module(F,Is) :-
|
||||
'$load_files'(F, [if(not_loaded),must_be_module(true),imports(Is)], use_module(F,Is)).
|
||||
load_files(F, [if(not_loaded),must_be_module(true),imports(Is)]).
|
||||
|
||||
'$module'(O,N,P,Opts) :- !,
|
||||
'$module'(O,N,P),
|
||||
|
Reference in New Issue
Block a user