Commit 8e079882 authored by Stefan Marr's avatar Stefan Marr

Remove BigInteger from SOM

It is implemented like in RTruffleSOM, BigInteger remains on the VM level to hold rbigint instances.
This also properly parses rbigint.
Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent e0d567af
Subproject commit ab97d9c0aad8042e4fffa5e0161a62cd6ca86eae Subproject commit d47d0965cae605c07ffe10321203e3154dd6e301
from rpython.rlib.rarithmetic import string_to_int
from rpython.rlib.rbigint import rbigint
from .lexer import Lexer from .lexer import Lexer
from .bytecode_generator import BytecodeGenerator from .bytecode_generator import BytecodeGenerator
from .method_generation_context import MethodGenerationContext from .method_generation_context import MethodGenerationContext
from .symbol import Symbol, symbol_as_str from .symbol import Symbol, symbol_as_str
from ..vmobjects.integer import integer_value_fits
class ParseError(BaseException): class ParseError(BaseException):
def __init__(self, message, expected_sym, parser): def __init__(self, message, expected_sym, parser):
...@@ -532,20 +532,21 @@ class Parser(object): ...@@ -532,20 +532,21 @@ class Parser(object):
def _literal_integer(self, negate_value): def _literal_integer(self, negate_value):
try: try:
i = int(self._text) i = string_to_int(self._text)
if negate_value: if negate_value:
i = 0 - i i = 0 - i
result = self._universe.new_integer(i)
except OverflowError:
bigint = rbigint.fromstr(self._text)
if negate_value:
bigint.sign = -1
result = self._universe.new_biginteger(bigint)
except ValueError: except ValueError:
raise ParseError("Could not parse integer. " raise ParseError("Could not parse integer. "
"Expected a number but got '%s'" % self._text, "Expected a number but got '%s'" % self._text,
Symbol.NONE, self) Symbol.NONE, self)
self._expect(Symbol.Integer) self._expect(Symbol.Integer)
return result
if integer_value_fits(i):
return self._universe.new_integer(i)
else:
return self._universe.new_biginteger(i)
def _literal_double(self, negate_value): def _literal_double(self, negate_value):
try: try:
......
...@@ -2,7 +2,9 @@ from som.interpreter.bytecodes import bytecode_length, Bytecodes ...@@ -2,7 +2,9 @@ from som.interpreter.bytecodes import bytecode_length, Bytecodes
from som.interpreter.control_flow import ReturnException from som.interpreter.control_flow import ReturnException
from rpython.rlib import jit from rpython.rlib import jit
from som.vmobjects.integer import Integer, integer_value_fits from som.vmobjects.biginteger import BigInteger
from som.vmobjects.double import Double
from som.vmobjects.integer import Integer
class Interpreter(object): class Interpreter(object):
...@@ -137,23 +139,16 @@ class Interpreter(object): ...@@ -137,23 +139,16 @@ class Interpreter(object):
raise ReturnException(result, context) raise ReturnException(result, context)
# TODO: this should be done like in the RTruffleSOM variant
def _push_long_result(self, frame, result):
# Check with integer bounds and push:
if integer_value_fits(result):
frame.push(self._universe.new_integer(int(result)))
else:
frame.push(self._universe.new_biginteger(result))
def _do_add(self, bytecode_index, frame, method): def _do_add(self, bytecode_index, frame, method):
rcvr = frame.get_stack_element(1) rcvr = frame.get_stack_element(1)
right = frame.get_stack_element(0) right = frame.get_stack_element(0)
if isinstance(rcvr, Integer) and isinstance(right, Integer): if (isinstance(rcvr, Integer) or
isinstance(rcvr, BigInteger) or
isinstance(rcvr, Double)):
frame.pop() frame.pop()
frame.pop() frame.pop()
result = rcvr.get_embedded_integer() + right.get_embedded_integer() frame.push(rcvr.prim_add(right, self._universe))
self._push_long_result(frame, result)
else: else:
self._send(method, frame, self._add_symbol, self._send(method, frame, self._add_symbol,
rcvr.get_class(self._universe), bytecode_index) rcvr.get_class(self._universe), bytecode_index)
......
from rpython.rlib.rfloat import (formatd, DTSF_ADD_DOT_0, DTSF_STR_PRECISION, from rpython.rlib.rfloat import round_double
NAN, INFINITY, isfinite, round_double)
from som.primitives.primitives import Primitives from som.primitives.primitives import Primitives
from som.vmobjects.primitive import Primitive from som.vmobjects.primitive import Primitive
...@@ -19,90 +18,67 @@ def _coerce_to_double(obj, universe): ...@@ -19,90 +18,67 @@ def _coerce_to_double(obj, universe):
def _asString(ivkbl, frame, interpreter): def _asString(ivkbl, frame, interpreter):
rcvr = frame.pop() rcvr = frame.pop()
d = rcvr.get_embedded_double() frame.push(rcvr.prim_as_string(interpreter.get_universe()))
s = formatd(d, "g", DTSF_STR_PRECISION, DTSF_ADD_DOT_0)
frame.push(interpreter.get_universe().new_string(s))
def _sqrt(ivkbl, frame, interpreter): def _sqrt(ivkbl, frame, interpreter):
rcvr = frame.pop() rcvr = frame.pop()
frame.push(interpreter.get_universe().new_double(math.sqrt(rcvr.get_embedded_double()))) frame.push(interpreter.get_universe().new_double(math.sqrt(
rcvr.get_embedded_double())))
def _plus(ivkbl, frame, interpreter): def _plus(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
frame.push(interpreter.get_universe().new_double(op1.get_embedded_double() frame.push(rcvr.prim_add(right, interpreter.get_universe()))
+ op2.get_embedded_double()))
def _minus(ivkbl, frame, interpreter): def _minus(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
frame.push(interpreter.get_universe().new_double(op2.get_embedded_double() frame.push(rcvr.prim_subtract(right, interpreter.get_universe()))
- op1.get_embedded_double()))
def _mult(ivkbl, frame, interpreter): def _mult(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
frame.push(interpreter.get_universe().new_double(op2.get_embedded_double() frame.push(rcvr.prim_multiply(right, interpreter.get_universe()))
* op1.get_embedded_double()))
def _doubleDiv(ivkbl, frame, interpreter): def _doubleDiv(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
frame.push(interpreter.get_universe().new_double(op2.get_embedded_double() frame.push(rcvr.prim_double_div(right, interpreter.get_universe()))
/ op1.get_embedded_double()))
def _mod(ivkbl, frame, interpreter): def _mod(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
frame.push(rcvr.prim_modulo(right, interpreter.get_universe()))
o1 = op1.get_embedded_double()
o2 = op2.get_embedded_double()
r = math.fmod(o1, o2)
frame.push(interpreter.get_universe().new_double(r))
def _equals(ivkbl, frame, interpreter): def _equals(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
if op1.get_embedded_double() == op2.get_embedded_double(): frame.push(rcvr.prim_equals(right, interpreter.get_universe()))
frame.push(interpreter.get_universe().trueObject)
else:
frame.push(interpreter.get_universe().falseObject)
def _lessThan(ivkbl, frame, interpreter): def _lessThan(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
if op2.get_embedded_double() < op1.get_embedded_double(): frame.push(rcvr.prim_less_than(right, interpreter.get_universe()))
frame.push(interpreter.get_universe().trueObject)
else:
frame.push(interpreter.get_universe().falseObject)
def _and(ivkbl, frame, interpreter): def _and(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
frame.push(rcvr.prim_and(right, interpreter.get_universe()))
left = int(op2.get_embedded_double())
right = int(op1.get_embedded_double())
result = float(left & right)
frame.push(interpreter.get_universe().new_double(result))
def _bitXor(ivkbl, frame, interpreter): def _bitXor(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe()) right = frame.pop()
op2 = frame.pop() rcvr = frame.pop()
frame.push(rcvr.prim_bit_xor(right, interpreter.get_universe()))
left = int(op2.get_embedded_double())
right = int(op1.get_embedded_double())
result = float(left ^ right)
frame.push(interpreter.get_universe().new_double(result))
def _round(ivkbl, frame, interpreter): def _round(ivkbl, frame, interpreter):
......
from rpython.rlib.rarithmetic import ovfcheck
from rpython.rlib.rbigint import rbigint
from som.primitives.primitives import Primitives from som.primitives.primitives import Primitives
from som.vmobjects.integer import Integer
from som.vmobjects.primitive import Primitive from som.vmobjects.primitive import Primitive
from som.vmobjects.biginteger import BigInteger
from som.vmobjects.integer import integer_value_fits, Integer
from som.vmobjects.double import Double from som.vmobjects.double import Double
from som.vmobjects.string import String from som.vmobjects.string import String
from som.vmobjects.block import block_evaluate from som.vmobjects.block import block_evaluate
...@@ -9,29 +10,9 @@ from som.vmobjects.block import block_evaluate ...@@ -9,29 +10,9 @@ from som.vmobjects.block import block_evaluate
import math import math
def _push_long_result(frame, result, universe):
# Check with integer bounds and push:
if integer_value_fits(result):
frame.push(universe.new_integer(int(result)))
else:
frame.push(universe.new_biginteger(result))
def _resend_as_biginteger(frame, operator, left, right, universe):
left_biginteger = universe.new_biginteger(left.get_embedded_integer())
operands = [right]
left_biginteger.send(frame, operator, operands, universe, universe.get_interpreter())
def _resend_as_double(frame, operator, left, right, universe):
left_double = universe.new_double(float(left.get_embedded_integer()))
operands = [right]
left_double.send(frame, operator, operands, universe, universe.get_interpreter())
def _asString(ivkbl, frame, interpreter): def _asString(ivkbl, frame, interpreter):
rcvr = frame.pop() rcvr = frame.pop()
frame.push(interpreter.get_universe().new_string(str(rcvr.get_embedded_integer()))) frame.push(rcvr.prim_as_string(interpreter.get_universe()))
def _sqrt(ivkbl, frame, interpreter): def _sqrt(ivkbl, frame, interpreter):
...@@ -52,157 +33,55 @@ def _atRandom(ivkbl, frame, interpreter): ...@@ -52,157 +33,55 @@ def _atRandom(ivkbl, frame, interpreter):
def _plus(ivkbl, frame, interpreter): def _plus(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_add(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "+", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "+", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
result = left.get_embedded_integer() + right.get_embedded_integer()
_push_long_result(frame, result, interpreter.get_universe())
def _minus(ivkbl, frame, interpreter): def _minus(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_subtract(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "-", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "-", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
result = left.get_embedded_integer() - right.get_embedded_integer()
_push_long_result(frame, result, interpreter.get_universe())
def _mult(ivkbl, frame, interpreter): def _mult(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_multiply(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "*", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "*", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
result = left.get_embedded_integer() * right.get_embedded_integer()
_push_long_result(frame, result, interpreter.get_universe())
def _doubleDiv(ivkbl, frame, interpreter): def _doubleDiv(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_double_div(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "/", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "/", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
result = float(left.get_embedded_integer()) / float(right.get_embedded_integer())
frame.push(interpreter.get_universe().new_double(result))
def _intDiv(ivkbl, frame, interpreter): def _intDiv(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_int_div(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "/", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "/", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
result = left.get_embedded_integer() / right.get_embedded_integer()
_push_long_result(frame, result, interpreter.get_universe())
def _mod(ivkbl, frame, interpreter): def _mod(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_modulo(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "%", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "%", left, right_obj, interpreter.get_universe())
else:
# Do operation:
_push_long_result(frame, left.get_embedded_integer() % right_obj.get_embedded_integer(), interpreter.get_universe())
def _and(ivkbl, frame, interpreter): def _and(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_and(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "&", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "&", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
result = left.get_embedded_integer() & right.get_embedded_integer()
_push_long_result(frame, result, interpreter.get_universe())
def _equals(ivkbl, frame, interpreter): def _equals(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_equals(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "=", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Integer):
if left.get_embedded_integer() == right_obj.get_embedded_integer():
frame.push(interpreter.get_universe().trueObject)
else:
frame.push(interpreter.get_universe().falseObject)
elif isinstance(right_obj, Double):
if left.get_embedded_integer() == right_obj.get_embedded_double():
frame.push(interpreter.get_universe().trueObject)
else:
frame.push(interpreter.get_universe().falseObject)
else:
frame.push(interpreter.get_universe().falseObject)
def _lessThan(ivkbl, frame, interpreter): def _lessThan(ivkbl, frame, interpreter):
right_obj = frame.pop() right_obj = frame.pop()
left = frame.pop() left = frame.pop()
frame.push(left.prim_less_than(right_obj, interpreter.get_universe()))
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger(frame, "<", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double(frame, "<", left, right_obj, interpreter.get_universe())
else:
if left.get_embedded_integer() < right_obj.get_embedded_integer():
frame.push(interpreter.get_universe().trueObject)
else:
frame.push(interpreter.get_universe().falseObject)
def _fromString(ivkbl, frame, interpreter): def _fromString(ivkbl, frame, interpreter):
...@@ -220,10 +99,17 @@ def _fromString(ivkbl, frame, interpreter): ...@@ -220,10 +99,17 @@ def _fromString(ivkbl, frame, interpreter):
def _leftShift(ivkbl, frame, interpreter): def _leftShift(ivkbl, frame, interpreter):
right = frame.pop() right = frame.pop()
left = frame.pop() left = frame.pop()
universe = interpreter.get_universe()
assert isinstance(right, Integer)
result = left.get_embedded_integer() << right.get_embedded_integer() l = left.get_embedded_integer()
r = right.get_embedded_integer()
_push_long_result(frame, result, interpreter.get_universe()) try:
result = ovfcheck(l << r)
frame.push(universe.new_integer(result))
except OverflowError:
frame.push(universe.new_biginteger(
rbigint.fromint(l).lshift(r)))
def _bitXor(ivkbl, frame, interpreter): def _bitXor(ivkbl, frame, interpreter):
...@@ -258,7 +144,6 @@ jitdriver_double = jit.JitDriver( ...@@ -258,7 +144,6 @@ jitdriver_double = jit.JitDriver(
get_printable_location=get_printable_location) get_printable_location=get_printable_location)
def _toDoInt(i, top, frame, context, interpreter, block_method, universe): def _toDoInt(i, top, frame, context, interpreter, block_method, universe):
assert isinstance(i, int) assert isinstance(i, int)
assert isinstance(top, int) assert isinstance(top, int)
...@@ -293,7 +178,7 @@ def _toDo(ivkbl, frame, interpreter): ...@@ -293,7 +178,7 @@ def _toDo(ivkbl, frame, interpreter):
universe = interpreter.get_universe() universe = interpreter.get_universe()
block = frame.pop() block = frame.pop()
limit = frame.pop() limit = frame.pop()
self = frame.pop() # we do leave it on there self = frame.pop() # we do leave it on there
block_method = block.get_method() block_method = block.get_method()
context = block.get_context() context = block.get_context()
...@@ -303,7 +188,7 @@ def _toDo(ivkbl, frame, interpreter): ...@@ -303,7 +188,7 @@ def _toDo(ivkbl, frame, interpreter):
_toDoDouble(i, limit.get_embedded_double(), frame, context, interpreter, _toDoDouble(i, limit.get_embedded_double(), frame, context, interpreter,
block_method, universe) block_method, universe)
else: else:
_toDoInt(i, limit.get_embedded_value(), frame, context, interpreter, _toDoInt(i, limit.get_embedded_integer(), frame, context, interpreter,
block_method, universe) block_method, universe)
frame.push(self) frame.push(self)
......
from rpython.rlib.debug import make_sure_not_resized from rpython.rlib.debug import make_sure_not_resized
from rpython.rlib.rbigint import rbigint
from rpython.rlib.rrandom import Random from rpython.rlib.rrandom import Random
from rpython.rlib import jit from rpython.rlib import jit
...@@ -60,7 +61,6 @@ class Universe(object): ...@@ -60,7 +61,6 @@ class Universe(object):
"metaclassClass", "metaclassClass",
"nilClass", "nilClass",
"integerClass", "integerClass",
"bigintegerClass",
"arrayClass", "arrayClass",
"methodClass", "methodClass",
"symbolClass", "symbolClass",
...@@ -87,7 +87,6 @@ class Universe(object): ...@@ -87,7 +87,6 @@ class Universe(object):
self.nilClass = None self.nilClass = None
self.integerClass = None self.integerClass = None
self.bigintegerClass= None
self.arrayClass = None self.arrayClass = None
self.methodClass = None self.methodClass = None
self.symbolClass = None self.symbolClass = None
...@@ -252,7 +251,6 @@ class Universe(object): ...@@ -252,7 +251,6 @@ class Universe(object):
self.symbolClass = self.new_system_class() self.symbolClass = self.new_system_class()
self.methodClass = self.new_system_class() self.methodClass = self.new_system_class()
self.integerClass = self.new_system_class() self.integerClass = self.new_system_class()
self.bigintegerClass = self.new_system_class()
self.primitiveClass = self.new_system_class() self.primitiveClass = self.new_system_class()
self.stringClass = self.new_system_class() self.stringClass = self.new_system_class()
self.doubleClass = self.new_system_class() self.doubleClass = self.new_system_class()
...@@ -269,7 +267,6 @@ class Universe(object): ...@@ -269,7 +267,6 @@ class Universe(object):
self._initialize_system_class(self.methodClass, self.arrayClass, "Method") self._initialize_system_class(self.methodClass, self.arrayClass, "Method")
self._initialize_system_class(self.symbolClass, self.objectClass, "Symbol") self._initialize_system_class(self.symbolClass, self.objectClass, "Symbol")
self._initialize_system_class(self.integerClass, self.objectClass, "Integer") self._initialize_system_class(self.integerClass, self.objectClass, "Integer")
self._initialize_system_class(self.bigintegerClass, self.objectClass, "BigInteger")
self._initialize_system_class(self.primitiveClass, self.objectClass, "Primitive") self._initialize_system_class(self.primitiveClass, self.objectClass, "Primitive")
self._initialize_system_class(self.stringClass, self.objectClass, "String") self._initialize_system_class(self.stringClass, self.objectClass, "String")
self._initialize_system_class(self.doubleClass, self.objectClass, "Double") self._initialize_system_class(self.doubleClass, self.objectClass, "Double")
...@@ -283,7 +280,6 @@ class Universe(object): ...@@ -283,7 +280,6 @@ class Universe(object):
self._load_system_class(self.methodClass) self._load_system_class(self.methodClass)
self._load_system_class(self.symbolClass) self._load_system_class(self.symbolClass)
self._load_system_class(self.integerClass) self._load_system_class(self.integerClass)
self._load_system_class(self.bigintegerClass)
self._load_system_class(self.primitiveClass) self._load_system_class(self.primitiveClass)
self._load_system_class(self.stringClass) self._load_system_class(self.stringClass)
self._load_system_class(self.doubleClass) self._load_system_class(self.doubleClass)
...@@ -389,6 +385,7 @@ class Universe(object): ...@@ -389,6 +385,7 @@ class Universe(object):
@staticmethod @staticmethod
def new_biginteger(value): def new_biginteger(value):
assert isinstance(value, rbigint)
return BigInteger(value) return BigInteger(value)
@staticmethod @staticmethod
......
from som.vmobjects.abstract_object import AbstractObject from rpython.rlib.rbigint import rbigint
from .abstract_object import AbstractObject
from .double import Double
class BigInteger(AbstractObject): class BigInteger(AbstractObject):
...@@ -7,15 +9,127 @@ class BigInteger(AbstractObject): ...@@ -7,15 +9,127 @@ class BigInteger(AbstractObject):
def __init__(self, value): def __init__(self, value):
AbstractObject.__init__(self) AbstractObject.__init__(self)
assert isinstance(value, int) assert isinstance(value, rbigint)
self._embedded_biginteger = value self._embedded_biginteger = value
def get_embedded_biginteger(self): def get_embedded_biginteger(self):
return self._embedded_biginteger return self._embedded_biginteger