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 9d3b373b authored by Stefan Marr's avatar Stefan Marr
Browse files

First parameter of invokable should not be named self



- this makes it simpler to distinguish the meaning of the different 'self's
Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent ac3559c0
......@@ -4,25 +4,25 @@ from som.primitives.primitives import Primitives
class ArrayPrimitives(Primitives):
def install_primitives(self):
def _at(self, frame, interpreter):
def _at(ivkbl, frame, interpreter):
i = frame.pop()
rcvr = frame.pop()
frame.push(rcvr.get_indexable_field(i.get_embedded_integer() - 1))
self._install_instance_primitive(Primitive("at:", self._universe, _at))
def _atPut(self, frame, interpreter):
def _atPut(ivkbl, frame, interpreter):
value = frame.pop()
index = frame.pop()
rcvr = frame.get_stack_element(0)
rcvr.set_indexable_field(index.get_embedded_integer() - 1, value)
self._install_instance_primitive(Primitive("at:put:", self._universe, _atPut))
def _length(self, frame, interpreter):
def _length(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_integer(rcvr.get_number_of_indexable_fields()))
self._install_instance_primitive(Primitive("length", self._universe, _length))
def _new(self, frame, interpreter):
def _new(ivkbl, frame, interpreter):
length = frame.pop()
frame.pop() # not required
frame.push(self._universe.new_array_with_length(length.get_embedded_integer()))
......
......@@ -6,18 +6,18 @@ import math
class BigIntegerPrimitives(Primitives):
def install_primitives(self):
def _asString(self, frame, interpreter):
def _asString(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_string(str(rcvr.get_embedded_biginteger())))
self._install_instance_primitive(Primitive("asString", self._universe, _asString))
def _sqrt(self, frame, interpreter):
def _sqrt(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_double(
math.sqrt(rcvr.get_embedded_biginteger())))
self._install_instance_primitive(Primitive("sqrt", self._universe, _sqrt))
def _plus(self, frame, interpreter):
def _plus(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......@@ -36,7 +36,7 @@ class BigIntegerPrimitives(Primitives):
frame.push(self._universe.new_integer(result))
self._install_instance_primitive(Primitive("+", self._universe, _plus))
def _minus(self, frame, interpreter):
def _minus(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......@@ -56,7 +56,7 @@ class BigIntegerPrimitives(Primitives):
frame.push(self._universe.new_integer(result.intValue()));
self._install_instance_primitive(Primitive("-", self._universe, _minus))
def _mult(self, frame, interpreter):
def _mult(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......@@ -75,7 +75,7 @@ class BigIntegerPrimitives(Primitives):
frame.push(self._universe.new_integer(result))
self._install_instance_primitive(Primitive("*", self._universe, _mult))
def _div(self, frame, interpreter):
def _div(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......@@ -94,7 +94,7 @@ class BigIntegerPrimitives(Primitives):
frame.push(self._universe.new_integer(result))
self._install_instance_primitive(Primitive("/", self._universe, _div))
def _mod(self, frame, interpreter):
def _mod(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......@@ -109,7 +109,7 @@ class BigIntegerPrimitives(Primitives):
frame.push(self._universe.new_biginteger(left.get_embedded_biginteger() % right.get_embedded_biginteger()))
self._install_instance_primitive(Primitive("%", self._universe, _mod))
def _and(self, frame, interpreter):
def _and(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......@@ -124,7 +124,7 @@ class BigIntegerPrimitives(Primitives):
frame.push(self._universe.new_biginteger(left.get_embedded_biginteger() & right.get_embedded_biginteger()))
self._install_instance_primitive(Primitive("&", self._universe, _and))
def _equals(self, frame, interpreter):
def _equals(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......@@ -142,7 +142,7 @@ class BigIntegerPrimitives(Primitives):
frame.push(self._universe.falseObject)
self._install_instance_primitive(Primitive("=", self._universe, _equals))
def _lessThan(self, frame, interpreter):
def _lessThan(ivkbl, frame, interpreter):
right_obj = frame.pop()
left = frame.pop()
......
......@@ -4,7 +4,7 @@ from som.vmobjects.primitive import Primitive
class ClassPrimitives(Primitives):
def install_primitives(self):
def _new(self, frame, interpreter):
def _new(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_instance(rcvr))
self._install_instance_primitive(Primitive("new", self._universe, _new))
\ No newline at end of file
......@@ -6,7 +6,7 @@ from som.vmobjects.array import Array
class ObjectPrimitives(Primitives):
def install_primitives(self):
def _equals(self, frame, interpreter):
def _equals(ivkbl, frame, interpreter):
op1 = frame.pop()
op2 = frame.pop()
if op1 is op2:
......@@ -15,13 +15,13 @@ class ObjectPrimitives(Primitives):
frame.push(self._universe.falseObject)
self._install_instance_primitive(Primitive("==", self._universe, _equals))
def _hashcode(self, frame, interpreter):
def _hashcode(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_integer(hash(rcvr)))
self._install_instance_primitive(Primitive("hashcode", self._universe, _hashcode))
def _objectSize(self, frame, interpreter):
def _objectSize(ivkbl, frame, interpreter):
rcvr = frame.pop()
size = rcvr.get_number_of_fields()
if isinstance(rcvr, Array):
......@@ -30,7 +30,7 @@ class ObjectPrimitives(Primitives):
frame.push(self._universe.new_integer(size))
self._install_instance_primitive(Primitive("objectSize", self._universe, _objectSize))
def _perform(self, frame, interpreter):
def _perform(ivkbl, frame, interpreter):
selector = frame.pop()
rcvr = frame.get_stack_element(0)
......@@ -38,7 +38,7 @@ class ObjectPrimitives(Primitives):
invokable.invoke(frame, interpreter)
self._install_instance_primitive(Primitive("perform:", self._universe, _perform))
def _performInSuperclass(self, frame, interpreter):
def _performInSuperclass(ivkbl, frame, interpreter):
clazz = frame.pop()
selector = frame.pop()
rcvr = frame.get_stack_element(0)
......@@ -47,7 +47,7 @@ class ObjectPrimitives(Primitives):
invokable.invoke(frame, interpreter)
self._install_instance_primitive(Primitive("perform:inSuperclass:", self._universe, _performInSuperclass))
def _performWithArguments(self, frame, interpreter):
def _performWithArguments(ivkbl, frame, interpreter):
args = frame.pop()
selector = frame.pop()
rcvr = frame.get_stack_element(0)
......@@ -59,14 +59,14 @@ class ObjectPrimitives(Primitives):
invokable.invoke(frame, interpreter)
self._install_instance_primitive(Primitive("perform:withArguments:", self._universe, _performWithArguments))
def _instVarAt(self, frame, interpreter):
def _instVarAt(ivkbl, frame, interpreter):
idx = frame.pop()
rcvr = frame.pop()
frame.push(rcvr.get_field(idx.get_embedded_integer() - 1))
self._install_instance_primitive(Primitive("instVarAt:", self._universe, _instVarAt))
def _instVarAtPut(self, frame, interpreter):
def _instVarAtPut(ivkbl, frame, interpreter):
val = frame.pop()
idx = frame.pop()
rcvr = frame.get_stack_element(0)
......
......@@ -4,7 +4,7 @@ from som.vmobjects.primitive import Primitive
class SymbolPrimitives(Primitives):
def install_primitives(self):
def _asString(self, frame, interpreter):
def _asString(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_string(rcvr.get_string()))
self._install_instance_primitive(Primitive("asString", self._universe, _asString))
......@@ -33,24 +33,23 @@ class Block(Object):
return self.NUMBER_OF_BLOCK_FIELDS
class Evaluation(Primitive):
def __init__(self, num_args, universe):
super(Evaluation, self).__init__(self._compute_signature_string(num_args), universe, self.invoke)
def __init__(self, num_args, universe):
def _invoke(ivkbl, frame, interpreter):
# Get the block (the receiver) from the stack
rcvr = frame.get_stack_element(ivkbl._number_of_arguments - 1)
# Get the context of the block...
context = rcvr.get_context()
# Push a new frame and set its context to be the one specified in
# the block
new_frame = interpreter.push_new_frame(rcvr.get_method())
new_frame.copy_arguments_from(frame)
new_frame.set_context(context)
super(Block.Evaluation, self).__init__(self._compute_signature_string(num_args), universe, _invoke)
self._number_of_arguments = num_args
def invoke(self, frame, interpreter):
# Get the block (the receiver) from the stack
rcvr = frame.get_stack_element(self._number_of_arguments - 1)
# Get the context of the block...
context = rcvr.get_context()
# Push a new frame and set its context to be the one specified in
# the block
new_frame = interpreter.push_new_frame(rcvr.get_method())
new_frame.copy_arguments_from(frame);
new_frame.set_context(context)
def _compute_signature_string(self, num_args):
# Compute the signature string
signature_string = "value"
......
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