Example #1
0
    def new_double(self, value):
        # Allocate a new integer and set its class to be the double class
        result = Double(self._nilObject, value)
        result.set_class(self._doubleClass)
 
        # Return the freshly allocated double
        return result
Example #2
0
    def new_double(self, value):
        # Allocate a new integer and set its class to be the double class
        result = Double(self._nilObject, value)
        result.set_class(self._doubleClass)

        # Return the freshly allocated double
        return result
Example #3
0
class DoubleTestCase(unittest.TestCase):

    def setUp(self):
        self.double = Double(Object(None), 5.5)

    def test_get_embedded_double(self):
        self.assertEqual(5.5, self.double.get_embedded_double())
 def read_location(self, obj):
     # assert isinstance(obj, Object)
     if self.is_set(obj):
         double_val = longlong2float(
             getattr(obj, "_primField" + str(field_idx)))
         return Double(double_val)
     else:
         return nilObject
Example #5
0
 def _set_remaining_with_block_as_bool(array, block, size, next_i, storage):
     block_method = block.get_method()
     while next_i < size:
         put_all_bool_driver.jit_merge_point(block_method = block_method)
         result = block_method.invoke(block, [])
         if result is trueObject or result is falseObject:
             storage[next_i] = result is trueObject
         else:
             # something else, so, let's go to the object strategy
             new_storage = [None] * size
             for i in range(0, next_i + 1):
                 new_storage[i] = Double(storage[i])
             _ArrayStrategy._set_remaining_with_block_as_obj(array, block,
                                                             size,
                                                             next_i + 1,
                                                             new_storage)
             return
         next_i += 1
     array._strategy = _bool_strategy
     array._storage  = _bool_strategy._erase(storage)
Example #6
0
 def _set_remaining_with_block_as_double(array, block, size, next_i, storage):
     block_method = block.get_method()
     while next_i < size:
         put_all_double_driver.jit_merge_point(block_method = block_method)
         result = block_method.invoke(block, [])
         if isinstance(result, Double):
             storage[next_i] = result.get_embedded_double()
         else:
             # something else, so, let's go to the object strategy
             new_storage = [None] * size
             for i in range(0, next_i + 1):
                 new_storage[i] = Double(storage[i])
             _ArrayStrategy._set_remaining_with_block_as_obj(array, block,
                                                             size,
                                                             next_i + 1,
                                                             new_storage)
             return
         next_i += 1
     array._strategy = _double_strategy
     array._storage  = _double_strategy._erase(storage)
Example #7
0
 def new_double(value):
     return Double(value)
Example #8
0
 def as_arguments_array(self, storage):
     store = self._unerase(storage)
     return [Double(v) for v in store]
Example #9
0
 def get_idx(self, storage, idx):
     store = self._unerase(storage)
     assert isinstance(store, list)
     assert isinstance(store[idx], float)
     return Double(store[idx])
Example #10
0
 def read_location(self, obj):
     if self.is_set(obj):
         val = longlong2float(obj._primFields[self._ext_idx])
         return Double(val)
     else:
         return nilObject
Example #11
0
 def setUp(self):
     self.double = Double(Object(None), 5.5)