From 089e86462150d6ade8357529f1189f3ccf72e871 Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 4 Aug 2006 04:06:33 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1682 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/readutil.c | 32 ++++++++++++++++++++++++-------- C/tracer.c | 2 -- library/readutil.yap | 7 +------ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/C/readutil.c b/C/readutil.c index 2120a673b..665f9ad3d 100644 --- a/C/readutil.c +++ b/C/readutil.c @@ -101,26 +101,42 @@ p_stream_to_codes(void) { int sno = Yap_CheckStream (ARG1, Input_Stream_f, "read_line_to_codes/2"); CELL *HBASE = H; + CELL *h0 = &ARG4; if (sno < 0) return FALSE; while (!(Stream[sno].status & Eof_Stream_f)) { /* skip errors */ Int ch = Stream[sno].stream_getc(sno); + Term t; if (ch == EOFCHAR) break; - *H++ = MkIntTerm(ch); - *H = AbsPair(H+1); - H++; - if (H >= ASP) { - Yap_Error(OUT_OF_STACK_ERROR, ARG1, "read_stream_to_codes/3"); - return FALSE; + t = MkIntegerTerm(ch); + h0[0] = AbsPair(H); + *H = t; + H+=2; + h0 = H-1; + if (H >= ASP-1024) { + RESET_VARIABLE(h0); + ARG4 = AbsPair(HBASE); + ARG5 = (CELL)h0; + fprintf(stderr,"+ %p-%p=%p\n",HBASE,H,H-HBASE); + if (!Yap_gc(5, ENV, P)) { + Yap_Error(OUT_OF_STACK_ERROR, ARG1, "read_stream_to_codes/3"); + return FALSE; + } + /* build a legal term again */ + h0 = (CELL *)ARG5; + HBASE = RepPair(ARG4); + fprintf(stderr,"- %p-%p=%d\n",HBASE,h0,h0-HBASE); } } if (H == HBASE) return Yap_unify(ARG2,ARG3); - H[-1] = Deref(ARG3); + RESET_VARIABLE(H-1); + Yap_unify(H[-1],ARG3); return Yap_unify(AbsPair(HBASE),ARG2); + } static Int @@ -162,7 +178,7 @@ Yap_InitReadUtil(void) CurrentModule = READUTIL_MODULE; Yap_InitCPred("read_line_to_codes", 2, p_rl_to_codes, SafePredFlag|SyncPredFlag); Yap_InitCPred("read_line_to_codes", 3, p_rl_to_codes2, SafePredFlag|SyncPredFlag); - Yap_InitCPred("read_stream_to_codes", 3, p_stream_to_codes, SafePredFlag|SyncPredFlag); + Yap_InitCPred("read_stream_to_codes", 3, p_stream_to_codes, SyncPredFlag); Yap_InitCPred("read_stream_to_terms", 3, p_stream_to_terms, SafePredFlag|SyncPredFlag); CurrentModule = cm; } diff --git a/C/tracer.c b/C/tracer.c index b73c17245..acd131f7d 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -161,8 +161,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 == 27) Yap_Portray_delays = TRUE; - else Yap_Portray_delays = TRUE; #ifdef COMMENTED if (worker_id != 04 || worker_id != 03) return; // if (vsc_count == 218280) diff --git a/library/readutil.yap b/library/readutil.yap index c7cd58f83..543d7828c 100644 --- a/library/readutil.yap +++ b/library/readutil.yap @@ -30,11 +30,6 @@ read_stream_to_codes(Stream, Codes) :- read_stream_to_codes(Stream, Codes, []). -read_file_to_codes(File, Codes) :- - open(File, read, Stream), - read_stream_to_codes(Stream, Codes, []), - close(Stream). - read_file_to_codes(File, Codes, _) :- open(File, read, Stream), read_stream_to_codes(Stream, Codes, []), @@ -42,7 +37,7 @@ read_file_to_codes(File, Codes, _) :- read_file_to_codes(File, Codes) :- open(File, read, Stream), - read_stream_to_terms(Stream, Codes, []), + read_stream_to_codes(Stream, Codes, []), close(Stream). read_file_to_terms(File, Codes, _) :-