WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit adb9a138 authored by Stefan Marr's avatar Stefan Marr
Browse files

With Python, the whole Integer vs. BigInteger is slightly useless

- for the moment lets use sys.maxint as a limit, will see whether we need to use the more traditional 31-bit boundaries for compatibility
Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 40003443
......@@ -3,6 +3,8 @@ from som.compiler.lexer import Lexer
from som.compiler.bytecode_generator import BytecodeGenerator
from som.compiler.method_generation_context import MethodGenerationContext
from som.vmobjects.integer import Integer
class Parser(object):
_single_op_syms = (Symbol.Not, Symbol.And, Symbol.Or, Symbol.Star,
......@@ -457,10 +459,11 @@ class Parser(object):
val = self._literal_decimal()
if isinstance(val, long):
lit = self._universe.new_biginteger(val)
if Integer.value_fits(val):
lit = self._universe.new_integer(val)
lit = self._universe.new_biginteger(val)
self._bc_gen.emitPUSHCONSTANT(mgenc, lit)
......@@ -12,10 +12,10 @@ class IntegerPrimitives(Primitives):
def _push_long_result(self, frame, result):
# Check with integer bounds and push:
if isinstance(result, long):
if Integer.value_fits(result):
def _resend_as_biginteger(self, operator, left, right):
left_biginteger = self._universe.new_biginteger(left.get_embedded_integer())
from som.vmobjects.object import Object
import sys
class Integer(Object):
def __init__(self, nilObject):
......@@ -13,4 +15,8 @@ class Integer(Object):
self._embedded_integer = value
def __str__(self):
return str(self._embedded_integer)
\ No newline at end of file
return str(self._embedded_integer)
def value_fits(cls, value):
return value < sys.maxint and value > (-sys.maxint - 1)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment