improve dialect support (make it less hackhish).

first  attempt at emulation of autoloader.
This commit is contained in:
Vítor Santos Costa II 2010-04-22 12:16:37 +01:00
parent 3efe7a067a
commit 52ef6ae819
10 changed files with 820 additions and 184 deletions

395
library/INDEX.pl Normal file
View File

@ -0,0 +1,395 @@
index(foreach,2,aggretate,library(aggregate)).
index(aggregate,3,aggretate,library(aggregate)).
index(aggregate,4,aggretate,library(aggregate)).
index(aggregate_all,3,aggretate,library(aggregate)).
index(aggregate_all,4,aggretate,library(aggregate)).
index(free_variables,4,aggretate,library(aggregate)).
index(genarg,3,arg,library(arg)).
index(arg0,3,arg,library(arg)).
index(genarg0,3,arg,library(arg)).
index(args,3,arg,library(arg)).
index(args0,3,arg,library(arg)).
index(path_arg,3,arg,library(arg)).
index(empty_assoc,1,assoc,library(assoc)).
index(assoc_to_list,2,assoc,library(assoc)).
index(is_assoc,1,assoc,library(assoc)).
index(min_assoc,3,assoc,library(assoc)).
index(max_assoc,3,assoc,library(assoc)).
index(gen_assoc,3,assoc,library(assoc)).
index(get_assoc,3,assoc,library(assoc)).
index(get_assoc,5,assoc,library(assoc)).
index(get_next_assoc,4,assoc,library(assoc)).
index(get_prev_assoc,4,assoc,library(assoc)).
index(list_to_assoc,2,assoc,library(assoc)).
index(ord_list_to_assoc,2,assoc,library(assoc)).
index(map_assoc,2,assoc,library(assoc)).
index(map_assoc,3,assoc,library(assoc)).
index(put_assoc,4,assoc,library(assoc)).
index(del_assoc,4,assoc,library(assoc)).
index(del_min_assoc,4,assoc,library(assoc)).
index(del_max_assoc,4,assoc,library(assoc)).
index(avl_new,1,avl,library(avl)).
index(avl_insert,4,avl,library(avl)).
index(avl_lookup,3,avl,library(avl)).
index(b_hash_new,1,b_hash,library(bhash)).
index(b_hash_new,2,b_hash,library(bhash)).
index(b_hash_new,4,b_hash,library(bhash)).
index(b_hash_lookup,3,b_hash,library(bhash)).
index(b_hash_update,3,b_hash,library(bhash)).
index(b_hash_update,4,b_hash,library(bhash)).
index(b_hash_insert_new,4,b_hash,library(bhash)).
index(b_hash_insert,4,b_hash,library(bhash)).
index(format_to_chars,3,charsio,library(charsio)).
index(format_to_chars,4,charsio,library(charsio)).
index(write_to_chars,3,charsio,library(charsio)).
index(write_to_chars,2,charsio,library(charsio)).
index(atom_to_chars,3,charsio,library(charsio)).
index(atom_to_chars,2,charsio,library(charsio)).
index(number_to_chars,3,charsio,library(charsio)).
index(number_to_chars,2,charsio,library(charsio)).
index(read_from_chars,2,charsio,library(charsio)).
index(open_chars_stream,2,charsio,library(charsio)).
index(with_output_to_chars,2,charsio,library(charsio)).
index(with_output_to_chars,3,charsio,library(charsio)).
index(with_output_to_chars,4,charsio,library(charsio)).
index(chr_show_store,1,chr,library(chr)).
index(find_chr_constraint,1,chr,library(chr)).
index(chr_trace,0,chr,library(chr)).
index(chr_notrace,0,chr,library(chr)).
index(chr_leash,1,chr,library(chr)).
index(#>,2,clpfd,library(clpfd)).
index(#<,2,clpfd,library(clpfd)).
index(#>=,2,clpfd,library(clpfd)).
index(#=<,2,clpfd,library(clpfd)).
index(#=,2,clpfd,library(clpfd)).
index(#\=,2,clpfd,library(clpfd)).
index(#\,1,clpfd,library(clpfd)).
index(#<==>,2,clpfd,library(clpfd)).
index(#==>,2,clpfd,library(clpfd)).
index(#<==,2,clpfd,library(clpfd)).
index(#\/,2,clpfd,library(clpfd)).
index(#/\,2,clpfd,library(clpfd)).
index(in,2,clpfd,library(clpfd)).
index(ins,2,clpfd,library(clpfd)).
index(all_different,1,clpfd,library(clpfd)).
index(all_distinct,1,clpfd,library(clpfd)).
index(sum,3,clpfd,library(clpfd)).
index(scalar_product,4,clpfd,library(clpfd)).
index(tuples_in,2,clpfd,library(clpfd)).
index(labeling,2,clpfd,library(clpfd)).
index(label,1,clpfd,library(clpfd)).
index(indomain,1,clpfd,library(clpfd)).
index(lex_chain,1,clpfd,library(clpfd)).
index(serialized,2,clpfd,library(clpfd)).
index(global_cardinality,2,clpfd,library(clpfd)).
index(global_cardinality,3,clpfd,library(clpfd)).
index(circuit,1,clpfd,library(clpfd)).
index(element,3,clpfd,library(clpfd)).
index(automaton,3,clpfd,library(clpfd)).
index(automaton,8,clpfd,library(clpfd)).
index(transpose,2,clpfd,library(clpfd)).
index(zcompare,3,clpfd,library(clpfd)).
index(chain,2,clpfd,library(clpfd)).
index(fd_var,1,clpfd,library(clpfd)).
index(fd_inf,2,clpfd,library(clpfd)).
index(fd_sup,2,clpfd,library(clpfd)).
index(fd_size,2,clpfd,library(clpfd)).
index(fd_dom,2,clpfd,library(clpfd)).
index({},1,clpr,library(clpr)).
index(maximize,1,clpr,library(clpr)).
index(minimize,1,clpr,library(clpr)).
index(inf,2,clpr,library(clpr)).
index(inf,4,clpr,library(clpr)).
index(sup,2,clpr,library(clpr)).
index(sup,4,clpr,library(clpr)).
index(bb_inf,3,clpr,library(clpr)).
index(bb_inf,5,clpr,library(clpr)).
index(ordering,1,clpr,library(clpr)).
index(entailed,1,clpr,library(clpr)).
index(clp_type,2,clpr,library(clpr)).
index(dump,3,clpr,library(clpr)).
index(gensym,2,gensym,library(gensym)).
index(reset_gensym,1,gensym,library(gensym)).
index(reset_gensym,0,gensym,library(gensym)).
index(add_to_heap,4,heaps,library(heaps)).
index(get_from_heap,4,heaps,library(heaps)).
index(empty_heap,1,heaps,library(heaps)).
index(heap_size,2,heaps,library(heaps)).
index(heap_to_list,2,heaps,library(heaps)).
index(list_to_heap,2,heaps,library(heaps)).
index(min_of_heap,3,heaps,library(heaps)).
index(min_of_heap,5,heaps,library(heaps)).
index(jpl_get_default_jvm_opts,1,jpl,library(jpl)).
index(jpl_set_default_jvm_opts,1,jpl,library(jpl)).
index(jpl_get_actual_jvm_opts,1,jpl,library(jpl)).
index(jpl_pl_lib_version,1,jpl,library(jpl)).
index(jpl_c_lib_version,1,jpl,library(jpl)).
index(jpl_new,3,jpl,library(jpl)).
index(jpl_call,4,jpl,library(jpl)).
index(jpl_get,3,jpl,library(jpl)).
index(jpl_set,3,jpl,library(jpl)).
index(jpl_servlet_byref,3,jpl,library(jpl)).
index(jpl_servlet_byval,3,jpl,library(jpl)).
index(jpl_class_to_classname,2,jpl,library(jpl)).
index(jpl_class_to_type,2,jpl,library(jpl)).
index(jpl_classname_to_class,2,jpl,library(jpl)).
index(jpl_classname_to_type,2,jpl,library(jpl)).
index(jpl_datum_to_type,2,jpl,library(jpl)).
index(jpl_false,1,jpl,library(jpl)).
index(jpl_is_class,1,jpl,library(jpl)).
index(jpl_is_false,1,jpl,library(jpl)).
index(jpl_is_null,1,jpl,library(jpl)).
index(jpl_is_object,1,jpl,library(jpl)).
index(jpl_is_object_type,1,jpl,library(jpl)).
index(jpl_is_ref,1,jpl,library(jpl)).
index(jpl_is_true,1,jpl,library(jpl)).
index(jpl_is_type,1,jpl,library(jpl)).
index(jpl_is_void,1,jpl,library(jpl)).
index(jpl_null,1,jpl,library(jpl)).
index(jpl_object_to_class,2,jpl,library(jpl)).
index(jpl_object_to_type,2,jpl,library(jpl)).
index(jpl_primitive_type,1,jpl,library(jpl)).
index(jpl_ref_to_type,2,jpl,library(jpl)).
index(jpl_true,1,jpl,library(jpl)).
index(jpl_type_to_class,2,jpl,library(jpl)).
index(jpl_type_to_classname,2,jpl,library(jpl)).
index(jpl_void,1,jpl,library(jpl)).
index(jpl_array_to_length,2,jpl,library(jpl)).
index(jpl_array_to_list,2,jpl,library(jpl)).
index(jpl_datums_to_array,2,jpl,library(jpl)).
index(jpl_enumeration_element,2,jpl,library(jpl)).
index(jpl_enumeration_to_list,2,jpl,library(jpl)).
index(jpl_hashtable_pair,2,jpl,library(jpl)).
index(jpl_iterator_element,2,jpl,library(jpl)).
index(jpl_list_to_array,2,jpl,library(jpl)).
index(jpl_list_to_array,3,jpl,library(jpl)).
index(jpl_terms_to_array,2,jpl,library(jpl)).
index(jpl_map_element,2,jpl,library(jpl)).
index(jpl_set_element,2,jpl,library(jpl)).
index(append,3,lists,library(lists)).
index(append,2,lists,library(lists)).
index(delete,3,lists,library(lists)).
index(last,2,lists,library(lists)).
index(member,2,lists,library(lists)).
index(memberchk,2,lists,library(lists)).
index(nextto,3,lists,library(lists)).
index(nth,3,lists,library(lists)).
index(nth,4,lists,library(lists)).
index(nth0,3,lists,library(lists)).
index(nth0,4,lists,library(lists)).
index(nth1,3,lists,library(lists)).
index(nth1,4,lists,library(lists)).
index(permutation,2,lists,library(lists)).
index(prefix,2,lists,library(lists)).
index(remove_duplicates,2,lists,library(lists)).
index(reverse,2,lists,library(lists)).
index(same_length,2,lists,library(lists)).
index(select,3,lists,library(lists)).
index(selectchk,3,lists,library(lists)).
index(sublist,2,lists,library(lists)).
index(substitute,4,lists,library(lists)).
index(sum_list,2,lists,library(lists)).
index(sum_list,3,lists,library(lists)).
index(suffix,2,lists,library(lists)).
index(sumlist,2,lists,library(lists)).
index(list_concat,2,lists,library(lists)).
index(flatten,2,lists,library(lists)).
index(max_list,2,lists,library(lists)).
index(min_list,2,lists,library(lists)).
index(numlist,3,lists,library(lists)).
index(intersection,3,lists,library(lists)).
index(nb_queue,1,nb,library(nb)).
index(nb_queue,2,nb,library(nb)).
index(nb_queue_close,3,nb,library(nb)).
index(nb_queue_enqueue,2,nb,library(nb)).
index(nb_queue_dequeue,2,nb,library(nb)).
index(nb_queue_peek,2,nb,library(nb)).
index(nb_queue_empty,1,nb,library(nb)).
index(nb_queue_size,2,nb,library(nb)).
index(nb_heap,2,nb,library(nb)).
index(nb_heap_close,1,nb,library(nb)).
index(nb_heap_add,3,nb,library(nb)).
index(nb_heap_del,3,nb,library(nb)).
index(nb_heap_peek,3,nb,library(nb)).
index(nb_heap_empty,1,nb,library(nb)).
index(nb_heap_size,2,nb,library(nb)).
index(nb_beam,2,nb,library(nb)).
index(nb_beam_close,1,nb,library(nb)).
index(nb_beam_add,3,nb,library(nb)).
index(nb_beam_del,3,nb,library(nb)).
index(nb_beam_peek,3,nb,library(nb)).
index(nb_beam_empty,1,nb,library(nb)).
index(nb_beam_size,2,nb,library(nb)).
index(contains_term,2,occurs,library(occurs)).
index(contains_var,2,occurs,library(occurs)).
index(free_of_term,2,occurs,library(occurs)).
index(free_of_var,2,occurs,library(occurs)).
index(occurrences_of_term,3,occurs,library(occurs)).
index(occurrences_of_var,3,occurs,library(occurs)).
index(sub_term,2,occurs,library(occurs)).
index(sub_var,2,occurs,library(occurs)).
index(option,2,swi_option,library(option)).
index(option,3,swi_option,library(option)).
index(select_option,3,swi_option,library(option)).
index(select_option,4,swi_option,library(option)).
index(list_to_ord_set,2,ordsets,library(ordsets)).
index(merge,3,ordsets,library(ordsets)).
index(ord_add_element,3,ordsets,library(ordsets)).
index(ord_del_element,3,ordsets,library(ordsets)).
index(ord_disjoint,2,ordsets,library(ordsets)).
index(ord_insert,3,ordsets,library(ordsets)).
index(ord_member,2,ordsets,library(ordsets)).
index(ord_intersect,2,ordsets,library(ordsets)).
index(ord_intersect,3,ordsets,library(ordsets)).
index(ord_intersection,3,ordsets,library(ordsets)).
index(ord_intersection,4,ordsets,library(ordsets)).
index(ord_seteq,2,ordsets,library(ordsets)).
index(ord_setproduct,3,ordsets,library(ordsets)).
index(ord_subset,2,ordsets,library(ordsets)).
index(ord_subtract,3,ordsets,library(ordsets)).
index(ord_symdiff,3,ordsets,library(ordsets)).
index(ord_union,2,ordsets,library(ordsets)).
index(ord_union,3,ordsets,library(ordsets)).
index(ord_union,4,ordsets,library(ordsets)).
index(ord_empty,1,ordsets,library(ordsets)).
index(ord_memberchk,2,ordsets,library(ordsets)).
index(pairs_keys_values,3,pairs,library(pairs)).
index(pairs_values,2,pairs,library(pairs)).
index(pairs_keys,2,pairs,library(pairs)).
index(group_pairs_by_key,2,pairs,library(pairs)).
index(transpose_pairs,2,pairs,library(pairs)).
index(map_list_to_pairs,3,pairs,library(pairs)).
index(xref_source,1,prolog_xref,library(prolog_xref)).
index(xref_called,3,prolog_xref,library(prolog_xref)).
index(xref_defined,3,prolog_xref,library(prolog_xref)).
index(xref_definition_line,2,prolog_xref,library(prolog_xref)).
index(xref_exported,2,prolog_xref,library(prolog_xref)).
index(xref_module,2,prolog_xref,library(prolog_xref)).
index(xref_op,2,prolog_xref,library(prolog_xref)).
index(xref_clean,1,prolog_xref,library(prolog_xref)).
index(xref_current_source,1,prolog_xref,library(prolog_xref)).
index(xref_done,2,prolog_xref,library(prolog_xref)).
index(xref_built_in,1,prolog_xref,library(prolog_xref)).
index(xref_expand,2,prolog_xref,library(prolog_xref)).
index(xref_source_file,3,prolog_xref,library(prolog_xref)).
index(xref_source_file,4,prolog_xref,library(prolog_xref)).
index(xref_public_list,4,prolog_xref,library(prolog_xref)).
index(xref_meta,2,prolog_xref,library(prolog_xref)).
index(xref_hook,1,prolog_xref,library(prolog_xref)).
index(xref_used_class,2,prolog_xref,library(prolog_xref)).
index(xref_defined_class,3,prolog_xref,library(prolog_xref)).
index(set_test_options,1,plunit,library(plunit)).
index(begin_tests,1,plunit,library(plunit)).
index(begin_tests,2,plunit,library(plunit)).
index(end_tests,1,plunit,library(plunit)).
index(run_tests,0,plunit,library(plunit)).
index(run_tests,1,plunit,library(plunit)).
index(load_test_files,1,plunit,library(plunit)).
index(running_tests,0,plunit,library(plunit)).
index(test_report,1,plunit,library(plunit)).
index(make_queue,1,queues,library(queues)).
index(join_queue,3,queues,library(queues)).
index(list_join_queue,3,queues,library(queues)).
index(jump_queue,3,queues,library(queues)).
index(list_jump_queue,3,queues,library(queues)).
index(head_queue,2,queues,library(queues)).
index(serve_queue,3,queues,library(queues)).
index(length_queue,2,queues,library(queues)).
index(empty_queue,1,queues,library(queues)).
index(list_to_queue,2,queues,library(queues)).
index(queue_to_list,2,queues,library(queues)).
index(random,1,random,library(random)).
index(random,3,random,library(random)).
index(randseq,3,random,library(random)).
index(randset,3,random,library(random)).
index(getrand,1,random,library(random)).
index(setrand,1,random,library(random)).
index(rb_new,1,rbtrees,library(rbtrees)).
index(rb_empty,1,rbtrees,library(rbtrees)).
index(rb_lookup,3,rbtrees,library(rbtrees)).
index(rb_update,4,rbtrees,library(rbtrees)).
index(rb_update,5,rbtrees,library(rbtrees)).
index(rb_apply,4,rbtrees,library(rbtrees)).
index(rb_lookupall,3,rbtrees,library(rbtrees)).
index(rb_insert,4,rbtrees,library(rbtrees)).
index(rb_insert_new,4,rbtrees,library(rbtrees)).
index(rb_delete,3,rbtrees,library(rbtrees)).
index(rb_delete,4,rbtrees,library(rbtrees)).
index(rb_visit,2,rbtrees,library(rbtrees)).
index(rb_visit,3,rbtrees,library(rbtrees)).
index(rb_keys,2,rbtrees,library(rbtrees)).
index(rb_keys,3,rbtrees,library(rbtrees)).
index(rb_map,2,rbtrees,library(rbtrees)).
index(rb_map,3,rbtrees,library(rbtrees)).
index(rb_partial_map,4,rbtrees,library(rbtrees)).
index(rb_clone,3,rbtrees,library(rbtrees)).
index(rb_clone,4,rbtrees,library(rbtrees)).
index(rb_min,3,rbtrees,library(rbtrees)).
index(rb_max,3,rbtrees,library(rbtrees)).
index(rb_del_min,4,rbtrees,library(rbtrees)).
index(rb_del_max,4,rbtrees,library(rbtrees)).
index(rb_next,4,rbtrees,library(rbtrees)).
index(rb_previous,4,rbtrees,library(rbtrees)).
index(list_to_rbtree,2,rbtrees,library(rbtrees)).
index(ord_list_to_rbtree,2,rbtrees,library(rbtrees)).
index(is_rbtree,1,rbtrees,library(rbtrees)).
index(rb_size,2,rbtrees,library(rbtrees)).
index(rb_in,3,rbtrees,library(rbtrees)).
index(read_line_to_codes,2,readutil,library(readutil)).
index(read_line_to_codes,3,readutil,library(readutil)).
index(read_stream_to_codes,2,readutil,library(readutil)).
index(read_stream_to_codes,3,readutil,library(readutil)).
index(read_file_to_codes,2,readutil,library(readutil)).
index(read_file_to_codes,3,readutil,library(readutil)).
index(read_file_to_terms,2,readutil,library(readutil)).
index(read_file_to_terms,3,readutil,library(readutil)).
index(regexp,3,regexp,library(regexp)).
index(regexp,4,regexp,library(regexp)).
index(datime,1,operating_system_support,library(system)).
index(delete_file,1,operating_system_support,library(system)).
index(delete_file,2,operating_system_support,library(system)).
index(directory_files,2,operating_system_support,library(system)).
index(environ,2,operating_system_support,library(system)).
index(exec,3,operating_system_support,library(system)).
index(file_exists,1,operating_system_support,library(system)).
index(file_exists,2,operating_system_support,library(system)).
index(file_property,2,operating_system_support,library(system)).
index(host_id,1,operating_system_support,library(system)).
index(host_name,1,operating_system_support,library(system)).
index(pid,1,operating_system_support,library(system)).
index(kill,2,operating_system_support,library(system)).
index(mktemp,2,operating_system_support,library(system)).
index(make_directory,1,operating_system_support,library(system)).
index(popen,3,operating_system_support,library(system)).
index(rename_file,2,operating_system_support,library(system)).
index(shell,0,operating_system_support,library(system)).
index(shell,1,operating_system_support,library(system)).
index(shell,2,operating_system_support,library(system)).
index(sleep,1,operating_system_support,library(system)).
index(system,0,operating_system_support,library(system)).
index(system,1,operating_system_support,library(system)).
index(system,2,operating_system_support,library(system)).
index(mktime,2,operating_system_support,library(system)).
index(tmpnam,1,operating_system_support,library(system)).
index(tmp_file,2,operating_system_support,library(system)).
index(wait,2,operating_system_support,library(system)).
index(working_directory,2,operating_system_support,library(system)).
index(term_hash,2,terms,library(terms)).
index(term_hash,4,terms,library(terms)).
index(instantiated_term_hash,4,terms,library(terms)).
index(variant,2,terms,library(terms)).
index(unifiable,3,terms,library(terms)).
index(subsumes,2,terms,library(terms)).
index(subsumes_chk,2,terms,library(terms)).
index(cyclic_term,1,terms,library(terms)).
index(acyclic_term,1,terms,library(terms)).
index(variable_in_term,2,terms,library(terms)).
index(variables_within_term,3,terms,library(terms)).
index(new_variables_in_term,3,terms,library(terms)).
index(time_out,3,timeout,library(timeout)).
index(get_label,3,trees,library(trees)).
index(list_to_tree,2,trees,library(trees)).
index(map_tree,3,trees,library(trees)).
index(put_label,4,trees,library(trees)).
index(tree_size,2,trees,library(trees)).
index(tree_to_list,2,trees,library(trees)).

View File

@ -25,11 +25,13 @@ srcdir=@srcdir@
YAP_EXTRAS=@YAP_EXTRAS@
PROGRAMS= \
$(srcdir)/INDEX.pl \
$(srcdir)/apply.yap \
$(srcdir)/apply_macros.yap \
$(srcdir)/arg.yap \
$(srcdir)/assoc.yap \
$(srcdir)/atts.yap \
$(srcdir)/autoloader.yap \
$(srcdir)/avl.yap \
$(srcdir)/bhash.yap \
$(srcdir)/charsio.yap \
@ -43,7 +45,6 @@ PROGRAMS= \
$(srcdir)/hacks.yap \
$(srcdir)/heaps.yap \
$(srcdir)/lineutils.yap \
$(srcdir)/listing.yap \
$(srcdir)/lists.yap \
$(srcdir)/nb.yap \
$(srcdir)/ordsets.yap \
@ -88,12 +89,18 @@ DIALECT_PROGRAMS= \
$(srcdir)/dialect/hprolog.yap \
$(srcdir)/dialect/swi.yap
DIALECT_SWI= \
$(srcdir)/dialect/swi/INDEX.pl \
$(srcdir)/dialect/swi/listing.pl
install: $(PROGRAMS) install_myddas
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect/swi
for p in $(PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap; done
for p in $(DIALECT_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/dialect; done
for p in $(DIALECT_SWI); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/dialect/swi; done
install_myddas: $(MYDDAS_PROGRAMS)
count=`echo "$(YAP_EXTRAS)" | grep MYDDAS | wc -l`; \

120
library/autoloader.yap Normal file
View File

@ -0,0 +1,120 @@
:- module(autoloader,[make_library_index/0]).
:- use_module(library(lists),[append/3]).
:- dynamic exported/3, loaded/1.
make_library_index :-
scan_library_exports,
scan_swi_exports.
scan_library_exports :-
% init table file.
open('INDEX.pl', write, W),
close(W),
scan_exports('../GPL/aggregate', library(aggregate)),
scan_exports(apply, library(apply)),
scan_exports(arg, library(arg)),
scan_exports(assoc, library(assoc)),
scan_exports(avl, library(avl)),
scan_exports(bhash, library(bhash)),
scan_exports(charsio, library(charsio)),
scan_exports('../packages/chr/chr_swi', library(chr)),
scan_exports(clp/clpfd, library(clpfd)),
scan_exports('../packages/clpqr/clpr', library(clpr)),
scan_exports(gensym, library(gensym)),
scan_exports(heaps, library(heaps)),
scan_exports('../packages/jpl/jpl', library(jpl)),
scan_exports(lists, library(lists)),
scan_exports(nb, library(nb)),
scan_exports(occurs, library(occurs)),
scan_exports('../LGPL/option', library(option)),
scan_exports(ordsets, library(ordsets)),
scan_exports(pairs, library(pairs)),
scan_exports('../LGPL/prolog_xref', library(prolog_xref)),
scan_exports('../packages/plunit/plunit', library(plunit)),
scan_exports(queues, library(queues)),
scan_exports(random, library(random)),
scan_exports(rbtrees, library(rbtrees)),
scan_exports(readutil, library(readutil)),
scan_exports(regexp, library(regexp)),
scan_exports(system, library(system)),
scan_exports(terms, library(terms)),
scan_exports(timeout, library(timeout)),
scan_exports(trees, library(trees)).
scan_exports(Library, CallName) :-
absolute_file_name(Library, Path,
[ file_type(prolog),
access(read),
file_errors(fail)
]),
!,
open(Path, read, O),
get_exports(O, Exports, Module),
close(O),
open('INDEX.pl', append, W),
publish_exports(Exports, W, CallName, Module),
close(W).
scan_exports(Library) :-
format(user_error,'[ warning: library ~w not defined ]~n',[Library]).
%
% SWI is the only language that uses autoload.
%
scan_swi_exports :-
retractall(exported(_,_,_)),
absolute_file_name(dialect/swi, Path,
[ file_type(prolog),
access(read),
file_errors(fail)
]),
open(Path, read, O),
get_exports(O, Exports, Module),
get_reexports(O, Reexports, Exports),
close(O),
open('dialect/swi/INDEX.pl', write, W),
publish_exports(Reexports, W, library(dialect/swi), Module),
close(W).
get_exports(O, Exports, Module) :-
read(O, (:- module(Module,Exports))), !.
get_exports(O, Exports, Module) :-
get_exports(O, Exports, Module).
get_reexports(O, Exports, ExportsL) :-
read(O, (:- reexport(_File,ExportsI))), !,
get_reexports(O, Exports0, ExportsL),
append(ExportsI, Exports0, Exports).
get_reexports(_, Exports, Exports).
publish_exports([], _, _, _).
publish_exports([F/A|Exports], W, Path, Module) :-
publish_export(F, A, W, Path, Module),
publish_exports(Exports, W, Path, Module).
publish_exports([F//A0|Exports], W, Path, Module) :-
A is A0+2,
publish_export(F, A, W, Path, Module),
publish_exports(Exports, W, Path, Module).
publish_exports([op(_,_,_)|Exports], W, Path, Module) :-
publish_exports(Exports, W, Path, Module).
publish_export(F, A, _, _, Module) :-
exported(F, A, M), !,
format(user_error,'[ warning: clash between ~a and ~a over ~a/~d ]~n',[Module,M,F,A]).
publish_export(F, A, W, Path, Module) :-
assert(exported(F, A, Module)), !,
portray_clause(W, index(F, A, Module, Path)).
find_predicate(G,ExportingModI) :-
functor(G, Name, Arity),
index(Name,Arity,ExportingModI,File),
ensure_file_loaded(File).
ensure_file_loaded(File) :-
loaded(File), !.
ensure_file_loaded(File) :-
load_files(autoloader:File,[silent(true),if(not_loaded)]),
assert(loaded(File)).

View File

@ -1,4 +1,83 @@
% SWI emulation.
% written in an on-demand basis.
:- module(system, [term_to_atom/2,
concat_atom/2,
concat_atom/3,
setenv/2,
prolog_to_os_filename/2,
is_absolute_file_name/1,
read_clause/1,
string/1,
working_directory/2,
chdir/1,
compile_aux_clauses/1,
convert_time/2,
'$set_source_module'/2,
'$declare_module'/5,
'$set_predicate_attribute'/3,
time_file/2,
flag/3,
current_flag/1
]).
:- reexport(library(charsio),[
write_to_chars/2,
read_from_chars/2
]).
:- reexport(library(lists),[append/2,
append/3,
delete/3,
member/2,
flatten/2,
intersection/3,
last/2,
memberchk/2,
max_list/2,
min_list/2,
nextto/3,
permutation/2,
reverse/2,
select/3,
selectchk/3,
sublist/2,
sumlist/2,
nth1/3,
nth0/3]).
:- reexport(library(apply),[maplist/2,
maplist/3,
maplist/4,
maplist/5,
include/3,
exclude/3,
partition/4,
partition/5
]).
:- reexport(library(system),
[datime/1,
mktime/2,
file_property/2,
sleep/1]).
:- reexport(library(arg),
[genarg/3]).
:- reexport(library(apply_macros),
[]).
:- reexport(library(terms),
[subsumes/2,
subsumes_chk/2,
term_hash/2,
unifiable/3,
cyclic_term/1,
variant/2]).
:- source.
:- style_check(all).
@ -7,123 +86,29 @@
:- yap_flag(open_expands_filename,false).
% redefines stuff in prolog module.
:- yap_flag(autoload,true).
:- module(swi, []).
:- load_foreign_files([plstream], [], initIO).
:- set_prolog_flag(user_flags,silent).
:- use_module(library(charsio),[write_to_chars/2,read_from_chars/2]).
goal_expansion(atom_concat(A,B),atomic_concat(A,B)).
goal_expansion(atom_concat(A,B,C),atomic_concat(A,B,C)).
goal_expansion(arg(A,B,C),genarg(A,B,C)).
goal_expansion(time_file(A,B),system:swi_time_file(A,B)).
goal_expansion(get_time(A),system:swi_get_time(A)).
:- use_module(library(lists),[append/2,
append/3,
delete/3,
member/2,
min_list/2,
nth1/3,
nth0/3]).
:- use_module(library(apply),[maplist/2,
maplist/3,
maplist/4,
maplist/5,
include/3,
exclude/3,
partition/4,
partition/5
]).
:- use_module(library(system),
[datime/1,
mktime/2,
file_property/2,
sleep/1]).
:- use_module(library(arg),
[genarg/3]).
:- use_module(library(apply_macros),
[]).
:- use_module(library(terms),
[subsumes/2,
subsumes_chk/2,
term_hash/2,
unifiable/3,
variant/2]).
:- unhide('$system_library_directories'),
unhide('$dir_separator').
:- load_foreign_files([plstream], [], initIO).
% make sure we also use
:- user:library_directory(X),
atom(X),
atom_concat([X,'/swi'],SwiDir),
atom_concat([X,'/dialect/swi'],SwiDir),
\+ user:library_directory(SwiDir),
asserta(user:library_directory(SwiDir)),
fail
;
true.
:- multifile user:term_expansion/2.
:- multifile user:goal_expansion/3.
:- multifile user:goal_expansion/2.
:- dynamic user:goal_expansion/2.
:- multifile swi_predicate_table/4.
swi_predicate_table(_,append(X,Y),lists,append(X,Y)).
swi_predicate_table(_,append(X,Y,Z),lists,append(X,Y,Z)).
swi_predicate_table(_,member(X,Y),lists,member(X,Y)).
swi_predicate_table(_,nextto(X,Y,Z),lists,nextto(X,Y,Z)).
swi_predicate_table(_,delete(X,Y,Z),lists,delete(X,Y,Z)).
swi_predicate_table(_,select(X,Y,Z),lists,select(X,Y,Z)).
swi_predicate_table(_,selectchk(X,Y,Z),lists,selectchk(X,Y,Z)).
swi_predicate_table(_,nth0(X,Y,Z),lists,nth0(X,Y,Z)).
swi_predicate_table(_,nth1(X,Y,Z),lists,nth1(X,Y,Z)).
swi_predicate_table(_,last(X,Y),lists,last(X,Y)).
swi_predicate_table(_,reverse(X,Y),lists,reverse(X,Y)).
swi_predicate_table(_,permutation(X,Y),lists,permutation(X,Y)).
swi_predicate_table(_,flatten(X,Y),lists,flatten(X,Y)).
swi_predicate_table(_,sumlist(X,Y),lists,sumlist(X,Y)).
swi_predicate_table(_,min_list(X,Y),lists,min_list(X,Y)).
swi_predicate_table(_,max_list(X,Y),lists,max_list(X,Y)).
swi_predicate_table(_,memberchk(X,Y),lists,memberchk(X,Y)).
swi_predicate_table(_,flatten(X,Y),lists,flatten(X,Y)).
swi_predicate_table(_,select(X,Y,Z),lists,select(X,Y,Z)).
swi_predicate_table(_,sublist(X,Y),lists,sublist(X,Y)).
swi_predicate_table(_,hash_term(X,Y),terms,term_hash(X,Y)).
swi_predicate_table(_,term_hash(X,Y),terms,term_hash(X,Y)).
swi_predicate_table(_,subsumes(X,Y),terms,subsumes(X,Y)).
swi_predicate_table(_,subsumes_chk(X,Y),terms,subsumes_chk(X,Y)).
swi_predicate_table(_,unifiable(X,Y,Z),terms,unifiable(X,Y,Z)).
swi_predicate_table(_,cyclic_term(X),terms,cyclic_term(X)).
swi_predicate_table(_,acyclic_term(X),terms,acyclic_term(X)).
swi_predicate_table(_,genarg(X,Y,Z),arg,genarg(X,Y,Z)).
swi_predicate_table(_,tmp_file(X,Y),system,tmp_file(X,Y)).
swi_predicate_table(_,maplist(X,Y),apply,maplist(X,Y)).
swi_predicate_table(_,maplist(X,Y,Z),apply,maplist(X,Y,Z)).
swi_predicate_table(_,maplist(X,Y,Z,A),apply,maplist(X,Y,Z,A)).
swi_predicate_table(_,maplist(X,Y,Z,A,B),apply,maplist(X,Y,Z,A,B)).
swi_predicate_table(_,include(X,Y,Z),apply,include(X,Y,Z)).
swi_predicate_table(_,exclude(X,Y,Z),apply,exclude(X,Y,Z)).
swi_predicate_table(_,partition(X,Y,Z,A),apply,partition(X,Y,Z,A)).
swi_predicate_table(_,partition(X,Y,Z,A,B),apply,partition(X,Y,Z,A,B)).
swi_predicate_table(_,partition(X,Y,Z),swi,plus(X,Y,Z)).
swi_mchk(X,Y) :- lists:memberchk(X,Y).
prolog:memberchk(X,Y) :- swi_mchk(X,Y).
:- dynamic
prolog:message/3.
:- multifile
prolog:message/3.
:- multifile
user:file_search_path/2.
@ -142,34 +127,29 @@ user:file_search_path(foreign, swi(lib)).
% maybe a good idea to eventually support this in YAP.
% but for now just ignore it.
%
prolog:load_foreign_library(P,Command) :-
load_foreign_library(P,Command) :-
absolute_file_name(P,[file_type(executable),solutions(first),file_errors(fail)],Lib),
load_foreign_files([Lib],[],Command).
prolog:load_foreign_library(P) :-
load_foreign_library(P) :-
prolog:load_foreign_library(P,install).
:- use_module(library(lists)).
prolog:term_to_atom(Term,Atom) :-
term_to_atom(Term,Atom) :-
nonvar(Atom), !,
atom_codes(Atom,S),
read_from_chars(S,Term).
prolog:term_to_atom(Term,Atom) :-
term_to_atom(Term,Atom) :-
write_to_chars(Term,S),
atom_codes(Atom,S).
prolog:concat_atom([A|List], Separator, New) :- var(List), !,
concat_atom([A|List], Separator, New) :- var(List), !,
atom_codes(Separator,[C]),
atom_codes(New, NewChars),
split_atom_by_chars(NewChars,C,L,L,A,List).
prolog:concat_atom(List, Separator, New) :-
concat_atom(List, Separator, New) :-
add_separator_to_list(List, Separator, NewList),
atomic_concat(NewList, New).
prolog:concat_atom(List, New) :-
atomic_concat(List, New).
split_atom_by_chars([],_,[],L,A,[]):-
atom_codes(A,L).
@ -184,23 +164,21 @@ add_separator_to_list([T], _, [T]) :- !.
add_separator_to_list([H|T], Separator, [H,Separator|NT]) :-
add_separator_to_list(T, Separator, NT).
concat_atom(List, New) :-
atomic_concat(List, New).
prolog:setenv(X,Y) :- unix(putenv(X,Y)).
prolog:prolog_to_os_filename(X,X).
setenv(X,Y) :- unix(putenv(X,Y)).
prolog:is_absolute_file_name(X) :-
prolog_to_os_filename(X,X).
is_absolute_file_name(X) :-
absolute_file_name(X,X).
prolog:read_clause(X,Y) :-
read_clause(X,Y) :-
read_term(X,Y,[singetons(warning)]).
prolog:string(_) :- fail.
slp(T) :- sleep(T).
prolog:sleep(T) :-
slp(T).
string(_) :- fail.
bindings_message(V) -->
{ cvt_bindings(V, Bindings) },
@ -211,70 +189,45 @@ cvt_bindings([[Name|Value]|L],[AName=Value|Bindings]) :-
atom_codes(AName, Name),
cvt_bindings(L,Bindings).
prolog:working_directory(OCWD,NCWD) :-
working_directory(OCWD,NCWD) :-
getcwd(OCWD),
(var(NCWD) -> true ; cd(NCWD)).
prolog:chdir(X) :- cd(X).
chdir(X) :- cd(X).
% Time is given as int, not as float.
prolog:get_time(Secs) :- datime(Datime), mktime(Datime, Secs).
% Time is given as a float in SWI-Prolog.
swi_get_time(FSecs) :- datime(Datime), mktime(Datime, Secs), FSecs is Secs*1.0.
% Time is received as int, and converted to "..."
prolog:convert_time(X,Y) :- swi:ctime(X,Y).
% ctime is a built-in.
convert_time(X,Y) :- swi:ctime(X,Y).
:- hide(atom_concat).
prolog:atom_concat(A,B) :- atomic_concat(A,B).
prolog:atom_concat(A,B,C) :- atomic_concat(A,B,C).
:- hide(create_mutable).
:- hide(get_mutable).
:- hide(update_mutable).
% copied from SWI lists library.
lists:intersection([], _, []) :- !.
lists:intersection([X|T], L, Intersect) :-
memberchk(X, L), !,
Intersect = [X|R],
lists:intersection(T, L, R).
lists:intersection([_|T], L, R) :-
lists:intersection(T, L, R).
prolog:compile_aux_clauses([]).
prolog:compile_aux_clauses([(:- G)|Cls]) :-
compile_aux_clauses([]).
compile_aux_clauses([(:- G)|Cls]) :-
prolog_load_context(module, M),
once(M:G),
prolog:compile_aux_clauses(Cls).
prolog:compile_aux_clauses([Cl|Cls]) :-
compile_aux_clauses(Cls).
compile_aux_clauses([Cl|Cls]) :-
prolog_load_context(module, M),
assert_static(M:Cl),
prolog:compile_aux_clauses(Cls).
compile_aux_clauses(Cls).
% fix different semantics for arg/3.
user:goal_expansion(arg(X,Y,Z),arg:genarg(X,Y,Z)) :-
nonvar(X), !.
prolog:'$set_source_module'(Source0, SourceF) :-
prolog_load_context(module, Source0),
'$set_source_module'(Source0, SourceF) :-
prolog_load_context(module, Source0), !,
module(SourceF).
prolog:'$set_source_module'(Source0, SourceF) :-
'$set_source_module'(Source0, SourceF) :-
current_module(Source0, SourceF).
prolog:'$declare_module'(Name, Context, _, _, _) :-
'$declare_module'(Name, Context, _, _, _) :-
add_import_module(Name, Context, start).
prolog:'$set_predicate_attribute'(_, _, _).
'$set_predicate_attribute'(_, _, _).
prolog:time_file(File, Time) :-
swi_time_file(File, Time) :-
file_property(File, mod_time(Date)),
Time is Date*1.0.
prolog:flag(Key, Old, New) :-
flag(Key, Old, New) :-
recorded(Key, Old, R), !,
(
Old \== New
@ -284,11 +237,11 @@ prolog:flag(Key, Old, New) :-
;
true
).
prolog:flag(Key, 0, New) :-
flag(Key, 0, New) :-
functor(Key, N, Ar),
functor(K, N, Ar),
assert(swi:flag(K)),
assert(flag(K)),
recorda(K, New, _).
prolog:current_flag(Key) :-
current_flag(Key) :-
swi:flag(Key).

View File

@ -0,0 +1,58 @@
index(write_to_chars,2,system,library(dialect/swi)).
index(read_from_chars,2,system,library(dialect/swi)).
index(append,2,system,library(dialect/swi)).
index(append,3,system,library(dialect/swi)).
index(delete,3,system,library(dialect/swi)).
index(member,2,system,library(dialect/swi)).
index(flatten,2,system,library(dialect/swi)).
index(intersection,3,system,library(dialect/swi)).
index(last,2,system,library(dialect/swi)).
index(memberchk,2,system,library(dialect/swi)).
index(max_list,2,system,library(dialect/swi)).
index(min_list,2,system,library(dialect/swi)).
index(nextto,3,system,library(dialect/swi)).
index(permutation,2,system,library(dialect/swi)).
index(reverse,2,system,library(dialect/swi)).
index(select,3,system,library(dialect/swi)).
index(selectchk,3,system,library(dialect/swi)).
index(sublist,2,system,library(dialect/swi)).
index(sumlist,2,system,library(dialect/swi)).
index(nth1,3,system,library(dialect/swi)).
index(nth0,3,system,library(dialect/swi)).
index(maplist,2,system,library(dialect/swi)).
index(maplist,3,system,library(dialect/swi)).
index(maplist,4,system,library(dialect/swi)).
index(maplist,5,system,library(dialect/swi)).
index(include,3,system,library(dialect/swi)).
index(exclude,3,system,library(dialect/swi)).
index(partition,4,system,library(dialect/swi)).
index(partition,5,system,library(dialect/swi)).
index(datime,1,system,library(dialect/swi)).
index(mktime,2,system,library(dialect/swi)).
index(file_property,2,system,library(dialect/swi)).
index(sleep,1,system,library(dialect/swi)).
index(genarg,3,system,library(dialect/swi)).
index(subsumes,2,system,library(dialect/swi)).
index(subsumes_chk,2,system,library(dialect/swi)).
index(term_hash,2,system,library(dialect/swi)).
index(unifiable,3,system,library(dialect/swi)).
index(cyclic_term,1,system,library(dialect/swi)).
index(variant,2,system,library(dialect/swi)).
index(term_to_atom,2,system,library(dialect/swi)).
index(concat_atom,2,system,library(dialect/swi)).
index(concat_atom,3,system,library(dialect/swi)).
index(setenv,2,system,library(dialect/swi)).
index(prolog_to_os_filename,2,system,library(dialect/swi)).
index(is_absolute_file_name,1,system,library(dialect/swi)).
index(read_clause,1,system,library(dialect/swi)).
index(string,1,system,library(dialect/swi)).
index(working_directory,2,system,library(dialect/swi)).
index(chdir,1,system,library(dialect/swi)).
index(compile_aux_clauses,1,system,library(dialect/swi)).
index(convert_time,2,system,library(dialect/swi)).
index('$set_source_module',2,system,library(dialect/swi)).
index('$declare_module',5,system,library(dialect/swi)).
index('$set_predicate_attribute',3,system,library(dialect/swi)).
index(time_file,2,system,library(dialect/swi)).
index(flag,3,system,library(dialect/swi)).
index(current_flag,1,system,library(dialect/swi)).

View File

@ -1,5 +0,0 @@
% SWI compatibility only
:- module(listing, []).

View File

@ -1,8 +1,86 @@
'$expects_dialect'(swi) :-
eraseall('$dialect'),
recorda('$dialect',swi,_),
load_files(library('dialect/swi'),[silent(true),if(not_loaded)]).
'$expects_dialect'(yap) :-
:- module(dialect,
[
exists_source/1,
source_exports/2
]).
prolog:'$expects_dialect'(yap) :- !,
eraseall('$dialect'),
recorda('$dialect',yap,_).
prolog:'$expects_dialect'(Dialect) :-
check_dialect(Dialect),
eraseall('$dialect'),
load_files(library(dialect/Dialect),[silent(true),if(not_loaded)]),
( current_predicate(Dialect:setup_dialect/0)
-> Dialect:setup_dialect
; true
),
recorda('$dialect',Dialect,_).
check_dialect(Dialect) :-
var(Dialect),!,
'$do_error'(instantiation_error,(:- dialect(Dialect))).
check_dialect(Dialect) :-
\+ atom(Dialect),!,
'$do_error'(type_error(Dialect),(:- dialect(Dialect))).
check_dialect(Dialect) :-
exists_source(library(dialect/Dialect)), !.
check_dialect(Dialect) :-
'$do_error'(domain_error(dialect,Dialect),(:- dialect(Dialect))).
%% exists_source(+Source) is semidet.
%
% True if Source (a term valid for load_files/2) exists. Fails
% without error if this is not the case. The predicate is intended
% to be used with :- if, as in the example below. See also
% source_exports/2.
%
% ==
% :- if(exists_source(library(error))).
% :- use_module_library(error).
% :- endif.
% ==
exists_source(Source) :-
exists_source(Source, _Path).
exists_source(Source, Path) :-
absolute_file_name(Source, Path,
[ file_type(prolog),
access(read),
file_errors(fail)
]).
%% source_exports(+Source, +Export) is semidet.
%% source_exports(+Source, -Export) is nondet.
%
% True if Source exports Export. Fails without error if this is
% not the case. See also exists_source/1.
%
% @tbd Should we also allow for source_exports(-Source, +Export)?
source_exports(Source, Export) :-
open_source(Source, In),
catch(call_cleanup(exports(In, Exports), close(In)), _, fail),
( ground(Export)
-> memberchk(Export, Exports)
; member(Export, Exports)
).
%% open_source(+Source, -In:stream) is semidet.
%
% Open a source location.
open_source(File, In) :-
exists_source(File, Path),
open(Path, read, In),
( peek_char(In, #)
-> skip(In, 10)
; true
).
exports(In, Exports) :-
read(In, Term),
Term = (:- module(_Name, Exports)).

View File

@ -33,6 +33,18 @@ yap_flag(V,Out) :-
yap_flag(fast,on) :- set_value('$fast',true).
yap_flag(fast,off) :- !, set_value('$fast',[]).
:- dynamic autolader:autoload/0.
% do or do not machine code
yap_flag(autoload,V) :-
var(V), !,
( autoloader:autoload -> V = true ; V = false ).
yap_flag(autoload,true) :-
'$ensure_autoload',
assert(autoloader:autoload).
yap_flag(autoload,false) :-
retract(autoloader:autoload).
% do or do not machine code
yap_flag(argv,L) :- '$argv'(L).
@ -775,6 +787,7 @@ yap_flag(dialect,yap).
'$yap_system_flag'(agc_margin).
'$yap_system_flag'(answer_format).
'$yap_system_flag'(argv).
'$yap_system_flag'(autoload).
'$yap_system_flag'(bounded).
'$yap_system_flag'(char_conversion).
'$yap_system_flag'(character_escapes).
@ -1100,4 +1113,9 @@ create_prolog_flag(Name, Value, Options) :-
'$flag_domain_from_value'(_, term).
'$ensure_autoload' :-
load_files([library(autoloader),
autoloader:library('INDEX'),
swi:library('dialect/swi/INDEX')],
[silent(true),if(not_loaded)]).

View File

@ -68,7 +68,6 @@ lists:append([H|T], L, [H|R]) :-
% with meta-predicate expansion being invoked
'modules.yap',
% must follow grammar
'dialect.yap',
'eval.yap',
'signals.yap',
'profile.yap',
@ -132,6 +131,7 @@ system_mode(verbose,off) :- set_value('$verbose',off).
:- use_module('hacks.yap').
:- use_module('attributes.yap').
:- use_module('corout.yap').
:- use_module('dialect.yap').
'$system_module'('$messages').
'$system_module'('$hacks').

View File

@ -322,6 +322,10 @@ expand_goal(G, G).
call(CurMod:goal_expansion(G, GI))
->
true
;
recorded('$dialect',swi,_), system:goal_expansion(G, GI)
->
true
;
user:goal_expansion(G, CurMod, GI)
->
@ -378,10 +382,18 @@ expand_goal(G, G).
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I), !.
% SWI builtin
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
swi:swi_predicate_table(ImportingMod,G,ExportingModI,G0I),
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
recorded('$dialect',Dialect,_),
Dialect \= yap,
functor(G, Name, Arity),
call(Dialect:index(Name,Arity,ExportingModI,_)), !,
'$continue_imported'(ExportingMod, ExportingModI, G0, G), !.
'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :-
autoloader:autoload, !,
autoloader:find_predicate(G,ExportingModI), !,
'$continue_imported'(ExportingMod, ExportingModI, G0, G), !.
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
prolog:'$parent_module'(ImportingMod,ExportingModI),
'$continue_imported'(ExportingMod, ExportingModI, G0, G).