cleanups.

This commit is contained in:
ubu32 2011-02-15 06:43:28 -08:00
parent 57f5ef8cfc
commit 185bb1b3f0
6 changed files with 57 additions and 1430 deletions

View File

@ -534,12 +534,6 @@ X_API Int STD_PROTO(YAP_NumberOfClausesForPredicate,(PredEntry *));
X_API int STD_PROTO(YAP_MaxOpPriority,(Atom, Term)); X_API int STD_PROTO(YAP_MaxOpPriority,(Atom, Term));
X_API int STD_PROTO(YAP_OpInfo,(Atom, Term, int, int *, int *)); X_API int STD_PROTO(YAP_OpInfo,(Atom, Term, int, int *, int *));
static int (*do_getf)(void);
static int do_yap_getc(int streamno) {
return(do_getf());
}
static int (*do_putcf)(wchar_t); static int (*do_putcf)(wchar_t);
static int do_yap_putc(int streamno,wchar_t ch) { static int do_yap_putc(int streamno,wchar_t ch) {
@ -1539,7 +1533,7 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
CPredicateV codev = (CPredicateV)exec_code; CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1)); struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
struct open_query_struct *oexec = execution; struct open_query_struct *oexec = execution;
extern PL_close_foreign_frame(struct open_query_struct *); extern void PL_close_foreign_frame(struct open_query_struct *);
PP = pe; PP = pe;
ctx->control = FRG_FIRST_CALL; ctx->control = FRG_FIRST_CALL;
@ -1599,7 +1593,7 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code)
CPredicateV codev = (CPredicateV)exec_code; CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1)); struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
struct open_query_struct *oexec = execution; struct open_query_struct *oexec = execution;
extern PL_close_foreign_frame(struct open_query_struct *); extern void PL_close_foreign_frame(struct open_query_struct *);
PP = pe; PP = pe;
ctx->control = FRG_CUTTED; ctx->control = FRG_CUTTED;
@ -1654,7 +1648,7 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
CPredicateV codev = (CPredicateV)exec_code; CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1)); struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
struct open_query_struct *oexec = execution; struct open_query_struct *oexec = execution;
extern PL_close_foreign_frame(struct open_query_struct *); extern void PL_close_foreign_frame(struct open_query_struct *);
PP = pe; PP = pe;
ctx->control = FRG_REDO; ctx->control = FRG_REDO;
@ -2429,7 +2423,6 @@ X_API Term
YAP_Read(IOSTREAM *inp) YAP_Read(IOSTREAM *inp)
{ {
Term t, tpos = TermNil; Term t, tpos = TermNil;
int sno;
TokEntry *tokstart; TokEntry *tokstart;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
@ -2523,29 +2516,11 @@ YAP_CompileClause(Term t)
static int eof_found = FALSE; static int eof_found = FALSE;
static int yap_lineno = 0; static int yap_lineno = 0;
static FILE *bootfile; static IOSTREAM *bootfile;
static char InitFile[] = "init.yap"; static char InitFile[] = "init.yap";
static char BootFile[] = "boot.yap"; static char BootFile[] = "boot.yap";
static int
mygetc (void)
{
int ch;
if (eof_found)
return EOF;
ch = getc (bootfile);
if (ch == EOF)
eof_found = TRUE;
if (ch == '\n') {
#ifdef MPW
ch = 10;
#endif
yap_lineno++;
}
return ch;
}
/* do initial boot by consulting the file boot.yap */ /* do initial boot by consulting the file boot.yap */
static void static void
do_bootfile (char *bootfilename) do_bootfile (char *bootfilename)
@ -2593,7 +2568,7 @@ do_bootfile (char *bootfilename)
else if (YAP_IsPairTerm (t)) else if (YAP_IsPairTerm (t))
{ {
fprintf(stderr, "[ SYSTEM ERROR: consult not allowed in boot file ]\n"); fprintf(stderr, "[ SYSTEM ERROR: consult not allowed in boot file ]\n");
fprintf(stderr, "error found at line %d and pos %d", yap_lineno, fseek(bootfile,0L,SEEK_CUR)); fprintf(stderr, "error found at line %d and pos %d", yap_lineno, Sseek(bootfile,0L,SEEK_CUR));
} }
else if (YAP_IsApplTerm (t) && FunctorOfTerm (t) == functor_query) else if (YAP_IsApplTerm (t) && FunctorOfTerm (t) == functor_query)
{ {
@ -3020,7 +2995,7 @@ YAP_FlushAllStreams(void)
{ {
BACKUP_H(); BACKUP_H();
Yap_FlushStreams(); // VSC?? Yap_FlushStreams();
RECOVER_H(); RECOVER_H();
} }
@ -3333,6 +3308,7 @@ YAP_FileNoFromStream(Term t)
if (IsVarTerm(t)) if (IsVarTerm(t))
return -1; return -1;
return Yap_StreamToFileNo(t); return Yap_StreamToFileNo(t);
return -1;
} }
X_API void * X_API void *
@ -3343,6 +3319,7 @@ YAP_FileDescriptorFromStream(Term t)
if (IsVarTerm(t)) if (IsVarTerm(t))
return NULL; return NULL;
return Yap_FileDescriptorFromStream(t); return Yap_FileDescriptorFromStream(t);
return NULL;
} }
X_API void * X_API void *

