]> gitweb.factorcode.org Git - factor.git/commitdiff
moved math.hpp functions to vm
authorPhil Dawes <phil@phildawes.net>
Mon, 17 Aug 2009 20:37:11 +0000 (21:37 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:16:22 +0000 (08:16 +0100)
vm/math.hpp
vm/vm.hpp

index 7828aa3e6c8905c5b47a8d8a1c7293ca60345442..cb4f1b1101a63d777d7a4fdbf75b5ffcca1c4830 100644 (file)
@@ -42,7 +42,7 @@ PRIMITIVE(bignum_bitp);
 PRIMITIVE(bignum_log2);
 PRIMITIVE(byte_array_to_bignum);
 
-inline static cell allot_integer(fixnum x)
+inline cell factorvm::allot_integer(fixnum x)
 {
        if(x < fixnum_min || x > fixnum_max)
                return tag<bignum>(fixnum_to_bignum(x));
@@ -50,7 +50,12 @@ inline static cell allot_integer(fixnum x)
                return tag_fixnum(x);
 }
 
-inline static cell allot_cell(cell x)
+inline cell allot_integer(fixnum x)
+{
+       return vm->allot_integer(x);
+}
+
+inline cell factorvm::allot_cell(cell x)
 {
        if(x > (cell)fixnum_max)
                return tag<bignum>(cell_to_bignum(x));
@@ -58,6 +63,11 @@ inline static cell allot_cell(cell x)
                return tag_fixnum(x);
 }
 
+inline cell allot_cell(cell x)
+{
+       return vm->allot_cell(x);
+}
+
 cell unbox_array_size();
 
 inline static double untag_float(cell tagged)
@@ -70,33 +80,48 @@ inline static double untag_float_check(cell tagged)
        return untag_check<boxed_float>(tagged)->n;
 }
 
-inline static cell allot_float(double n)
+inline cell factorvm::allot_float(double n)
 {
        boxed_float *flo = allot<boxed_float>(sizeof(boxed_float));
        flo->n = n;
        return tag(flo);
 }
 
+inline cell allot_float(double n)
+{
+       return vm->allot_float(n);
+}
+
 inline static fixnum float_to_fixnum(cell tagged)
 {
        return (fixnum)untag_float(tagged);
 }
 
-inline static bignum *float_to_bignum(cell tagged)
+inline bignum *factorvm::float_to_bignum(cell tagged)
 {
        return double_to_bignum(untag_float(tagged));
 }
 
-inline static double fixnum_to_float(cell tagged)
+inline bignum *float_to_bignum(cell tagged)
+{
+       return vm->float_to_bignum(tagged);
+}
+
+inline double fixnum_to_float(cell tagged)
 {
        return (double)untag_fixnum(tagged);
 }
 
-inline static double bignum_to_float(cell tagged)
+inline double factorvm::bignum_to_float(cell tagged)
 {
        return bignum_to_double(untag<bignum>(tagged));
 }
 
+inline double bignum_to_float(cell tagged)
+{
+       return vm->bignum_to_float(tagged);
+}
+
 PRIMITIVE(fixnum_to_float);
 PRIMITIVE(bignum_to_float);
 PRIMITIVE(str_to_float);
index 0389817bb9f85dd310b3d29f5937c4fd4b7b3776..5db239626df55c6bd72bbc8f78dff5195c22b60b 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -246,7 +246,6 @@ struct factorvm {
        cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
        inline void vmprim_resize_array();
        inline void set_array_nth(array *array, cell slot, cell value);
-       // next method here:
 
        //strings
        cell string_nth(string* str, cell index);
@@ -358,6 +357,12 @@ struct factorvm {
        void overflow_fixnum_add(fixnum x, fixnum y);
        void overflow_fixnum_subtract(fixnum x, fixnum y);
        void overflow_fixnum_multiply(fixnum x, fixnum y);
+       inline cell allot_integer(fixnum x);
+       inline cell allot_cell(cell x);
+       inline cell allot_float(double n);
+       inline bignum *float_to_bignum(cell tagged);
+       inline double bignum_to_float(cell tagged);
+       // next method here:
        
        //io
        void init_c_io();