GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit 25ed7d6d authored by Stefan Marr's avatar Stefan Marr

Need to pass on frame explicitly in send operations

Signed-off-by: 's avatarStefan Marr <git@stefan-marr.de>
parent 3b3b3d70
......@@ -14,15 +14,15 @@ def _push_long_result(frame, result, universe):
else:
frame.push(universe.new_biginteger(result))
def _resend_as_biginteger(operator, left, right, universe):
def _resend_as_biginteger(frame, operator, left, right, universe):
left_biginteger = universe.new_biginteger(left.get_embedded_integer())
operands = [right]
left_biginteger.send(operator, operands, universe, universe.get_interpreter())
left_biginteger.send(frame, operator, operands, universe, universe.get_interpreter())
def _resend_as_double(operator, left, right, universe):
def _resend_as_double(frame, operator, left, right, universe):
left_double = universe.new_double(left.get_embedded_integer())
operands = [right]
left_double.send(operator, operands, universe, universe.get_interpreter())
left_double.send(frame, operator, operands, universe, universe.get_interpreter())
def _asString(ivkbl, frame, interpreter):
rcvr = frame.pop()
......@@ -48,9 +48,9 @@ def _plus(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("+", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "+", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("+", left, right_obj, interpreter.get_universe())
_resend_as_double(frame, "+", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
......@@ -64,9 +64,9 @@ def _minus(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("-", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "-", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("-", left, right_obj, interpreter.get_universe())
_resend_as_double(frame, "-", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
......@@ -80,9 +80,9 @@ def _mult(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("*", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "*", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("*", left, right_obj, interpreter.get_universe())
_resend_as_double(frame, "*", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
......@@ -96,9 +96,9 @@ def _doubleDiv(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("/", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "/", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("/", left, right_obj, interpreter.get_universe())
_resend_as_double(frame, "/", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
......@@ -112,9 +112,9 @@ def _intDiv(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("/", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "/", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("/", left, right_obj, interpreter.get_universe())
_resend_as_double(frame, "/", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
......@@ -128,9 +128,9 @@ def _mod(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("%", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "%", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("%", left, right_obj, interpreter.get_universe())
_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())
......@@ -142,9 +142,9 @@ def _and(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("&", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "&", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("&", left, right_obj, interpreter.get_universe())
_resend_as_double(frame, "&", left, right_obj, interpreter.get_universe())
else:
# Do operation:
right = right_obj
......@@ -159,7 +159,7 @@ def _equals(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("=", left, right_obj, interpreter.get_universe())
_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)
......@@ -180,9 +180,9 @@ def _lessThan(ivkbl, frame, interpreter):
# Check second parameter type:
if isinstance(right_obj, BigInteger):
# Second operand was BigInteger
_resend_as_biginteger("<", left, right_obj, interpreter.get_universe())
_resend_as_biginteger(frame, "<", left, right_obj, interpreter.get_universe())
elif isinstance(right_obj, Double):
_resend_as_double("<", left, right_obj, interpreter.get_universe())
_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)
......
......@@ -3,29 +3,27 @@ class AbstractObject(object):
def __init__(self):
pass
def send(self, selector_string, arguments, universe, interpreter):
def send(self, frame, selector_string, arguments, universe, interpreter):
# Turn the selector string into a selector
selector = universe.symbol_for(selector_string)
# Push the receiver onto the stack
interpreter.get_frame().push(self)
frame.push(self)
# Push the arguments onto the stack
for arg in arguments:
interpreter.get_frame().push(arg)
frame.push(arg)
# Lookup the invokable
invokable = self.get_class(universe).lookup_invokable(selector)
# Invoke the invokable
invokable.invoke(interpreter.get_frame(), interpreter)
invokable.invoke(frame, interpreter)
def send_does_not_understand(self, selector, universe, interpreter):
def send_does_not_understand(self, frame, selector, universe, interpreter):
# Compute the number of arguments
number_of_arguments = selector.get_number_of_signature_arguments()
frame = interpreter.get_frame()
# Allocate an array with enough room to hold all arguments
arguments_array = universe.new_array_with_length(number_of_arguments)
......@@ -37,15 +35,15 @@ class AbstractObject(object):
i -= 1
args = [selector, arguments_array]
self.send("doesNotUnderstand:arguments:", args, universe, interpreter)
self.send(frame, "doesNotUnderstand:arguments:", args, universe, interpreter)
def send_unknown_global(self, global_name, universe, interpreter):
def send_unknown_global(self, frame, global_name, universe, interpreter):
arguments = [global_name]
self.send("unknownGlobal:", arguments, universe, interpreter)
self.send(frame, "unknownGlobal:", arguments, universe, interpreter)
def send_escaped_block(self, block, universe, interpreter):
def send_escaped_block(self, frame, block, universe, interpreter):
arguments = [block]
self.send("escapedBlock:", arguments, universe, interpreter)
self.send(frame, "escapedBlock:", arguments, universe, interpreter)
def get_class(self, universe):
raise NotImplementedError("Subclasses need to implement get_class(universe).")
......
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