This commit is contained in:
Vitor Santos Costa 2018-06-03 12:07:38 +01:00
parent 72a703393f
commit 1201357017
9 changed files with 725 additions and 32 deletions

View File

@ -525,7 +525,7 @@ bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
q.CurSlot = Yap_StartSlots();
q.p = P;
q.cp = CP;
PredEntry *ap;
PredEntry *ap = nullptr;
if (IsStringTerm(tmod))
tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod)));
YAPPredicate *p = new YAPPredicate(t, tmod, ts, "C++");

View File

@ -126,8 +126,7 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
`true`. */
YAP_FLAG(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag,
"true", NULL),
YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context",
true, booleanFlag, "true", NULL),
YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context", true, booleanFlag, "true", NULL),
/**< `compiled_at `
Read-only flag that gives the time when the main YAP binary was compiled. It
@ -145,15 +144,14 @@ opportunity. Initial value is 10,000. May be changed. A value of 0
YAP_FLAG(DEBUG_INFO_FLAG, "debug_info", true, booleanFlag, "true", NULL),
YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true",
NULL),
/**< `debugger_print_options `
/**<
If bound, set the argument to the `write_term/3` options the
debugger uses to write terms. If unbound, show the current options.
*/
YAP_FLAG(DEBUGGER_PRINT_OPTIONS_FLAG, "debugger_print_options", true,
list_option,
"[quoted(true),numbervars(true),portrayed(true),max_depth(10)]",
NULL),
NULL),
YAP_FLAG(DEBUGGER_SHOW_CONTEXT_FLAG, "debugger_show_context", true,
booleanFlag, "false", NULL),
/**< `dialect `

View File

@ -153,7 +153,7 @@ int Yap_open_buf_read_stream(const char *buf, size_t nchars, encoding_t *encp,
f = st->file = fmemopen((void *)buf, nchars, "r");
st->vfs = NULL;
flags = Input_Stream_f | InMemory_Stream_f | Seekable_Stream_f;
Yap_initStream(sno, f, "memStream", "r", TermNone, encoding, flags, NULL);
Yap_initStream(sno, f, "memStream", "r", TermNone, encoding, flags, NULL);
// like any file stream.
Yap_DefaultStreamOps(st);
UNLOCK(st->streamlock);
@ -171,9 +171,10 @@ open_mem_read_stream(USES_REGS1) /* $open_mem_read_stream(+List,-Stream) */
int l = push_text_stack();
buf = Yap_TextTermToText(ti);
if (!buf) {
pop_text_stack(l);
return false;
}
buf = pop_output_text_stack(l, buf);
buf = pop_output_text_stack(l, buf);
sno = Yap_open_buf_read_stream(buf, strlen(buf) + 1, &LOCAL_encoding,
MEM_BUF_MALLOC);
t = Yap_MkStream(sno);
@ -197,7 +198,7 @@ int Yap_open_buf_write_stream(encoding_t enc, memBufSource src) {
st->linecount = 1;
st->encoding = enc;
st->vfs = NULL;
st->buf.on = false;
st->buf.on = false;
#if HAVE_OPEN_MEMSTREAM
st->file = open_memstream(&st->nbuf, &st->nsize);
// setbuf(st->file, NULL);

View File

@ -1127,11 +1127,8 @@ static Int format(Term tf, Term tas, Term tout USES_REGS) {
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars) ){
output_stream = Yap_OpenBufWriteStream(PASS_REGS1);
mem_stream = true;
}
if (output_stream <0 ||!mem_stream) {
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
/* needs to change LOCAL_c_output_stream for write */
output_stream = Yap_CheckStream(tout, Output_Stream_f, "format/3");
} else {
output_stream = Yap_CheckStream(tout, Output_Stream_f, "format/3");
}
if (output_stream == -1) {
UNLOCK(GLOBAL_Stream[output_stream].streamlock);

View File

@ -1557,7 +1557,7 @@ int Yap_OpenStream(Term tin, const char *io_mode, Term user_name,
CACHE_REGS
int sno;
StreamDesc *st;
struct vfs *vfsp;
struct vfs *vfsp = NULL;
int flags;
const char *fname;
@ -1627,7 +1627,7 @@ int Yap_OpenStream(Term tin, const char *io_mode, Term user_name,
const char *buf;
int i = push_text_stack();
buf = Yap_TextTermToText(ArgOfTerm(1, tin) PASS_REGS);
if (!buf) {
if (buf == NULL) {
pop_text_stack(i);
return -1;
}

File diff suppressed because one or more lines are too long

View File

@ -1,20 +1,19 @@
/**
/*!
* @file complete.yap
*
* @brief Prolog completer.
*/
:- module( completer,
[
completions/2.
]).
[completions/2 ]).
:- use_module(library(lists)).
:- use_module(library(maplist)).
:- use_module(library(python)).
%% completions( +Text, +PythonCell )
%
%
% Tries to complete the current text. The list with the set of completions
% is stored in the
% `matches` field of the python object.
@ -116,8 +115,3 @@ cont(0, F, P, P0) :-
atom_concat( F, P, P0 ).
cont( _, F, P, PB ):-
atom_concat( [F, P, '( )'], PB ).

View File

@ -4,7 +4,7 @@
* @brief JUpyter support.
*/
% :- module( jupyter,
% [jupyter_query/3,
% errors/2,
@ -52,11 +52,13 @@ jupyter_consult(Text) :-
blank( Text ),
!.
jupyter_consult(Cell) :-
open_mem_read_stream( Cell, Stream),
% Name = 'Inp',
% stream_property(Stream, file_name(Name) ),
load_files(user:'jupyter cell',[stream(Stream)]), !.
%should load_files close?
setup_call_cleanup(
open_mem_read_stream( Cell, Stream),
load_files(user:'jupyter cell',[stream(Stream)]),
close(Stream)
).
blank(Text) :-
atom_codes(Text, L),

View File

@ -804,5 +804,4 @@ class YAPRun:
if query[-1] == '.':
return s,'',False,0
(query, _,loop, sols) = self.clean_end(query)
print(program, query, loop, sols)
return (program, query, loop, sols)