optimize misc/buildheap script

This commit is contained in:
Ricardo Rocha 2011-05-04 19:34:22 +01:00
parent d9cee607e9
commit feb27c1e6e
5 changed files with 278 additions and 274 deletions

View File

@ -24,30 +24,30 @@ static void InitGlobal(void) {
#if THREADS #if THREADS
Yap_global->n_of_threads = 1; Yap_NOfThreads = 1;
Yap_global->n_of_threads_created = 1; Yap_NOfThreadsCreated = 1;
Yap_global->threads_total_time = 0L; Yap_ThreadsTotalTime = 0L;
#endif #endif
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_global->bgl); INIT_LOCK(Yap_BGL);
#endif #endif
Yap_global->allow_local_expansion = TRUE; Yap_AllowLocalExpansion = TRUE;
Yap_global->allow_global_expansion = TRUE; Yap_AllowGlobalExpansion = TRUE;
Yap_global->allow_trail_expansion = TRUE; Yap_AllowTrailExpansion = TRUE;
Yap_global->size_of_overflow = 0; Yap_SizeOfOverflow = 0;
Yap_global->agc_last_call = 0; Yap_AGcLastCall = 0;
Yap_global->agc_threshold = 10000; Yap_AGcThreshold = 10000;
Yap_global->agc_hook = NULL; Yap_AGCHook = NULL;
#ifdef THREADS #ifdef THREADS
INIT_LOCK(Yap_global->thread_handles_lock); INIT_LOCK(Yap_ThreadHandlesLock);
#endif #endif
#if defined(YAPOR) || defined(TABLING) #if defined(YAPOR) || defined(TABLING)
@ -55,10 +55,10 @@ static void InitGlobal(void) {
#endif #endif
Yap_global->initialised = FALSE; Yap_Initialised = FALSE;
Yap_global->initialised_from_pl = FALSE; Yap_InitialisedFromPL = FALSE;
Yap_global->pl_argc = 0; Yap_PL_Argc = 0;
Yap_global->pl_argv = NULL; Yap_PL_Argv = NULL;
Yap_global->yap_halt_hook = NULL; Yap_HaltHooks = NULL;
} }

View File

