more PLStream stuff.

This commit is contained in:
Vítor Santos Costa 2011-02-23 17:46:50 +00:00
parent 6ea0b727e0
commit f92fa69eab
7 changed files with 33 additions and 8 deletions

View File

@ -172,10 +172,6 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
LOCK(Yap_heap_regs->low_level_trace_lock);
sc = Yap_heap_regs;
vsc_count++;
if (vsc_count == 471321)
jmp_deb(1);
if (vsc_count < 471300)
return;
#ifdef THREADS
MY_ThreadHandle.thread_inst_count++;
#endif

View File

@ -315,6 +315,7 @@ PL_SOURCES= \
$(srcdir)/pl/tabling.yap $(srcdir)/pl/threads.yap \
$(srcdir)/pl/udi.yap \
$(srcdir)/pl/utils.yap \
$(srcdir)/LGPL/history.pl \
$(srcdir)/pl/yapor.yap $(srcdir)/pl/yio.yap
YAPDOCS=$(srcdir)/docs/yap.tex $(srcdir)/docs/chr.tex \

View File

@ -4681,6 +4681,8 @@ static const PL_extension foreigns[] = {
FRG("format_predicate", 2, pl_format_predicate, META),
FRG("current_format_predicate", 2, pl_current_format_predicate,
META|NDET),
FRG("$raw_read", 1, pl_raw_read, 0),
FRG("$raw_read", 2, pl_raw_read2, 0),
/* DO NOT ADD ENTRIES BELOW THIS ONE */
LFRG((char *)NULL, 0, NULL, 0)
};

View File

@ -28,7 +28,6 @@ typedef struct
unsigned char *base; /* base of clause */
unsigned char *end; /* end of the clause */
unsigned char *token_start; /* start of most recent read token */
IOSTREAM *stream;
int has_exception; /* exception is raised */
unsigned char *posp; /* position pointer */
@ -37,6 +36,7 @@ typedef struct
unsigned int flags; /* Module syntax flags */
int styleCheck; /* style-checking mask */
bool backquoted_string; /* Read `hello` as string */
int *char_conversion_table; /* active conversion table */
term_t exception; /* raised exception */
@ -70,7 +70,7 @@ init_read_data(ReadData _PL_rd, IOSTREAM *in ARG_LD)
{ memset(_PL_rd, 0, sizeof(*_PL_rd)); /* optimise! */
_PL_rd->varnames = 0;
_PL_rd->stream = in;
rb.stream = in;
_PL_rd->has_exception = 0;
_PL_rd->exception = 0;
}
@ -81,9 +81,9 @@ free_read_data(ReadData _PL_rd)
}
static int
read_term(term_t t, ReadData rd ARG_LD)
read_term(term_t t, ReadData _PL_rd ARG_LD)
{
return Yap_read_term(t, rd->stream, rd->varnames);
return Yap_read_term(t, rb.stream, _PL_rd->varnames);
}

View File

@ -144,6 +144,15 @@ true :- true.
*/
/* main execution loop */
'$read_vars'(user_input, Goal, Mod, Pos, Binding) :-
read_history(h, '!h',
[trace, end_of_file],
Prompt, Goal, Bindings),
(nonvar(Err) ->
print_message(error,Err), fail
;
true
).
'$read_vars'(Stream,T,Mod,Pos,V) :-
'$read'(true,T,Mod,V,Pos,Err,Stream),
(nonvar(Err) ->
@ -1562,3 +1571,6 @@ format(Stream, Command, Args) :-
is_stream(Stream) :-
swi_is_stream(Stream).
'$raw_read'(Stream, String) :-
'swi_$raw_read'(Stream, String).

View File

@ -205,6 +205,16 @@ yap_flag(home,X) :-
'$transl_to_index_mode'(3, on). % default is multi argument indexing
'$transl_to_index_mode'(4, max).
yap_flag(readline,X) :-
var(X), !,
get_value('$readline',X1).
'$transl_to_true_false'(X1,X).
yap_flag(readline,X) :-
'$transl_to_true_false'(X1,X), !,
set_value('$readline',X1).
yap_flag(bounded,X) :-
'$do_error'(domain_error(flag_value,readline+X),yap_flag(bounded,X)).
% tabling mode
yap_flag(tabling_mode,Options) :-
var(Options), !,

View File

@ -113,11 +113,15 @@ system_mode(verbose,off) :- set_value('$verbose',off).
:- use_module('attributes.yap').
:- use_module('corout.yap').
:- use_module('dialect.yap').
%:- use_module('../LGPL/history.pl').
%:- set_prolog_flag(readline, true).
'$system_module'('$messages').
'$system_module'('$hacks').
'$system_module'('$attributes').
'$system_module'('$coroutining').
'$system_module'('$history').
yap_hacks:cut_by(CP) :- '$$cut_by'(CP).