예제 #1
0
void
prim_subtract(PRIM_PROTOTYPE)
{
	CHECKOP(2);
	oper1 = POP();
	oper2 = POP();
	if (!arith_type(oper2, oper1))
		abort_interp("Invalid argument type.");
	if ((oper1->type == PROG_FLOAT) || (oper2->type == PROG_FLOAT)) {
		tf1 = (oper2->type == PROG_FLOAT) ? oper2->data.fnumber : oper2->data.number;
		tf2 = (oper1->type == PROG_FLOAT) ? oper1->data.fnumber : oper1->data.number;
		if (!nogood(tf1) && !nogood(tf2)) {
			fresult = tf1 - tf2;
		} else {
			fresult = 0.0;
			fr->error.error_flags.f_bounds = 1;
		}
	} else {
		result = oper2->data.number - oper1->data.number;
		tl = (double) oper2->data.number - (double) oper1->data.number;
		if (!arith_good(tl))
			fr->error.error_flags.i_bounds = 1;
	}
	tmp = (oper2->type == PROG_FLOAT || oper1->type == PROG_FLOAT) ? PROG_FLOAT : oper2->type;
	CLEAR(oper1);
	CLEAR(oper2);
	if (tmp == PROG_FLOAT)
		push(arg, top, tmp, MIPSCAST & fresult);
	else
		push(arg, top, tmp, MIPSCAST & result);
}
예제 #2
0
파일: atms.c 프로젝트: abfeldman/lydia
static void update(atms tms, trie L, atms_node n)
{
    register unsigned int ix;

    atms_justification J;

    trie_remove_subsumed_trie(L, n->label);
    trie_remove_subsumed_trie(n->label, L);
    trie_add_trie(n->label, L);

    if (n->index == 0) { /* This is a nogood. */
        nogood(tms, L);
        return;
    }

    for (ix = 0; ix < n->consequences->sz; ix++) {
        J = (atms_justification)n->consequences->arr[ix];
        propagate(tms, J, n, L);

        trie_remove_not_subsumed_trie(L, n->label);
        if (trie_is_empty(L)) {
            break;
        }
    }
}
예제 #3
0
void
prim_divide(PRIM_PROTOTYPE)
{
	CHECKOP(2);
	oper1 = POP();
	oper2 = POP();
	if (!arith_type(oper2, oper1))
		abort_interp("Invalid argument type.");
	if ((oper1->type == PROG_FLOAT) || (oper2->type == PROG_FLOAT)) {
		if ((oper1->type == PROG_INTEGER && !oper1->data.number) ||
			(oper1->type == PROG_FLOAT && fabs(oper1->data.fnumber) < DBL_EPSILON)) {
			/* FIXME: This should be NaN.  */
			fresult = INF;
			fr->error.error_flags.div_zero = 1;
		} else {
			tf1 = (oper2->type == PROG_FLOAT) ? oper2->data.fnumber : oper2->data.number;
			tf2 = (oper1->type == PROG_FLOAT) ? oper1->data.fnumber : oper1->data.number;
			if (!nogood(tf1) && !nogood(tf2)) {
				fresult = tf1 / tf2;
			} else {
				fresult = 0.0;
				fr->error.error_flags.f_bounds = 1;
			}
		}
	} else {
		if (oper1->data.number) {
			result = oper2->data.number / oper1->data.number;
		} else {
			result = 0;
			fr->error.error_flags.div_zero = 1;
		}
	}
	tmp = (oper2->type == PROG_FLOAT || oper1->type == PROG_FLOAT) ? PROG_FLOAT : oper2->type;
	CLEAR(oper1);
	CLEAR(oper2);
	if (tmp == PROG_FLOAT)
		push(arg, top, tmp, MIPSCAST & fresult);
	else
		push(arg, top, tmp, MIPSCAST & result);
}
예제 #4
0
int main(void)
{
    printf("hello from %s().\n", __func__);
    hello_foo();
    hello_bar();
    nogood();
    /////////////////////////
    int crc = 0;
    const char* buf = "voice from hell....";
    crc = crc32((unsigned char *)buf, strlen(buf));
    printf("crc: 0x%x\n", crc);
    dump(buf, strlen(buf));
    return 0;
}