Dev checkpoint

db4
Phil Dawes 2009-08-17 21:37:05 +01:00
parent 10901e7c37
commit 8426e2f877
2 changed files with 37 additions and 11 deletions

40
vm/bignum.cpp Normal file → Executable file
View File

@ -61,8 +61,7 @@ namespace factor
/* Exports */ /* Exports */
int int factorvm::bignum_equal_p(bignum * x, bignum * y)
bignum_equal_p(bignum * x, bignum * y)
{ {
return return
((BIGNUM_ZERO_P (x)) ((BIGNUM_ZERO_P (x))
@ -74,8 +73,12 @@ bignum_equal_p(bignum * x, bignum * y)
&& (bignum_equal_p_unsigned (x, y)))); && (bignum_equal_p_unsigned (x, y))));
} }
enum bignum_comparison int bignum_equal_p(bignum * x, bignum * y)
bignum_compare(bignum * x, bignum * y) {
return vm->bignum_equal_p(x,y);
}
enum bignum_comparison factorvm::bignum_compare(bignum * x, bignum * y)
{ {
return return
((BIGNUM_ZERO_P (x)) ((BIGNUM_ZERO_P (x))
@ -97,9 +100,13 @@ bignum_compare(bignum * x, bignum * y)
: (bignum_compare_unsigned (x, y)))); : (bignum_compare_unsigned (x, y))));
} }
enum bignum_comparison bignum_compare(bignum * x, bignum * y)
{
return vm->bignum_compare(x,y);
}
/* allocates memory */ /* allocates memory */
bignum * bignum *factorvm::bignum_add(bignum * x, bignum * y)
bignum_add(bignum * x, bignum * y)
{ {
return return
((BIGNUM_ZERO_P (x)) ((BIGNUM_ZERO_P (x))
@ -115,9 +122,13 @@ bignum_add(bignum * x, bignum * y)
: (bignum_add_unsigned (x, y, 0))))); : (bignum_add_unsigned (x, y, 0)))));
} }
bignum *bignum_add(bignum * x, bignum * y)
{
return vm->bignum_add(x,y);
}
/* allocates memory */ /* allocates memory */
bignum * bignum *factorvm::bignum_subtract(bignum * x, bignum * y)
bignum_subtract(bignum * x, bignum * y)
{ {
return return
((BIGNUM_ZERO_P (x)) ((BIGNUM_ZERO_P (x))
@ -135,9 +146,13 @@ bignum_subtract(bignum * x, bignum * y)
: (bignum_subtract_unsigned (x, y)))))); : (bignum_subtract_unsigned (x, y))))));
} }
bignum *bignum_subtract(bignum * x, bignum * y)
{
return vm->bignum_subtract(x,y);
}
/* allocates memory */ /* allocates memory */
bignum * bignum *factorvm::bignum_multiply(bignum * x, bignum * y)
bignum_multiply(bignum * x, bignum * y)
{ {
bignum_length_type x_length = (BIGNUM_LENGTH (x)); bignum_length_type x_length = (BIGNUM_LENGTH (x));
bignum_length_type y_length = (BIGNUM_LENGTH (y)); bignum_length_type y_length = (BIGNUM_LENGTH (y));
@ -168,6 +183,11 @@ bignum_multiply(bignum * x, bignum * y)
return (bignum_multiply_unsigned (x, y, negative_p)); return (bignum_multiply_unsigned (x, y, negative_p));
} }
bignum *bignum_multiply(bignum * x, bignum * y)
{
return vm->bignum_multiply(x,y);
}
/* allocates memory */ /* allocates memory */
void void
bignum_divide(bignum * numerator, bignum * denominator, bignum_divide(bignum * numerator, bignum * denominator,

View File

@ -43,7 +43,6 @@ struct factorvm {
void fatal_error(const char* msg, cell tagged); void fatal_error(const char* msg, cell tagged);
void critical_error(const char* msg, cell tagged); void critical_error(const char* msg, cell tagged);
void throw_error(cell error, stack_frame *callstack_top); void throw_error(cell error, stack_frame *callstack_top);
void not_implemented_error(); void not_implemented_error();
bool in_page(cell fault, cell area, cell area_size, int offset); bool in_page(cell fault, cell area, cell area_size, int offset);
void memory_protection_error(cell addr, stack_frame *native_stack); void memory_protection_error(cell addr, stack_frame *native_stack);
@ -57,6 +56,13 @@ struct factorvm {
void fp_signal_handler_impl(); void fp_signal_handler_impl();
void type_error(cell type, cell tagged); void type_error(cell type, cell tagged);
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top); void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top);
// bignum
int bignum_equal_p(bignum * x, bignum * y);
enum bignum_comparison bignum_compare(bignum * x, bignum * y);
bignum *bignum_add(bignum * x, bignum * y);
bignum *bignum_subtract(bignum * x, bignum * y);
bignum *bignum_multiply(bignum * x, bignum * y);
// next method here: // next method here:
}; };