@ -35,7 +35,7 @@
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->dlmalloc_lock); INIT_LOCK(DLMallocLock);
#endif #endif
#endif #endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO) #if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
@ -51,10 +51,10 @@
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->free_blocks_lock); INIT_LOCK(FreeBlocksLock);
INIT_LOCK(Yap_heap_regs->heap_used_lock); INIT_LOCK(HeapUsedLock);
INIT_LOCK(Yap_heap_regs->heap_top_lock); INIT_LOCK(HeapTopLock);
Yap_heap_regs->heap_top_owner = -1; HeapTopOwner = -1;
#endif #endif
@ -62,13 +62,13 @@
#endif #endif
Yap_heap_regs->execute_cpred_op_code = Yap_opcode(_execute_cpred); EXECUTE_CPRED_OP_CODE = Yap_opcode(_execute_cpred);
Yap_heap_regs->expand_op_code = Yap_opcode(_expand_index); EXPAND_OP_CODE = Yap_opcode(_expand_index);
Yap_heap_regs->fail_op = Yap_opcode(_op_fail); FAIL_OPCODE = Yap_opcode(_op_fail);
Yap_heap_regs->index_op = Yap_opcode(_index_pred); INDEX_OPCODE = Yap_opcode(_index_pred);
Yap_heap_regs->lockpred_op = Yap_opcode(_lock_pred); LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
Yap_heap_regs->orlast_op = Yap_opcode(_or_last); ORLAST_OPCODE = Yap_opcode(_or_last);
Yap_heap_regs->undef_op = Yap_opcode(_undef_p); UNDEF_OPCODE = Yap_opcode(_undef_p);
@ -80,100 +80,100 @@
#include "iatoms.h" #include "iatoms.h"
#ifdef EUROTRA #ifdef EUROTRA
Yap_heap_regs->term_dollar_u = MkAtomTerm(AtomDollarU); TermDollarU = MkAtomTerm(AtomDollarU);
#endif #endif
Yap_heap_regs->term_prolog = MkAtomTerm(AtomProlog); TermProlog = MkAtomTerm(AtomProlog);
Yap_heap_regs->term_refound_var = MkAtomTerm(AtomRefoundVar); TermReFoundVar = MkAtomTerm(AtomRefoundVar);
Yap_heap_regs->user_module = MkAtomTerm(AtomUser); USER_MODULE = MkAtomTerm(AtomUser);
Yap_heap_regs->idb_module = MkAtomTerm(AtomIDB); IDB_MODULE = MkAtomTerm(AtomIDB);
Yap_heap_regs->attributes_module = MkAtomTerm(AtomAttributes); ATTRIBUTES_MODULE = MkAtomTerm(AtomAttributes);
Yap_heap_regs->charsio_module = MkAtomTerm(AtomCharsio); CHARSIO_MODULE = MkAtomTerm(AtomCharsio);
Yap_heap_regs->terms_module = MkAtomTerm(AtomTerms); TERMS_MODULE = MkAtomTerm(AtomTerms);
Yap_heap_regs->system_module = MkAtomTerm(AtomSystem); SYSTEM_MODULE = MkAtomTerm(AtomSystem);
Yap_heap_regs->operating_system_module = MkAtomTerm(AtomOperatingSystemSupport); OPERATING_SYSTEM_MODULE = MkAtomTerm(AtomOperatingSystemSupport);
Yap_heap_regs->readutil_module = MkAtomTerm(AtomReadutil); READUTIL_MODULE = MkAtomTerm(AtomReadutil);
Yap_heap_regs->hacks_module = MkAtomTerm(AtomYapHacks); HACKS_MODULE = MkAtomTerm(AtomYapHacks);
Yap_heap_regs->arg_module = MkAtomTerm(AtomArg); ARG_MODULE = MkAtomTerm(AtomArg);
Yap_heap_regs->globals_module = MkAtomTerm(AtomNb); GLOBALS_MODULE = MkAtomTerm(AtomNb);
Yap_heap_regs->swi_module = MkAtomTerm(AtomSwi); SWI_MODULE = MkAtomTerm(AtomSwi);
Yap_heap_regs->dbload_module = MkAtomTerm(AtomDBLoad); DBLOAD_MODULE = MkAtomTerm(AtomDBLoad);
Yap_heap_regs->current_modules = NULL; CurrentModules = NULL;
Yap_InitModules(); Yap_InitModules();
Yap_heap_regs->execution_mode = INTERPRETED; Yap_ExecutionMode = INTERPRETED;
InitPredHash(); InitPredHash();
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
#endif #endif
Yap_heap_regs->preds_in_hash_table = 0; PredsInHashTable = 0;
Yap_heap_regs->creep_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomCreep,1),PROLOG_MODULE)); CreepCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomCreep,1),PROLOG_MODULE));
Yap_heap_regs->undef_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomUndefp,1),PROLOG_MODULE)); UndefCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomUndefp,1),PROLOG_MODULE));
Yap_heap_regs->spy_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomSpy,1),PROLOG_MODULE)); SpyCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomSpy,1),PROLOG_MODULE));
Yap_heap_regs->pred_fail = RepPredProp(PredPropByAtom(AtomFail,PROLOG_MODULE)); PredFail = RepPredProp(PredPropByAtom(AtomFail,PROLOG_MODULE));
Yap_heap_regs->pred_true = RepPredProp(PredPropByAtom(AtomTrue,PROLOG_MODULE)); PredTrue = RepPredProp(PredPropByAtom(AtomTrue,PROLOG_MODULE));
#ifdef COROUTINING #ifdef COROUTINING
Yap_heap_regs->wake_up_code = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomWakeUpGoal,2),PROLOG_MODULE)); WakeUpCode = RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomWakeUpGoal,2),PROLOG_MODULE));
#endif #endif
Yap_heap_regs->pred_goal_expansion = RepPredProp(PredPropByFunc(FunctorGoalExpansion,USER_MODULE)); PredGoalExpansion = RepPredProp(PredPropByFunc(FunctorGoalExpansion,USER_MODULE));
Yap_heap_regs->pred_meta_call = RepPredProp(PredPropByFunc(FunctorMetaCall,PROLOG_MODULE)); PredMetaCall = RepPredProp(PredPropByFunc(FunctorMetaCall,PROLOG_MODULE));
Yap_heap_regs->pred_dollar_catch = RepPredProp(PredPropByFunc(FunctorCatch,PROLOG_MODULE)); PredDollarCatch = RepPredProp(PredPropByFunc(FunctorCatch,PROLOG_MODULE));
Yap_heap_regs->pred_recorded_with_key = RepPredProp(PredPropByFunc(FunctorRecordedWithKey,PROLOG_MODULE)); PredRecordedWithKey = RepPredProp(PredPropByFunc(FunctorRecordedWithKey,PROLOG_MODULE));
Yap_heap_regs->pred_log_upd_clause = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE)); PredLogUpdClause = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
Yap_heap_regs->pred_log_upd_clause_erase = RepPredProp(PredPropByFunc(FunctorDoLogUpdClauseErase,PROLOG_MODULE)); PredLogUpdClauseErase = RepPredProp(PredPropByFunc(FunctorDoLogUpdClauseErase,PROLOG_MODULE));
Yap_heap_regs->pred_log_upd_clause0 = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE)); PredLogUpdClause0 = RepPredProp(PredPropByFunc(FunctorDoLogUpdClause,PROLOG_MODULE));
Yap_heap_regs->pred_static_clause = RepPredProp(PredPropByFunc(FunctorDoStaticClause,PROLOG_MODULE)); PredStaticClause = RepPredProp(PredPropByFunc(FunctorDoStaticClause,PROLOG_MODULE));
Yap_heap_regs->pred_throw = RepPredProp(PredPropByFunc(FunctorThrow,PROLOG_MODULE)); PredThrow = RepPredProp(PredPropByFunc(FunctorThrow,PROLOG_MODULE));
Yap_heap_regs->pred_handle_throw = RepPredProp(PredPropByFunc(FunctorHandleThrow,PROLOG_MODULE)); PredHandleThrow = RepPredProp(PredPropByFunc(FunctorHandleThrow,PROLOG_MODULE));
Yap_heap_regs->pred_is = RepPredProp(PredPropByFunc(FunctorIs,PROLOG_MODULE)); PredIs = RepPredProp(PredPropByFunc(FunctorIs,PROLOG_MODULE));
Yap_heap_regs->pred_safe_call_cleanup = RepPredProp(PredPropByFunc(FunctorSafeCallCleanup,PROLOG_MODULE)); PredSafeCallCleanup = RepPredProp(PredPropByFunc(FunctorSafeCallCleanup,PROLOG_MODULE));
Yap_heap_regs->pred_restore_regs = RepPredProp(PredPropByFunc(FunctorRestoreRegs,PROLOG_MODULE)); PredRestoreRegs = RepPredProp(PredPropByFunc(FunctorRestoreRegs,PROLOG_MODULE));
#ifdef YAPOR #ifdef YAPOR
Yap_heap_regs->pred_getwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE)); PredGetwork = RepPredProp(PredPropByAtom(AtomGetwork,PROLOG_MODULE));
Yap_heap_regs->pred_getwork_seq = RepPredProp(PredPropByAtom(AtomGetworkSeq,PROLOG_MODULE)); PredGetworkSeq = RepPredProp(PredPropByAtom(AtomGetworkSeq,PROLOG_MODULE));
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER #ifdef LOW_LEVEL_TRACER
Yap_heap_regs->yap_do_low_level_trace = FALSE; Yap_do_low_level_trace = FALSE;
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->low_level_trace_lock); INIT_LOCK(Yap_low_level_trace_lock);
#endif #endif
#endif #endif
Yap_heap_regs->clause_space = 0; Yap_ClauseSpace = 0;
Yap_heap_regs->index_space_Tree = 0; Yap_IndexSpace_Tree = 0;
Yap_heap_regs->index_space_EXT = 0; Yap_IndexSpace_EXT = 0;
Yap_heap_regs->index_space_SW = 0; Yap_IndexSpace_SW = 0;
Yap_heap_regs->lu_clause_space = 0; Yap_LUClauseSpace = 0;
Yap_heap_regs->lu_index_space_Tree = 0; Yap_LUIndexSpace_Tree = 0;
Yap_heap_regs->lu_index_space_CP = 0; Yap_LUIndexSpace_CP = 0;
Yap_heap_regs->lu_index_space_EXT = 0; Yap_LUIndexSpace_EXT = 0;
Yap_heap_regs->lu_index_space_SW = 0; Yap_LUIndexSpace_SW = 0;
Yap_heap_regs->dummycode->opc = Yap_opcode(_op_fail); DUMMYCODE->opc = Yap_opcode(_op_fail);
Yap_heap_regs->failcode->opc = Yap_opcode(_op_fail); FAILCODE->opc = Yap_opcode(_op_fail);
Yap_heap_regs->nocode->opc = Yap_opcode(_Nstop); NOCODE->opc = Yap_opcode(_Nstop);
InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail); InitEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail); InitEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail); InitOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
#ifdef BEAM #ifdef BEAM
Yap_heap_regs->beam_retry_code->opc = Yap_opcode(_beam_retry_code); BEAM_RETRY_CODE->opc = Yap_opcode(_beam_retry_code);
#endif /* BEAM */ #endif /* BEAM */
#ifdef YAPOR #ifdef YAPOR
Yap_heap_regs->seq_def = FALSE; SEQUENTIAL_IS_DEFAULT = FALSE;
InitOtaplInst(GETWORK,_getwork,PredGetwork); InitOtaplInst(GETWORK,_getwork,PredGetwork);
InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq); InitOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
Yap_heap_regs->getwork_first_time->opc = Yap_opcode(_getwork_first_time); GETWORK_FIRST_TIME->opc = Yap_opcode(_getwork_first_time);
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef TABLING #ifdef TABLING
InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail); InitOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail);
@ -185,121 +185,121 @@
Yap_heap_regs->debugger_p_before_spy = NULL; P_before_spy = NULL;
Yap_heap_regs->retry_recordedp_code = NULL; RETRY_C_RECORDEDP_CODE = NULL;
Yap_heap_regs->retry_recorded_k_code = NULL; RETRY_C_RECORDED_K_CODE = NULL;
Yap_heap_regs->system_profiling = FALSE; PROFILING = FALSE;
Yap_heap_regs->system_call_counting = FALSE; CALL_COUNTING = FALSE;
Yap_heap_regs->system_pred_goal_expansion_all = FALSE; PRED_GOAL_EXPANSION_ALL = FALSE;
Yap_heap_regs->system_pred_goal_expansion_func = FALSE; PRED_GOAL_EXPANSION_FUNC = FALSE;
Yap_heap_regs->system_pred_goal_expansion_on = FALSE; PRED_GOAL_EXPANSION_ON = FALSE;
Yap_heap_regs->compiler_optimizer_on = TRUE; optimizer_on = TRUE;
Yap_heap_regs->compiler_compile_mode = 0; compile_mode = 0;
Yap_heap_regs->compiler_profiling = FALSE; profiling = FALSE;
Yap_heap_regs->compiler_call_counting = FALSE; call_counting = FALSE;
Yap_heap_regs->compiler_compile_arrays = FALSE; compile_arrays = FALSE;
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->dbterms_list_lock); INIT_LOCK(DBTermsListLock);
#endif #endif
Yap_heap_regs->dbterms_list = NULL; DBTermsList = NULL;
Yap_heap_regs->expand_clauses_first = NULL; ExpandClausesFirst = NULL;
Yap_heap_regs->expand_clauses_last = NULL; ExpandClausesLast = NULL;
Yap_heap_regs->expand_clauses = 0; Yap_ExpandClauses = 0;
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->expand_clauses_list_lock); INIT_LOCK(ExpandClausesListLock);
INIT_LOCK(Yap_heap_regs->op_list_lock); INIT_LOCK(OpListLock);
#endif #endif
#ifdef DEBUG #ifdef DEBUG
Yap_heap_regs->new_cps = 0L; Yap_NewCps = 0L;
Yap_heap_regs->live_cps = 0L; Yap_LiveCps = 0L;
Yap_heap_regs->dirty_cps = 0L; Yap_DirtyCps = 0L;
Yap_heap_regs->freed_cps = 0L; Yap_FreedCps = 0L;
#endif #endif
Yap_heap_regs->expand_clauses_sz = 0L; Yap_expand_clauses_sz = 0L;
Yap_heap_regs->udi_control_blocks = NULL; UdiControlBlocks = NULL;
Yap_heap_regs->static_predicates_marked = FALSE; STATIC_PREDICATES_MARKED = FALSE;
Yap_heap_regs->IntKeys = NULL; INT_KEYS = NULL;
Yap_heap_regs->IntLUKeys = NULL; INT_LU_KEYS = NULL;
Yap_heap_regs->IntBBKeys = NULL; INT_BB_KEYS = NULL;
Yap_heap_regs->int_keys_size = INT_KEYS_DEFAULT_SIZE; INT_KEYS_SIZE = INT_KEYS_DEFAULT_SIZE;
Yap_heap_regs->int_keys_timestamp = 0L; INT_KEYS_TIMESTAMP = 0L;
Yap_heap_regs->int_bb_keys_size = INT_KEYS_DEFAULT_SIZE; INT_BB_KEYS_SIZE = INT_KEYS_DEFAULT_SIZE;
Yap_heap_regs->update_mode = UPDATE_MODE_LOGICAL; UPDATE_MODE = UPDATE_MODE_LOGICAL;
InitDBErasedMarker(); InitDBErasedMarker();
InitLogDBErasedMarker(); InitLogDBErasedMarker();
Yap_heap_regs->dead_static_clauses = NULL; DeadStaticClauses = NULL;
Yap_heap_regs->dead_mega_clauses = NULL; DeadMegaClauses = NULL;
Yap_heap_regs->dead_static_indices = NULL; DeadStaticIndices = NULL;
Yap_heap_regs->db_erased_list = NULL; DBErasedList = NULL;
Yap_heap_regs->db_erased_ilist = NULL; DBErasedIList = NULL;
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_heap_regs->dead_static_clauses_lock); INIT_LOCK(DeadStaticClausesLock);
INIT_LOCK(Yap_heap_regs->dead_mega_clauses_lock); INIT_LOCK(DeadMegaClausesLock);
INIT_LOCK(Yap_heap_regs->dead_static_indices_lock); INIT_LOCK(DeadStaticIndicesLock);
#endif #endif
#ifdef COROUTINING #ifdef COROUTINING
Yap_heap_regs->num_of_atts = 1; NUM_OF_ATTS = 1;
#endif #endif
InitFlags(); InitFlags();
Yap_heap_regs->op_list = NULL; OpList = NULL;
Yap_heap_regs->yap_streams = NULL; Stream = NULL;
Yap_heap_regs->n_of_file_aliases = 0; NOfFileAliases = 0;
Yap_heap_regs->sz_of_file_aliases = 0; SzOfFileAliases = 0;
Yap_heap_regs->file_aliases = NULL; FileAliases = NULL;
Yap_heap_regs->atprompt = AtomNil; AtPrompt = AtomNil;
Yap_heap_regs->char_conversion_table = NULL; CharConversionTable = NULL;
Yap_heap_regs->char_conversion_table2 = NULL; CharConversionTable2 = NULL;
Yap_heap_regs->parser_error_style = EXCEPTION_ON_PARSER_ERROR; ParserErrorStyle = EXCEPTION_ON_PARSER_ERROR;
Yap_heap_regs->yap_lib_dir = NULL; Yap_LibDir = NULL;
Yap_heap_regs->last_wtime = NULL; LastWtimePtr = NULL;
Yap_heap_regs->debugger_output_msg = 0L; output_msg = 0L;
#if LOW_PROF #if LOW_PROF
Yap_heap_regs->profiler_on = FALSE; ProfilerOn = FALSE;
Yap_heap_regs->offline_profiler = FALSE; Yap_OffLineProfiler = FALSE;
Yap_heap_regs->f_prof = NULL; FProf = NULL;
Yap_heap_regs->f_preds = NULL; FPreds = NULL;
Yap_heap_regs->prof_preds = 0L; ProfPreds = 0L;
#endif /* LOW_PROF */ #endif /* LOW_PROF */
Yap_heap_regs->foreign_code_loaded = NULL; ForeignCodeLoaded = NULL;
Yap_heap_regs->foreign_code_base = NULL; ForeignCodeBase = NULL;
Yap_heap_regs->foreign_code_top = NULL; ForeignCodeTop = NULL;
Yap_heap_regs->foreign_code_max = NULL; ForeignCodeMax = NULL;
Yap_heap_regs->yap_records = NULL; Yap_Records = NULL;
InitSWIAtoms(); InitSWIAtoms();
Yap_heap_regs->swi_blob_types = NULL; SWI_BlobTypes = NULL;
Yap_heap_regs->swi_blobs = NULL; SWI_Blobs = NULL;

