Ejemplo n.º 1
0
static errval_t run_eclipse(struct oct_query_state* st)
{
    assert(st != NULL);
    long int qid;

    // Contains Queue ID in case of PFLUSHIO
    ec_ref retval = ec_ref_create_newvar();
    //ec_post_goal(ec_term(ec_did("flush", 1), ec_long(1)));
    //ec_post_goal(ec_term(ec_did("flush", 1), ec_long(2)));
    //ec_post_goal(ec_term(ec_did("garbage_collect", 0)));
    while ((st->exec_res = ec_resume1(retval)) == PFLUSHIO) {
        ec_get_long(ec_ref_get(retval), &qid);

        switch (qid) {
        case STDOUT_QID:
            read_eclipse_queue(STDOUT_QID, &st->std_out);
            break;

        case STDERR_QID:
            read_eclipse_queue(STDERR_QID, &st->std_err);
            break;
        }
    }

    // atm. ignore all subsequent results
    if (st->exec_res == PSUCCEED) {
        ec_cut_to_chp(retval);
        ec_resume1(retval);
    }

    ec_ref_destroy(retval);

    errval_t err = transform_ec_error(st->exec_res);
    if (err_no(err) == SKB_ERR_EXECUTION) {
        err = err_push(err, OCT_ERR_ENGINE_FAIL);
    }

    return err;
}
Ejemplo n.º 2
0
static void
free_prop_value(int prop_name, pword *prop_value)
{
    switch(prop_name)
    {
    case GLOBVAR_PROP:
	if (IsGlobalPrologRef(prop_value)) {
	    ec_ref_destroy((ec_ref) prop_value->val.wptr);
	    prop_value->val.wptr = NULL;
	}
	/* If we are erasing the last global ref, decrement the global index */
	else if (IsGlobalPrologRefIndex(prop_value) &&
		prop_value->val.nint == (GlobalVarIndex - 1))
	{
	    GlobalVarIndex--;
	}
	else
	{
	    free_heapterm(prop_value);
	}
	break;

    case ARRAY_PROP:
	free_array(prop_value);
	break;

    case IDB_PROP:
    {
	extern t_ext_type heap_rec_header_tid;
	heap_rec_header_tid.free((t_ext_ptr)prop_value->val.wptr);
	break;
    }

    case HTABLE_PROP:
    {
	extern t_ext_type heap_htable_tid;
	heap_htable_tid.free((t_ext_ptr)prop_value->val.wptr);
	break;
    }

    case SHELF_PROP:
    {
	extern t_ext_type heap_array_tid;
	heap_array_tid.free((t_ext_ptr)prop_value->val.wptr);
	break;
    }

    case MODULE_PROP:
    case TRANS_PROP:
    case WRITE_TRANS_PROP:
    case GOAL_TRANS_PROP:
    case WRITE_GOAL_TRANS_PROP:
    case CLAUSE_TRANS_PROP:
    case WRITE_CLAUSE_TRANS_PROP:
	hg_free((generic_ptr)prop_value->val.ptr);
	break;

    case EVENT_PROP:
    case STREAM_PROP:
    case PREFIX_PROP:
    case INFIX_PROP:
    case POSTFIX_PROP:
    case SYSCALL_PROP:
	break;

    default:
	p_fprintf(current_err_, "Unknown property type %d in free_prop_value()\n", prop_name);
	ec_flush(current_err_);
	break;
    }
}