fix use_modules to deal with modules;
allocation fix for simplesim git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@328 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
5e938b92c4
commit
81d38acbc9
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.11 2002-01-21 15:26:48 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.12 2002-01-26 05:37:31 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -822,12 +822,14 @@ mallinfo(void)
|
||||
|
||||
/* user should ask for a lot of memory first */
|
||||
|
||||
#define MAX_SPACE 128*1024*1024
|
||||
|
||||
static int total_space;
|
||||
|
||||
MALLOC_T
|
||||
InitWorkSpace(Int s)
|
||||
{
|
||||
MALLOC_T ptr = (MALLOC_T)malloc(s);
|
||||
MALLOC_T ptr = (MALLOC_T)malloc(MAX_SPACE);
|
||||
total_space = s;
|
||||
|
||||
if (ptr == ((MALLOC_T) - 1)) {
|
||||
@ -843,6 +845,7 @@ ExtendWorkSpace(Int s)
|
||||
MALLOC_T ptr;
|
||||
total_space += s;
|
||||
|
||||
if (total_space < MAX_SPACE) return(TRUE);
|
||||
ptr = (MALLOC_T)realloc((void *)HeapBase, total_space);
|
||||
if (ptr == ((MALLOC_T) - 1)) {
|
||||
Error(SYSTEM_ERROR, TermNil, "could not expand stacks %d bytes", s);
|
||||
|
@ -29,6 +29,7 @@
|
||||
arrangement/2
|
||||
]).
|
||||
|
||||
|
||||
:- use_module( clpr, '../clpr', [get_or_add_class/2]).
|
||||
|
||||
:- ensure_loaded( '../clpqr/ordering').
|
||||
|
@ -87,7 +87,7 @@
|
||||
'$exec_directive'(use_module(Fs,I), _, M) :-
|
||||
'$use_module'(M:Fs,I).
|
||||
'$exec_directive'(use_module(Fs,F,I), _, M) :-
|
||||
'$use_module'(M:Fs,F,I).
|
||||
'$use_module'(Fs,M:F,I).
|
||||
'$exec_directive'(block(BlockSpec), _, _) :-
|
||||
'$block'(BlockSpec).
|
||||
'$exec_directive'(wait(BlockSpec), _, _) :-
|
||||
|
@ -103,9 +103,15 @@ use_module(M,I) :-
|
||||
'$use_module'(V,Decls) :-
|
||||
throw(error(type_error(atom,V),use_module(V,Decls))).
|
||||
|
||||
use_module(M,F,I) :-
|
||||
'$use_module'(M,F,I).
|
||||
use_module(Mod,F,I) :-
|
||||
'$use_module'(Mod,F,I).
|
||||
|
||||
'$use_module'(Module,M:File,Imports) :- !,
|
||||
atom(M), !,
|
||||
'$current_module'(M0),
|
||||
'$change_module'(M),
|
||||
'$use_module'(Module,File,Imports),
|
||||
'$change_module'(M0).
|
||||
'$use_module'(Module,File,Imports) :-
|
||||
'$current_module'(M),
|
||||
'$find_in_path'(File,X),
|
||||
@ -129,6 +135,28 @@ use_module(M,F,I) :-
|
||||
;
|
||||
throw(error(permission_error(input,stream,library(X)),use_module(Module,File,Imports)))
|
||||
).
|
||||
'$use_module'(Module,File,Imports,M) :-
|
||||
'$find_in_path'(File,X),
|
||||
( '$open'(X,'$csult',Stream,0), !,
|
||||
'$consulting_file_name'(Stream,TrueFileName),
|
||||
( '$loaded'(Stream) -> true
|
||||
;
|
||||
'$record_loaded'(Stream),
|
||||
% the following avoids import of all public predicates
|
||||
'$recorda'('$importing','$importing'(TrueFileName),R),
|
||||
'$reconsult'(File,Stream)
|
||||
),
|
||||
'$close'(Stream),
|
||||
( var(R) -> true; erased(R) -> true; erase(R)),
|
||||
( '$recorded'('$module','$module'(TrueFileName,Module,Publics),_) ->
|
||||
'$use_preds'(Imports,Publics,Module,M)
|
||||
;
|
||||
'$format'(user_error,"[ use_module/2 can not find module ~w in file ~w]~n",[Module,File]),
|
||||
fail
|
||||
)
|
||||
;
|
||||
throw(error(permission_error(input,stream,library(X)),use_module(Module,File,Imports)))
|
||||
).
|
||||
'$use_module'(Module,V,Decls) :-
|
||||
throw(error(type_error(atom,V),use_module(Module,V,Decls))).
|
||||
|
||||
@ -248,6 +276,8 @@ module(N) :-
|
||||
'$check_import'(_,_,_,_).
|
||||
|
||||
% $use_preds(Imports,Publics,Mod,M)
|
||||
'$use_preds'(M:L,Publics,Mod,_) :-
|
||||
'$use_preds'(L,Publics,Mod,M).
|
||||
'$use_preds'([],_,_,_) :- !.
|
||||
'$use_preds'([P|Ps],Publics,Mod,M) :- !,
|
||||
'$use_preds'(P,Publics,Mod,M),
|
||||
|
Reference in New Issue
Block a user