File diff suppressed because it is too large Load Diff

View File

@ -804,6 +804,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, Term *tposp)
ch = getchr(inp_stream); ch = getchr(inp_stream);
} }
*tposp = Yap_StreamPosition(inp_stream); *tposp = Yap_StreamPosition(inp_stream);
StartLine = inp_stream->posbuf.lineno;
do { do {
wchar_t och; wchar_t och;
int quote, isvar; int quote, isvar;

View File

@ -2781,6 +2781,9 @@ Yap_TermToString(Term t, char *s, unsigned int sz, int flags)
return out; return out;
} }
extern atom_t fileNameStream(IOSTREAM *s);
extern Atom Yap_FileName(IOSTREAM *s);
Atom Atom
Yap_FileName(IOSTREAM *s) Yap_FileName(IOSTREAM *s)
{ {
@ -2788,6 +2791,36 @@ Yap_FileName(IOSTREAM *s)
return SWIAtomToAtom(a); return SWIAtomToAtom(a);
} }
extern void closeFiles(int);
void
Yap_CloseStreams(int loud)
{
closeFiles(FALSE);
}
int Yap_StreamToFileNo(Term t) {
IOSTREAM *s;
int rc;
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t), &s)) ) {
return Sfileno(s);
}
return -1;
}
FILE *Yap_FileDescriptorFromStream(Term t)
{
IOSTREAM *s;
int rc;
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t), &s)) ) {
fprintf(stderr,"Unimplemented\n");
// return Sfileno(s);
}
return -1;
}
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>

View File

@ -1382,8 +1382,7 @@ cd(Dir) :- working_directory(_, Dir).
getcwd(Dir) :- working_directory(Dir, Dir). getcwd(Dir) :- working_directory(Dir, Dir).
close(Stream) :- close(Stream) :-
'$close'(Stream). swi_close(Stream).
% swi_close(Stream).
close(Stream, Options) :- close(Stream, Options) :-
swi_close(Stream, Options). swi_close(Stream, Options).
open(File, Type, Stream) :- open(File, Type, Stream) :-

View File

@ -454,8 +454,8 @@ initialization(G,OPT) :-
( '$access_yap_flags'(15, 0) -> true ; halt). ( '$access_yap_flags'(15, 0) -> true ; halt).
'$skip_unix_comments'(Stream) :- '$skip_unix_comments'(Stream) :-
'$peek'(Stream, 0'#), !, % 35 is ASCII for '# peek(Stream, 0'#), !, % 35 is ASCII for '#
'$get0_line_codes'(Stream, _), skip(Stream, 10),
'$skip_unix_comments'(Stream). '$skip_unix_comments'(Stream).
'$skip_unix_comments'(_). '$skip_unix_comments'(_).