Ejemplo n.º 1
0
MR_Next
MR_trace_cmd_diff(char **words, int word_count, MR_TraceCmdInfo *cmd,
                  MR_EventInfo *event_info, MR_Code **jumpaddr)
{
    MR_Unsigned start;
    MR_Unsigned max;
    char        *name1;
    char        *name2;
    MR_TypeInfo type_info1;
    MR_TypeInfo type_info2;
    MR_Word     value1;
    MR_Word     value2;
    MR_Word     univ1;
    MR_Word     univ2;
    const char  *problem1;
    const char  *problem2;
    MR_bool     bad_subterm1;
    MR_bool     bad_subterm2;

    start = 0;
    max = 20;
    if (! MR_trace_options_diff(&start, &max, &words, &word_count)) {
        /* the usage message has already been printed */
        return KEEP_INTERACTING;
    } else if (word_count != 3) {
        MR_trace_usage_cur_cmd();
        return KEEP_INTERACTING;
    }

    name1 = words[1];
    name2 = words[2];
    problem1 = MR_trace_parse_lookup_var_path(name1, &type_info1, &value1,
               &bad_subterm1);
    problem2 = MR_trace_parse_lookup_var_path(name2, &type_info2, &value2,
               &bad_subterm2);
    if (problem1 != NULL) {
        fflush(MR_mdb_out);
        fprintf(MR_mdb_err, "mdb: %s%s.\n",
                (bad_subterm1? "arg1: there is no path " : ""), problem1);
        return KEEP_INTERACTING;
    }
    if (problem2 != NULL) {
        fflush(MR_mdb_out);
        fprintf(MR_mdb_err, "mdb: %s%s.\n",
                (bad_subterm2? "arg2: there is no path " : ""), problem2);
        return KEEP_INTERACTING;
    }

    MR_TRACE_CALL_MERCURY(
        MR_new_univ_on_hp(univ1, type_info1, value1);
        MR_new_univ_on_hp(univ2, type_info2, value2);
        ML_report_diffs(start, max, univ1, univ2);
    );
Ejemplo n.º 2
0
MR_bool
MR_trace_get_action(MR_IoActionNum action_number, MR_ConstString *proc_name_ptr,
    MR_Word *is_func_ptr, MR_Word *arg_list_ptr)
{
    const MR_TableIoDecl    *table_io_decl;
    const MR_ProcLayout     *proc_layout;
    MR_ConstString          proc_name;
    MR_Word                 is_func;
    MR_Word                 arg_list;
    MR_Word                 arg;
    int                     filtered_arity;
    int                     arity;
    int                     hv;
    MR_TrieNode             answer_block_trie;
    MR_Word                 *answer_block;
    MR_TypeInfo             *type_params;
    MR_TypeInfo             type_info;

    if (! (MR_io_tabling_start <= action_number
        && action_number < MR_io_tabling_counter_hwm))
    {
        return MR_FALSE;
    }

    MR_TABLE_START_INT(NULL, MR_tabledebug, MR_FALSE,
        answer_block_trie, (MR_TrieNode) &MR_io_tabling_pointer,
        MR_io_tabling_start, action_number);
    answer_block = answer_block_trie->MR_answerblock;

    if (answer_block == NULL) {
        return MR_FALSE;
    }

    table_io_decl = (const MR_TableIoDecl *) answer_block[0];
    proc_layout = table_io_decl->MR_table_io_decl_proc;
    filtered_arity = table_io_decl->MR_table_io_decl_filtered_arity;

    MR_generate_proc_name_from_layout(proc_layout, &proc_name, &arity,
        &is_func);

    type_params = MR_materialize_answer_block_type_params(
        table_io_decl->MR_table_io_decl_type_params, answer_block,
        filtered_arity);

    MR_restore_transient_hp();
    arg_list = MR_list_empty();
    MR_save_transient_hp();
    for (hv = filtered_arity; hv >= 1; hv--) {
        type_info = MR_create_type_info(type_params,
            table_io_decl->MR_table_io_decl_ptis[hv - 1]);
        MR_restore_transient_hp();
        MR_new_univ_on_hp(arg, type_info, answer_block[hv]);
        arg_list = MR_univ_list_cons(arg, arg_list);
        MR_save_transient_hp();
    }

    MR_free(type_params);

    *proc_name_ptr = proc_name;
    *is_func_ptr = is_func;
    *arg_list_ptr = arg_list;
    return MR_TRUE;
}
Ejemplo n.º 3
0
MR_bool
MR_trace_get_action(MR_IoActionNum action_number, MR_ConstString *proc_name_ptr,
    MR_Word *is_func_ptr, MR_bool *have_arg_infos_ptr, MR_Word *arg_list_ptr)
{
    const MR_TableIoEntry   *table_io_entry;
    const MR_ProcLayout     *proc_layout;
    MR_ConstString          proc_name;
    MR_Word                 is_func;
    int                     arity;
    int                     hv;
    MR_TrieNode             answer_block_trie;
    MR_Word                 *answer_block;

    if (! (MR_io_tabling_start <= action_number
        && action_number < MR_io_tabling_counter_hwm))
    {
        return MR_FALSE;
    }

    MR_TABLE_START_INT(NULL, MR_tabledebug, MR_FALSE,
        answer_block_trie, (MR_TrieNode) &MR_io_tabling_pointer,
        MR_io_tabling_start, action_number);
    answer_block = answer_block_trie->MR_answerblock;

    if (answer_block == NULL) {
        return MR_FALSE;
    }

    table_io_entry = (const MR_TableIoEntry *) answer_block[0];
    proc_layout = table_io_entry->MR_table_io_entry_proc;
    MR_generate_proc_name_from_layout(proc_layout, &proc_name, &arity,
        &is_func);
    *proc_name_ptr = proc_name;
    *is_func_ptr = is_func;

    if (table_io_entry->MR_table_io_entry_have_arg_infos) {
        int         filtered_arity;
        MR_Word     arg_list;
        MR_Word     arg;
        MR_TypeInfo *type_params;
        MR_TypeInfo type_info;

        *have_arg_infos_ptr = MR_TRUE;
        filtered_arity = table_io_entry->MR_table_io_entry_num_ptis;
        type_params = MR_materialize_answer_block_type_params(
            table_io_entry->MR_table_io_entry_type_params, answer_block,
            filtered_arity);

        MR_restore_transient_hp();
        arg_list = MR_list_empty();
        MR_save_transient_hp();
        for (hv = filtered_arity; hv >= 1; hv--) {
            type_info = MR_create_type_info(type_params,
                table_io_entry->MR_table_io_entry_ptis[hv - 1]);
            MR_restore_transient_hp();
            MR_new_univ_on_hp(arg, type_info, answer_block[hv]);
            arg_list = MR_univ_list_cons(arg, arg_list);
            MR_save_transient_hp();
        }

        MR_free(type_params);
        *arg_list_ptr = arg_list;
    } else {
        *have_arg_infos_ptr = MR_FALSE;
        // *arg_list_ptr is not meaningful when *have_arg_infos_ptr is false,
        // but setting it to the empty list makes it easier to catch any
        // caller that ignores that fact.
        *arg_list_ptr = MR_list_empty();
    }

    return MR_TRUE;
}