Commit d8b5529c authored by Tobias Pape's avatar Tobias Pape Committed by Stefan Marr

fix some primitives

Signed-off-by: 's avatarStefan Marr <git@stefan-marr.de>
parent c58e578c
......@@ -9,7 +9,7 @@ def _coerce_to_double(obj, universe):
if isinstance(obj, Double):
return obj
if isinstance(obj, Integer):
return universe.new_double(obj.get_embedded_integer())
return universe.new_double(float(obj.get_embedded_integer()))
raise ValueError("Cannot coerce %s to Double!" % obj)
def _asString(ivkbl, frame, interpreter):
......@@ -46,8 +46,11 @@ def _doubleDiv(ivkbl, frame, interpreter):
def _mod(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe())
op2 = frame.pop()
frame.push(interpreter.get_universe().new_double(op2.get_embedded_double()
% op1.get_embedded_double()))
o1 = float(op1.get_embedded_double())
o2 = float(op2.get_embedded_double())
r = math.fmod(o1, o2)
frame.push(interpreter.get_universe().new_double(r))
def _equals(ivkbl, frame, interpreter):
op1 = _coerce_to_double(frame.pop(), interpreter.get_universe())
......
......@@ -33,8 +33,8 @@ def _sqrt(ivkbl, frame, interpreter):
def _atRandom(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(interpreter.universe().new_integer(int(
rcvr.get_embedded_integer() * interpreter.universe().random.random())))
frame.push(interpreter.get_universe().new_integer(int(
rcvr.get_embedded_integer() * interpreter.get_universe().random.random())))
def _plus(ivkbl, frame, interpreter):
right_obj = frame.pop()
......
......@@ -42,7 +42,7 @@ def _substring(ivkbl, frame, interpreter):
def _hashcode(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(interpreter.universe().new_integer(
frame.push(interpreter.get_universe().new_integer(
compute_identity_hash(rcvr.get_embedded_string())))
class StringPrimitives(Primitives):
......
......@@ -35,13 +35,13 @@ def _print_newline(ivkbl, frame, interpreter):
def _time(ivkbl, frame, interpreter):
frame.pop() # ignore
_time = time.time() - interpreter.universe().start_time
frame.push(interpreter.universe().new_integer(int(_time * 1000)))
since_start = time.time() - interpreter.get_universe().start_time
frame.push(interpreter.get_universe().new_integer(int(since_start * 1000)))
def _ticks(ivkbl, frame, interpreter):
frame.pop() # ignore
_time = time.time() - interpreter.universe().start_time
frame.push(interpreter.universe().new_integer(int(_time * 1000000)))
since_start = time.time() - interpreter.get_universe().start_time
frame.push(interpreter.get_universe().new_integer(int(since_start * 1000000)))
def _fullGC(ivkbl, frame, interpreter):
# naught - GC is entirely left to Python
......
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