static SourceFile lookupSourceFile_unlocked(atom_t name, int create) { GET_LD SourceFile file; if ( !GD->files.table ) { GD->files.table = newHTable(32); GD->files.table->free_symbol = freeSymbolSourceFile; GD->files.no_hole_before = 1; } if ( (file=lookupHTable(GD->files.table, (void*)name)) ) { ; } else if ( create ) { file = allocHeapOrHalt(sizeof(*file)); memset(file, 0, sizeof(*file)); file->name = name; file->system = GD->bootsession; #ifdef O_PLMT file->mutex = allocSimpleMutex(PL_atom_chars(name)); #endif PL_register_atom(file->name); file->magic = SF_MAGIC; registerSourceFile(file); addNewHTable(GD->files.table, (void*)name, file); } else { file = NULL; } return file; }
static Table newOperatorTable(int size) { Table t = newHTable(size); t->copy_symbol = copyOperatorSymbol; t->free_symbol = freeOperatorSymbol; return t; }
void initBuildIns(void) { ExtensionCell ecell; Module m = MODULE_system; GD->procedures.dirty = newHTable(32); registerBuiltins(foreigns); REG_PLIST(alloc); REG_PLIST(atom); REG_PLIST(arith); REG_PLIST(bag); REG_PLIST(comp); REG_PLIST(flag); REG_PLIST(index); REG_PLIST(list); REG_PLIST(module); REG_PLIST(prims); REG_PLIST(strings); REG_PLIST(variant); REG_PLIST(copyterm); REG_PLIST(prologflag); REG_PLIST(trace); REG_PLIST(pro); REG_PLIST(read); REG_PLIST(thread); REG_PLIST(profile); REG_PLIST(wic); REG_PLIST(file); REG_PLIST(files); REG_PLIST(glob); REG_PLIST(btree); REG_PLIST(ctype); REG_PLIST(tai); REG_PLIST(setup); REG_PLIST(gc); REG_PLIST(proc); REG_PLIST(srcfile); REG_PLIST(write); REG_PLIST(dlopen); REG_PLIST(system); REG_PLIST(op); REG_PLIST(rec); REG_PLIST(term); REG_PLIST(termhash); #ifdef O_ATTVAR REG_PLIST(attvar); #endif #ifdef O_GVAR REG_PLIST(gvar); #endif #ifdef __WINDOWS__ REG_PLIST(win); REG_PLIST(dde); #endif #ifdef O_LOCALE REG_PLIST(locale); #endif REG_PLIST(debug); REG_PLIST(dict); REG_PLIST(cont); REG_PLIST(trie); REG_PLIST(tabling); REG_PLIST(mutex); REG_PLIST(zip); REG_PLIST(cbtrace); #define LOOKUPPROC(name) \ { GD->procedures.name = lookupProcedure(FUNCTOR_ ## name, m); \ DEBUG(CHK_SECURE, assert(GD->procedures.name)); \ } LOOKUPPROC(dgarbage_collect1); LOOKUPPROC(catch3); LOOKUPPROC(reset3); LOOKUPPROC(dmeta_call1); LOOKUPPROC(true0); LOOKUPPROC(fail0); LOOKUPPROC(equals2); LOOKUPPROC(is2); LOOKUPPROC(strict_equal2); LOOKUPPROC(not_strict_equal2); LOOKUPPROC(print_message2); LOOKUPPROC(dcall1); LOOKUPPROC(setup_call_catcher_cleanup4); LOOKUPPROC(dthread_init0); LOOKUPPROC(dc_call_prolog0); LOOKUPPROC(dinit_goal3); #ifdef O_ATTVAR LOOKUPPROC(dwakeup1); #endif #if O_DEBUGGER PROCEDURE_event_hook1 = PL_predicate("prolog_event_hook", 1, "user"); #endif PROCEDURE_exception_hook4 = PL_predicate("prolog_exception_hook", 4, "user"); /* allow debugging in call/1 */ clear(PROCEDURE_dcall1->definition, HIDE_CHILDS|TRACE_ME); set(PROCEDURE_dcall1->definition, P_DYNAMIC|P_LOCKED); PL_meta_predicate(PL_predicate("assert", 1, "system"), ":"); PL_meta_predicate(PL_predicate("asserta", 1, "system"), ":"); PL_meta_predicate(PL_predicate("assertz", 1, "system"), ":"); PL_meta_predicate(PL_predicate("assert", 2, "system"), ":-"); PL_meta_predicate(PL_predicate("asserta", 2, "system"), ":-"); PL_meta_predicate(PL_predicate("assertz", 2, "system"), ":-"); PL_meta_predicate(PL_predicate("retract", 1, "system"), ":"); PL_meta_predicate(PL_predicate("retractall", 1, "system"), ":"); PL_meta_predicate(PL_predicate("clause", 2, "system"), ":?"); PL_meta_predicate(PL_predicate("format", 2, "system"), "+:"); PL_meta_predicate(PL_predicate("format", 3, "system"), "++:"); PL_meta_predicate(PL_predicate("format_predicate", 2, "system"), "+0"); PL_meta_predicate(PL_predicate("notrace", 1, "system"), "0"); PL_meta_predicate(PL_predicate("with_mutex", 2, "system"), "+0"); PL_meta_predicate(PL_predicate("with_output_to", 2, "system"), "+0"); #ifdef O_PLMT PL_meta_predicate(PL_predicate("thread_create", 3, "system"), "0?+"); PL_meta_predicate(PL_predicate("thread_at_exit", 1, "system"), "0"); PL_meta_predicate(PL_predicate("thread_signal", 2, "system"), "+0"); #endif PL_meta_predicate(PL_predicate("prolog_frame_attribute", 3, "system"), "++:"); PL_meta_predicate(PL_predicate("compile_predicates", 1, "system"), ":"); PL_meta_predicate(PL_predicate("op", 3, "system"), "++:"); PL_meta_predicate(PL_predicate("current_op", 3, "system"), "++:"); for( ecell = ext_head; ecell; ecell = ecell->next ) bindExtensions(ecell->module, ecell->extensions); extensions_loaded = TRUE; }