To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 04495acc authored by Stefan Marr's avatar Stefan Marr
Browse files

Added ArrayPrimitives


Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 00b61f56
from som.vmobjects.primitive import Primitive
from som.primitives.primitives import Primitives
class ArrayPrimitives(Primitives):
def install_primitives(self):
def _at(self, 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):
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):
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):
length = frame.pop()
frame.pop() # not required
frame.push(self._universe.new_array_with_length(length.get_embedded_integer()))
self._install_instance_primitive(Primitive("new:", self._universe, _new))
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