예제 #1
0
파일: universe.py 프로젝트: QDucasse/PySOM
    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
예제 #2
0
 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
예제 #3
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)
예제 #4
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)
예제 #5
0
 def new_double(value):
     return Double(value)
예제 #6
0
 def as_arguments_array(self, storage):
     store = self._unerase(storage)
     return [Double(v) for v in store]
예제 #7
0
 def get_idx(self, storage, idx):
     store = self._unerase(storage)
     assert isinstance(store, list)
     assert isinstance(store[idx], float)
     return Double(store[idx])
예제 #8
0
 def read_location(self, obj):
     if self.is_set(obj):
         val = longlong2float(obj._primFields[self._ext_idx])
         return Double(val)
     else:
         return nilObject
예제 #9
0
 def setUp(self):
     self.double = Double(Object(None), 5.5)