View File

@ -33,7 +33,7 @@ static void RestoreGlobal(void) {
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_global->bgl); REINIT_LOCK(Yap_BGL);
#endif #endif
@ -47,7 +47,7 @@ static void RestoreGlobal(void) {
#ifdef THREADS #ifdef THREADS
REINIT_LOCK(Yap_global->thread_handles_lock); REINIT_LOCK(Yap_ThreadHandlesLock);
#endif #endif
#if defined(YAPOR) || defined(TABLING) #if defined(YAPOR) || defined(TABLING)

View File

@ -35,7 +35,7 @@
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->dlmalloc_lock); REINIT_LOCK(DLMallocLock);
#endif #endif
#endif #endif
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO) #if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
@ -51,24 +51,24 @@
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->free_blocks_lock); REINIT_LOCK(FreeBlocksLock);
REINIT_LOCK(Yap_heap_regs->heap_used_lock); REINIT_LOCK(HeapUsedLock);
REINIT_LOCK(Yap_heap_regs->heap_top_lock); REINIT_LOCK(HeapTopLock);
#endif #endif
#if USE_THREADED_CODE #if USE_THREADED_CODE
Yap_heap_regs->op_rtable = OpRTableAdjust(Yap_heap_regs->op_rtable); OP_RTABLE = OpRTableAdjust(OP_RTABLE);
#endif #endif
Yap_heap_regs->execute_cpred_op_code = Yap_opcode(_execute_cpred); EXECUTE_CPRED_OP_CODE = Yap_opcode(_execute_cpred);
Yap_heap_regs->expand_op_code = Yap_opcode(_expand_index); EXPAND_OP_CODE = Yap_opcode(_expand_index);
Yap_heap_regs->fail_op = Yap_opcode(_op_fail); FAIL_OPCODE = Yap_opcode(_op_fail);
Yap_heap_regs->index_op = Yap_opcode(_index_pred); INDEX_OPCODE = Yap_opcode(_index_pred);
Yap_heap_regs->lockpred_op = Yap_opcode(_lock_pred); LOCKPRED_OPCODE = Yap_opcode(_lock_pred);
Yap_heap_regs->orlast_op = Yap_opcode(_or_last); ORLAST_OPCODE = Yap_opcode(_or_last);
Yap_heap_regs->undef_op = Yap_opcode(_undef_p); UNDEF_OPCODE = Yap_opcode(_undef_p);
@ -80,27 +80,27 @@
#include "ratoms.h" #include "ratoms.h"
#ifdef EUROTRA #ifdef EUROTRA
Yap_heap_regs->term_dollar_u = AtomTermAdjust(Yap_heap_regs->term_dollar_u); TermDollarU = AtomTermAdjust(TermDollarU);
#endif #endif
Yap_heap_regs->term_prolog = AtomTermAdjust(Yap_heap_regs->term_prolog); TermProlog = AtomTermAdjust(TermProlog);
Yap_heap_regs->term_refound_var = AtomTermAdjust(Yap_heap_regs->term_refound_var); TermReFoundVar = AtomTermAdjust(TermReFoundVar);
Yap_heap_regs->user_module = AtomTermAdjust(Yap_heap_regs->user_module); USER_MODULE = AtomTermAdjust(USER_MODULE);
Yap_heap_regs->idb_module = AtomTermAdjust(Yap_heap_regs->idb_module); IDB_MODULE = AtomTermAdjust(IDB_MODULE);
Yap_heap_regs->attributes_module = AtomTermAdjust(Yap_heap_regs->attributes_module); ATTRIBUTES_MODULE = AtomTermAdjust(ATTRIBUTES_MODULE);
Yap_heap_regs->charsio_module = AtomTermAdjust(Yap_heap_regs->charsio_module); CHARSIO_MODULE = AtomTermAdjust(CHARSIO_MODULE);
Yap_heap_regs->terms_module = AtomTermAdjust(Yap_heap_regs->terms_module); TERMS_MODULE = AtomTermAdjust(TERMS_MODULE);
Yap_heap_regs->system_module = AtomTermAdjust(Yap_heap_regs->system_module); SYSTEM_MODULE = AtomTermAdjust(SYSTEM_MODULE);
Yap_heap_regs->operating_system_module = AtomTermAdjust(Yap_heap_regs->operating_system_module); OPERATING_SYSTEM_MODULE = AtomTermAdjust(OPERATING_SYSTEM_MODULE);
Yap_heap_regs->readutil_module = AtomTermAdjust(Yap_heap_regs->readutil_module); READUTIL_MODULE = AtomTermAdjust(READUTIL_MODULE);
Yap_heap_regs->hacks_module = AtomTermAdjust(Yap_heap_regs->hacks_module); HACKS_MODULE = AtomTermAdjust(HACKS_MODULE);
Yap_heap_regs->arg_module = AtomTermAdjust(Yap_heap_regs->arg_module); ARG_MODULE = AtomTermAdjust(ARG_MODULE);
Yap_heap_regs->globals_module = AtomTermAdjust(Yap_heap_regs->globals_module); GLOBALS_MODULE = AtomTermAdjust(GLOBALS_MODULE);
Yap_heap_regs->swi_module = AtomTermAdjust(Yap_heap_regs->swi_module); SWI_MODULE = AtomTermAdjust(SWI_MODULE);
Yap_heap_regs->dbload_module = AtomTermAdjust(Yap_heap_regs->dbload_module); DBLOAD_MODULE = AtomTermAdjust(DBLOAD_MODULE);
Yap_heap_regs->current_modules = ModEntryPtrAdjust(Yap_heap_regs->current_modules); CurrentModules = ModEntryPtrAdjust(CurrentModules);
@ -114,36 +114,36 @@
Yap_heap_regs->creep_code = PtoPredAdjust(Yap_heap_regs->creep_code); CreepCode = PtoPredAdjust(CreepCode);
Yap_heap_regs->undef_code = PtoPredAdjust(Yap_heap_regs->undef_code); UndefCode = PtoPredAdjust(UndefCode);
Yap_heap_regs->spy_code = PtoPredAdjust(Yap_heap_regs->spy_code); SpyCode = PtoPredAdjust(SpyCode);
Yap_heap_regs->pred_fail = PtoPredAdjust(Yap_heap_regs->pred_fail); PredFail = PtoPredAdjust(PredFail);
Yap_heap_regs->pred_true = PtoPredAdjust(Yap_heap_regs->pred_true); PredTrue = PtoPredAdjust(PredTrue);
#ifdef COROUTINING #ifdef COROUTINING
Yap_heap_regs->wake_up_code = PtoPredAdjust(Yap_heap_regs->wake_up_code); WakeUpCode = PtoPredAdjust(WakeUpCode);
#endif #endif
Yap_heap_regs->pred_goal_expansion = PtoPredAdjust(Yap_heap_regs->pred_goal_expansion); PredGoalExpansion = PtoPredAdjust(PredGoalExpansion);
Yap_heap_regs->pred_meta_call = PtoPredAdjust(Yap_heap_regs->pred_meta_call); PredMetaCall = PtoPredAdjust(PredMetaCall);
Yap_heap_regs->pred_dollar_catch = PtoPredAdjust(Yap_heap_regs->pred_dollar_catch); PredDollarCatch = PtoPredAdjust(PredDollarCatch);
Yap_heap_regs->pred_recorded_with_key = PtoPredAdjust(Yap_heap_regs->pred_recorded_with_key); PredRecordedWithKey = PtoPredAdjust(PredRecordedWithKey);
Yap_heap_regs->pred_log_upd_clause = PtoPredAdjust(Yap_heap_regs->pred_log_upd_clause); PredLogUpdClause = PtoPredAdjust(PredLogUpdClause);
Yap_heap_regs->pred_log_upd_clause_erase = PtoPredAdjust(Yap_heap_regs->pred_log_upd_clause_erase); PredLogUpdClauseErase = PtoPredAdjust(PredLogUpdClauseErase);
Yap_heap_regs->pred_log_upd_clause0 = PtoPredAdjust(Yap_heap_regs->pred_log_upd_clause0); PredLogUpdClause0 = PtoPredAdjust(PredLogUpdClause0);
Yap_heap_regs->pred_static_clause = PtoPredAdjust(Yap_heap_regs->pred_static_clause); PredStaticClause = PtoPredAdjust(PredStaticClause);
Yap_heap_regs->pred_throw = PtoPredAdjust(Yap_heap_regs->pred_throw); PredThrow = PtoPredAdjust(PredThrow);
Yap_heap_regs->pred_handle_throw = PtoPredAdjust(Yap_heap_regs->pred_handle_throw); PredHandleThrow = PtoPredAdjust(PredHandleThrow);
Yap_heap_regs->pred_is = PtoPredAdjust(Yap_heap_regs->pred_is); PredIs = PtoPredAdjust(PredIs);
Yap_heap_regs->pred_safe_call_cleanup = PtoPredAdjust(Yap_heap_regs->pred_safe_call_cleanup); PredSafeCallCleanup = PtoPredAdjust(PredSafeCallCleanup);
Yap_heap_regs->pred_restore_regs = PtoPredAdjust(Yap_heap_regs->pred_restore_regs); PredRestoreRegs = PtoPredAdjust(PredRestoreRegs);
#ifdef YAPOR #ifdef YAPOR
Yap_heap_regs->pred_getwork = PtoPredAdjust(Yap_heap_regs->pred_getwork); PredGetwork = PtoPredAdjust(PredGetwork);
Yap_heap_regs->pred_getwork_seq = PtoPredAdjust(Yap_heap_regs->pred_getwork_seq); PredGetworkSeq = PtoPredAdjust(PredGetworkSeq);
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef LOW_LEVEL_TRACER #ifdef LOW_LEVEL_TRACER
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->low_level_trace_lock); REINIT_LOCK(Yap_low_level_trace_lock);
#endif #endif
#endif #endif
@ -158,22 +158,22 @@
Yap_heap_regs->dummycode->opc = Yap_opcode(_op_fail); DUMMYCODE->opc = Yap_opcode(_op_fail);
Yap_heap_regs->failcode->opc = Yap_opcode(_op_fail); FAILCODE->opc = Yap_opcode(_op_fail);
Yap_heap_regs->nocode->opc = Yap_opcode(_Nstop); NOCODE->opc = Yap_opcode(_Nstop);
RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail); RestoreEnvInst(ENV_FOR_TRUSTFAIL,&TRUSTFAILCODE,_trust_fail,PredFail);
RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail); RestoreEnvInst(ENV_FOR_YESCODE,&YESCODE,_Ystop,PredFail);
RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail); RestoreOtaplInst(RTRYCODE,_retry_and_mark,PredFail);
#ifdef BEAM #ifdef BEAM
Yap_heap_regs->beam_retry_code->opc = Yap_opcode(_beam_retry_code); BEAM_RETRY_CODE->opc = Yap_opcode(_beam_retry_code);
#endif /* BEAM */ #endif /* BEAM */
#ifdef YAPOR #ifdef YAPOR
RestoreOtaplInst(GETWORK,_getwork,PredGetwork); RestoreOtaplInst(GETWORK,_getwork,PredGetwork);
RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq); RestoreOtaplInst(GETWORK_SEQ,_getwork_seq,PredGetworkSeq);
Yap_heap_regs->getwork_first_time->opc = Yap_opcode(_getwork_first_time); GETWORK_FIRST_TIME->opc = Yap_opcode(_getwork_first_time);
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef TABLING #ifdef TABLING
RestoreOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail); RestoreOtaplInst(LOAD_ANSWER,_table_load_answer,PredFail);
@ -185,10 +185,10 @@
Yap_heap_regs->debugger_p_before_spy = PtoOpAdjust(Yap_heap_regs->debugger_p_before_spy); P_before_spy = PtoOpAdjust(P_before_spy);
Yap_heap_regs->retry_recordedp_code = PtoOpAdjust(Yap_heap_regs->retry_recordedp_code); RETRY_C_RECORDEDP_CODE = PtoOpAdjust(RETRY_C_RECORDEDP_CODE);
Yap_heap_regs->retry_recorded_k_code = PtoOpAdjust(Yap_heap_regs->retry_recorded_k_code); RETRY_C_RECORDED_K_CODE = PtoOpAdjust(RETRY_C_RECORDED_K_CODE);
@ -203,7 +203,7 @@
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->dbterms_list_lock); REINIT_LOCK(DBTermsListLock);
#endif #endif
RestoreDBTermsList(); RestoreDBTermsList();
@ -211,8 +211,8 @@
RestoreExpandList(); RestoreExpandList();
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->expand_clauses_list_lock); REINIT_LOCK(ExpandClausesListLock);
REINIT_LOCK(Yap_heap_regs->op_list_lock); REINIT_LOCK(OpListLock);
#endif #endif
#ifdef DEBUG #ifdef DEBUG
@ -247,9 +247,9 @@
RestoreDBErasedList(); RestoreDBErasedList();
RestoreDBErasedIList(); RestoreDBErasedIList();
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_heap_regs->dead_static_clauses_lock); REINIT_LOCK(DeadStaticClausesLock);
REINIT_LOCK(Yap_heap_regs->dead_mega_clauses_lock); REINIT_LOCK(DeadMegaClausesLock);
REINIT_LOCK(Yap_heap_regs->dead_static_indices_lock); REINIT_LOCK(DeadStaticIndicesLock);
#endif #endif
#ifdef COROUTINING #ifdef COROUTINING
@ -260,7 +260,7 @@
Yap_heap_regs->op_list = OpListAdjust(Yap_heap_regs->op_list); OpList = OpListAdjust(OpList);
RestoreStreams(); RestoreStreams();
@ -269,17 +269,17 @@
RestoreAliases(); RestoreAliases();
Yap_heap_regs->atprompt = AtomAdjust(Yap_heap_regs->atprompt); AtPrompt = AtomAdjust(AtPrompt);
Yap_heap_regs->char_conversion_table = CodeCharPAdjust(Yap_heap_regs->char_conversion_table); CharConversionTable = CodeCharPAdjust(CharConversionTable);
Yap_heap_regs->char_conversion_table2 = CodeCharPAdjust(Yap_heap_regs->char_conversion_table2); CharConversionTable2 = CodeCharPAdjust(CharConversionTable2);
Yap_heap_regs->yap_lib_dir = CodeCharPAdjust(Yap_heap_regs->yap_lib_dir); Yap_LibDir = CodeCharPAdjust(Yap_LibDir);
Yap_heap_regs->last_wtime = CodeVoidPAdjust(Yap_heap_regs->last_wtime); LastWtimePtr = CodeVoidPAdjust(LastWtimePtr);
#if LOW_PROF #if LOW_PROF

