static void initTables(void) { var_tab = ATtableCreate(TABLESIZE,75); if (!var_tab) ATerror("Table is not allocated"); par_tab = ATtableCreate(TABLESIZE,75); if (!par_tab) ATerror("Table is not allocated"); }
static void SG_AmbiTablesCreate() { if (cluster_table || index_table) { SG_AmbiTablesDestroy(); } cluster_table = ATtableCreate(4096, 75); index_table = ATtableCreate(4096, 75); }
int main(int argc, char *argv[]) { ATerm bottomOfStack; int cid; ATBinit(argc, argv, &bottomOfStack); EM_initEditorManagerApi(); sessions = ATtableCreate(INITIAL_TABLE_SIZE, TABLE_RESIZE_PERCENTAGE); bindings = ATtableCreate(INITIAL_TABLE_SIZE, TABLE_RESIZE_PERCENTAGE); cid = ATBconnect(NULL, NULL, -1, editor_manager_handler); return ATBeventloop(); }
void *_create_table(void) { if(ST_table_table == NULL) ST_table_table = ATtableCreate(100, 80); if(ST_free_table >= NR_TABLES - 1) { ATfprintf(stderr, "create-table: too many tables\n"); exit(1); } /* ATfprintf(stderr, "<create-table>%t = %d\n", Ttop(), ST_free_table); */ ST_tables[ST_free_table] = ATtableCreate(117,75); ATtablePut(ST_table_table, Ttop(), (ATerm)ATmakeInt(ST_free_table)); ST_free_table++; return NULL; }
static void register_strategies (void) { int initial_size = 117; int max_load = 75; struct str_closure * closures; int closures_index = 0; if((strategy_table == NULL)) strategy_table = ATtableCreate(initial_size, max_load); closures = (struct str_closure*) malloc((sizeof(struct str_closure) * 3)); if((closures == NULL)) { perror("malloc error for registration of dynamic strategies"); exit(1); } closures[closures_index].fun = &(parse_stratego_file_0_0); closures[closures_index].sl = NULL; SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("parse_stratego_file_0_0", 0, ATtrue)), &(closures[closures_index])); closures_index++; closures[closures_index].fun = &(do_parse_0_0); closures[closures_index].sl = NULL; SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("do_parse_0_0", 0, ATtrue)), &(closures[closures_index])); closures_index++; closures[closures_index].fun = &(main_0_0); closures[closures_index].sl = NULL; SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("main_0_0", 0, ATtrue)), &(closures[closures_index])); closures_index++; }
ATerm ATsubstVar(ATerm t, ATerm var, ATerm s) { ATerm result; ATbool table_nonempty=ATfalse; if (first_subst_call) { first_subst_call=0; Subst=ATtableCreate(16,40); } result = substVar_rec(t,var,s,&table_nonempty); if (table_nonempty) ATtableReset(Subst); return result; }
ATbool ATunifySystem(ATermStack system,ATermSubst sigma) { /* Solves {system[0]=system[1], ...,system[2n-2]=system[2n-1]} - returns 0: t1=t2 is not unifiable; sigma is reset. - returns 1: ATermSubst represents the mgu {X1->t1,..,Xn->tn} This implements the Pascal version of Baader/Nipkow. (Linear space, nearly linear time) - ATermTable equivalence contains the Union/Find structure - ATermStack assigned contains the domain of the solution First, the system is solved without occur-check Subsequently, a substitution is computed, with loop detection. */ static char first_call = 1; char unifiable = 1; if (first_call) { first_call=0; assigned = ATstackCreate(40); equivalence = ATtableCreate(40,40); } assert((!sigma) || (ATstackDepth(sigma)==0)); assert(ATstackDepth(assigned)==0); assert(ATisEmpty(ATtableKeys(equivalence))); while (ATstackDepth(system)>0) { ATerm t1=find(ATstackPop(system)); ATerm t2=find(ATstackPop(system)); int i,n; if (t1==t2) continue; if (ATisVariable(t2)) { ATerm t3=t1; t1=t2; t2=t3; } if (ATisVariable(t1)) { ATstackPush(assigned,t1); ATtablePut(equivalence,t1,t2); /* ATprintf("%t->%t\n",t1,t2); */ } else { /* both t1 and t2 start with function symbol. */ Symbol s1 = ATgetSymbol(t1); Symbol s2 = ATgetSymbol(t2); if (s1!=s2) { unifiable=0; break; } else { n = ATgetArity(s1); ATtablePut(equivalence,t1,t2); /* note: forget about cardinality */ for (i=0;i<n;i++) { ATstackPush(system,ATgetArgument(t1,i)); ATstackPush(system,ATgetArgument(t2,i)); } } } } if (unifiable) return unfold_solution(sigma); else { ATstackReset(system); ATstackReset(assigned); ATtableReset(equivalence); return ATfalse; } }
ATerm ATsubstitute(ATerm t, ATermSubst sigma) { ATerm result; ATbool table_nonempty=ATfalse; if (first_subst_call) { first_subst_call=0; Subst=ATtableCreate(16,40); } result = substitute_rec(t,sigma,&table_nonempty); if (table_nonempty) ATtableReset(Subst); return result; }
PT_Tree PT_findTreeParent(PT_Tree needle, PT_Tree haystack) { PT_Tree result; if (findParentCache == NULL) { findParentCache = ATtableCreate(1024, 75); NeedleNotHere = ATparse("needle-not-here"); ATprotect(&NeedleNotHere); } result = PT_findTreeParentRecursive(needle, haystack); ATtableReset(findParentCache); return result; }
ATbool RWinitialize(ATerm adt) { if (!caseFlag #ifdef DYNLINK || tasks == &RWWtasks || tasks == &RWtasks #endif ) { rewrite = tasks->RWrewrite; rewritelist = tasks->RWrewriteList; } else { rewrite = CaseRewrite; rewritelist = CaseRewriteList; norm = ATtableCreate(100, 50); } return tasks->RWinitialize(adt); }
static void createMappingToPT(SDF_ProductionList productions) { mapping = ATtableCreate(1024, 75); while (SDF_hasProductionListHead(productions)) { SDF_Production prod = SDF_getProductionListHead(productions); if (SDF_isProductionProd(prod)) { PT_Production ptprod = SDFProductionToPtProduction(prod); if (ptprod) { ATtablePut(mapping, (ATerm) normalizeProduction(ptprod), (ATerm) prod); } } if (!SDF_hasProductionListTail(productions)) { break; } else { productions = SDF_getProductionListTail(productions); } } }
ACB new_acb(ACData agent, ACData action) { ACCACB acb = (ACCACB)malloc(sizeof(struct accacb)); INIT_EXCEPTION_STACK(acb->exception_stack); INIT_DATA_STACK(acb->result); INIT_DATA_STACK(acb->data); acb->data = ATmakeList0(); acb->scope = ATmakeList0(); acb->saved_data = ATmakeList0(); acb->saved_scope = ATmakeList0(); ATprotect(&(acb->result)); ATprotect(&(acb->data)); ATprotect(&(acb->scope)); ATprotect(&(acb->saved_data)); ATprotect(&(acb->saved_scope)); acb->tagged_buffer = ATtableCreate(100, 80); acb->agent = agent; acb->action = action; ATprotect(&(acb->agent)); ATprotect(&(acb->action)); acb->return_stack.top = NULL; acb->exit_status = NORMAL_OUTCOME; acb->prev = NULL; return acb; }
static char unfold_solution(ATermSubst sigma) { /* - makes assigned, solution and equivalence empty - doesn't alter equivalence, except shortening find paths - returns 1: unifiable; sigma contains solution (except when NULL) - returns 0: not unifiable; sigma is empty Note: unfolding is also needed if sigma=NULL to detect loops. */ int i; ATerm t; char unifiable=1; static char first_call=1; if (first_call) { first_call = 0; loop_detection=ATindexedSetCreate(64,50); solution = ATtableCreate(64,50); } assert(ATisEmpty(ATtableKeys(solution))); for (i=ATstackDepth(assigned)-1;i>=0;i--) { ATerm x = ATstackPop(assigned); assert(ATisEmpty(ATindexedSetElements(loop_detection))); t = unfold_rec(find(x)); if (t && sigma) ATstackSet(sigma,ATgetInt((ATermInt)x),t); else { unifiable=0; break; } } ATtableReset(solution); ATtableReset(equivalence); if (unifiable) return ATtrue; else { ATstackReset(assigned); if (sigma) ATstackReset(sigma); return ATfalse; } }
ATRelationStore ATR_createRelationStore() { return ATtableCreate(RELATION_STORE_SIZE, RELATION_STORE_LOAD_PCT); }
Table T_createTable() { return (Table)ATtableCreate(TABLE_SIZE, TABLE_RESIZE_QUOTIENT); }