static void handle_term(CTXTdecl void* user_data, raptor_statement* quad) { struct raptor_node *node = malloc(sizeof(struct raptor_node)); // build a prolog term node->subject = build_term(quad->subject); node->predicate = build_term(quad->predicate); node->object = build_term(quad->object); node->graph = build_term(quad->graph); if(tail == NULL) { node->prev = NULL; node->next = NULL; tail = node; head = node; } else { node->next = tail; node->prev = NULL; tail->prev = node; tail = node; } }
int test_pp_main(void) { yices_init(); test_pp(build_term()); yices_exit(); return 0; }
int gotcha_diag(diagnostic_problem problem, const_tv_term alpha) { priority_queue opened; gotcha_node initial; dnf_tree consistent_input; tv_term_list_list systems; unsigned int old_diagnoses; int terminate = 0; int result = 1; diagnostic_problem_reset(problem); sort_int_list(alpha->neg); sort_int_list(alpha->pos); start_stopwatch("observation filtering time"); consistent_input = dnf_tree_filter(dnf_tree_copy(problem->u.tv_tdnf_sd.model), alpha); stop_stopwatch("observation filtering time"); systems = new_tv_term_list_list(); get_systems(consistent_input, systems); /* Start the timer. */ start_stopwatch("search time"); opened = priority_queue_new(cmp_nodes, (priority_queue_element_destroy_func_t)gotcha_node_free, (void *)systems->sz); initial = gotcha_node_new(systems->sz); priority_queue_push(opened, initial); increase_int_counter("pushed"); maximize_int_counter("max", 1); while (!terminate && !priority_queue_empty(opened)) { gotcha_node current = priority_queue_pop(opened); candidate_found(current->cardinality); if (is_terminate()) { gotcha_node_free(current); break; } if (current->depth != 0) { /* The root node has no siblings. */ if (!enqueue_sibling(problem, opened, current, systems)) { result = 0; gotcha_node_free(current); break; } } if (is_diagnosis(current, systems)) { tv_term diagnosis = build_term(current, systems); if (NULL == diagnosis) { result = 0; gotcha_node_free(current); break; } old_diagnoses = problem->diagnoses->sz; if (!add_diagnosis_from_tv_term(problem, diagnosis, &terminate, 1)) { result = 0; rfre_tv_term(diagnosis); gotcha_node_free(current); break; } if (cones != NULL && problem->diagnoses->sz - 1 == old_diagnoses) { assert(problem->diagnoses->sz > 0); /* @todo: Fix the termination here. */ expand_cone_exhaustive(cones, alpha, problem->diagnoses->arr[problem->diagnoses->sz - 1]); } rfre_tv_term(diagnosis); gotcha_node_free(current); } else { if (!enqueue_next_best_state(problem, opened, current, systems)) { result = 0; gotcha_node_free(current); break; } } } priority_queue_free(opened); fre_tv_term_list_list(systems); /* Stop the timer. */ stop_stopwatch("search time"); dnf_tree_free(consistent_input); return result; }
void mainwindow_create_tab(void) { GtkWidget* tmp_term = build_term(); GtkVScrollbar *sbar= NULL; GtkHBox *tmp_box = GTK_HBOX(gtk_hbox_new(FALSE, 0)); if (conf_get_scrollbar() == -1) gtk_box_pack_start(GTK_BOX(tmp_box), tmp_term, TRUE, TRUE, 0); else if (conf_get_scrollbar() == POS_LEFT) { sbar = GTK_VSCROLLBAR(gtk_vscrollbar_new(vte_terminal_get_adjustment( VTE_TERMINAL(tmp_term)))); gtk_box_pack_start(GTK_BOX(tmp_box), GTK_WIDGET(sbar), FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(tmp_box), GTK_WIDGET(tmp_term), TRUE, TRUE, 0); } else // (conf_get_scrollbar() == POS_RIGHT) { sbar = GTK_VSCROLLBAR(gtk_vscrollbar_new(vte_terminal_get_adjustment( VTE_TERMINAL(tmp_term)))); gtk_box_pack_start(GTK_BOX(tmp_box), GTK_WIDGET(tmp_term), TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(tmp_box), GTK_WIDGET(sbar), FALSE, FALSE, 0); } char buffer [100]; sprintf(buffer, "%s %d", conf_get_term_name(), activetab + 1); GtkLabel* tmp_label = GTK_LABEL(gtk_label_new(buffer)); if (conf_get_opacity() < 100) { if (screen_is_composited) { vte_terminal_set_background_transparent(VTE_TERMINAL(tmp_term), FALSE); vte_terminal_set_opacity(VTE_TERMINAL(tmp_term), conf_get_opacity()/100 * 0xffff); } else { vte_terminal_set_background_saturation(VTE_TERMINAL(tmp_term), 1.0 - conf_get_opacity()/100); if (conf_get_bg_image() == NULL) vte_terminal_set_background_transparent(VTE_TERMINAL(tmp_term), TRUE); } } if (conf_get_opacity() < 100 && screen_is_composited) { vte_terminal_set_background_transparent(VTE_TERMINAL(tmp_term), FALSE); vte_terminal_set_opacity(VTE_TERMINAL(tmp_term), conf_get_opacity()/100 * 0xffff); } g_signal_connect(G_OBJECT(tmp_term), "window-title-changed", G_CALLBACK(mainwindow_window_title_changed), tmp_label); g_array_append_val(tabs, tmp_term); tabcount++; gtk_widget_show_all(GTK_WIDGET(tmp_box)); gtk_notebook_append_page(tabbar, GTK_WIDGET(tmp_box), GTK_WIDGET(tmp_label)); if (conf_get_tab_fill()) gtk_container_child_set(GTK_CONTAINER(tabbar), GTK_WIDGET(tmp_box), "tab-expand", TRUE, "tab-fill", TRUE, NULL); if (conf_get_show_tab() == TABS_ONE&& tabcount > 1) gtk_notebook_set_show_tabs(tabbar, TRUE); activetab = tabcount - 1; gtk_notebook_set_current_page(tabbar, activetab); }