View File

@ -126,6 +126,10 @@ fetch_name(Global) :-
fetch_name(Global) :- fetch_name(Global) :-
Global = "Yap_heap_regs->". Global = "Yap_heap_regs->".
fetch_name(Global,RField,_) :-
globals(worker_init), !,
append("FOREIGN(wid)->",RField,Global).
fetch_name(Global,_,Global).
% handle *field[4] % handle *field[4]
cut_c_stuff([0'*|Name], RName) :- !, % 'cut * cut_c_stuff([0'*|Name], RName) :- !, % 'cut *
@ -174,31 +178,31 @@ gen_hstruct(Inp,Out) :-
glue(Inp2, " ", Inp3), glue(Inp2, " ", Inp3),
gen_hstruct(Inp3,Out). gen_hstruct(Inp3,Out).
gen_hstruct(Inp,Out) :- gen_hstruct(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkAT", _]), !, split(Inp," ",[_, Field, MacroName, "MkAT", _]), !,
fetch_name(Global), fetch_name(Global,Field,MacroName),
append([" ",Global,Field," = AtomTermAdjust(Yap_heap_regs->",Field,");"], Out). append([" ",Global," = AtomTermAdjust(",Global,");"], Out).
gen_hstruct(Inp,Out) :- gen_hstruct(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkPred"| _]), !, split(Inp," ",[_, Field, MacroName, "MkPred"| _]), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField," = PtoPredAdjust(Yap_heap_regs->",RField,");"], Out). append([" ",Global," = PtoPredAdjust(",Global,");"], Out).
gen_hstruct(Inp,Out) :- gen_hstruct(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkOp", Name]), !, split(Inp," ",[_, Field, MacroName, "MkOp", Name]), !,
fetch_name(Global), fetch_name(Global,Field,MacroName),
append([" ",Global,Field," = Yap_opcode(",Name,");"], Out). append([" ",Global," = Yap_opcode(",Name,");"], Out).
gen_hstruct(Inp,Out) :- gen_hstruct(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkLock"]), !, split(Inp," ",[_, Field, MacroName, "MkLock"]), !,
fetch_name(Global), fetch_name(Global,Field,MacroName),
append([" REINIT_LOCK(",Global,Field,");"], Out). append([" REINIT_LOCK(",Global,");"], Out).
gen_hstruct(Inp,Out) :- gen_hstruct(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkRWLock"]), !, split(Inp," ",[_, Field, MacroName, "MkRWLock"]), !,
fetch_name(Global), fetch_name(Global,Field,MacroName),
append([" REINIT_RWLOCK(",Global,Field,");"], Out). append([" REINIT_RWLOCK(",Global,");"], Out).
gen_hstruct(Inp,Out) :- gen_hstruct(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkInstE",OP]), !, split(Inp," ",[_, Field, MacroName, "MkInstE",OP]), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField,"->opc = Yap_opcode(",OP,");"], Out). append([" ",Global,"->opc = Yap_opcode(",OP,");"], Out).
gen_hstruct(Inp,"") :- gen_hstruct(Inp,"") :-
split(Inp," ",[_, _, _, _]), !. split(Inp," ",[_, _, _, _]), !.
gen_hstruct(Inp,"") :- gen_hstruct(Inp,"") :-
@ -208,11 +212,11 @@ gen_hstruct(Inp,Restore) :-
append("Restore",_,Restore0), !, append("Restore",_,Restore0), !,
append([" ",Restore0,";"],Restore). %' append([" ",Restore0,";"],Restore). %'
gen_hstruct(Inp,Out) :- gen_hstruct(Inp,Out) :-
split(Inp," ",[_, Field, _, _, Adjust]), split(Inp," ",[_, Field, MacroName, _, Adjust]),
append(Adjust,"Adjust",_), !, append(Adjust,"Adjust",_), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField," = ",Adjust,"(",Global,RField,");"], Out). append([" ",Global," = ",Adjust,"(",Global,");"], Out).
gen_hstruct(Inp,_) :- gen_hstruct(Inp,_) :-
split(Inp," ",[_, _, _| _]), split(Inp," ",[_, _, _| _]),
format(user_error,"OOPS: could not gen_hstruct for ~s~n",[Inp]). format(user_error,"OOPS: could not gen_hstruct for ~s~n",[Inp]).
@ -261,48 +265,48 @@ gen_init(Inp,Init) :-
append("Yap_Init",_,Init0), !, append("Yap_Init",_,Init0), !,
append([" ",Init0,";"],Init). append([" ",Init0,";"],Init).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkAT", AtomName]), !, split(Inp," ",[_, Field, MacroName, "MkAT", AtomName]), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField," = MkAtomTerm(",AtomName,");"], Out). append([" ",Global," = MkAtomTerm(",AtomName,");"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkOp", Name]), !, split(Inp," ",[_, Field, MacroName, "MkOp", Name]), !,
fetch_name(Global), fetch_name(Global,Field,MacroName),
append([" ",Global,Field," = Yap_opcode(",Name,");"], Out). append([" ",Global," = Yap_opcode(",Name,");"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkLock"]), !, split(Inp," ",[_, Field, MacroName, "MkLock"]), !,
fetch_name(Global), fetch_name(Global,Field,MacroName),
append([" INIT_LOCK(",Global,Field,");"], Out). append([" INIT_LOCK(",Global,");"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkRWLock"]), !, split(Inp," ",[_, Field, MacroName, "MkRWLock"]), !,
fetch_name(Global), fetch_name(Global,Field,MacroName),
append([" INIT_RWLOCK(",Global,Field,");"], Out). append([" INIT_RWLOCK(",Global,");"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkInstE",OP]), !, split(Inp," ",[_, Field, MacroName, "MkInstE",OP]), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField,"->opc = Yap_opcode(",OP,");"], Out). append([" ",Global,"->opc = Yap_opcode(",OP,");"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkPred", Atom, "0", Module]), !, split(Inp," ",[_, Field, MacroName, "MkPred", Atom, "0", Module]), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField," = RepPredProp(PredPropByAtom(",Atom,",",Module,"));"], Out). append([" ",Global," = RepPredProp(PredPropByAtom(",Atom,",",Module,"));"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkPred", Atom, Arity, Module]), !, split(Inp," ",[_, Field, MacroName, "MkPred", Atom, Arity, Module]), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField," = RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,"));"], Out). append([" ",Global," = RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,"));"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, "MkPred", Fun, Module]), !, split(Inp," ",[_, Field, MacroName, "MkPred", Fun, Module]), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField," = RepPredProp(PredPropByFunc(",Fun,",",Module,"));"], Out). append([" ",Global," = RepPredProp(PredPropByFunc(",Fun,",",Module,"));"], Out).
gen_init(Inp,Out) :- gen_init(Inp,Out) :-
split(Inp," ",[_, Field, _, F0|_]), split(Inp," ",[_, Field, MacroName, F0|_]),
append("=",F,F0), !, append("=",F,F0), !,
cut_c_stuff(Field, RField), cut_c_stuff(Field, RField),
fetch_name(Global), fetch_name(Global,RField,MacroName),
append([" ",Global,RField," = ",F,";"], Out). append([" ",Global," = ",F,";"], Out).
gen_init(Inp,_) :- gen_init(Inp,_) :-
split(Inp," ",[_, _, _| _]), split(Inp," ",[_, _, _| _]),
format(user_error,"OOPS: could not gen_init for ~s~n",[Inp]). format(user_error,"OOPS: could not gen_init for ~s~n",[Inp]).