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

Added StringPrimitives


Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 2f239eb2
from som.primitives.primitives import Primitives
from som.vmobjects.primitive import Primitive
class StringPrimitives(Primitives):
def install_primitives(self):
def _concat(ivkbl, frame, interpreter):
argument = frame.pop()
rcvr = frame.pop()
frame.push(self._universe.new_string(rcvr.get_embedded_string()
+ argument.get_embedded_string()))
self._install_instance_primitive(Primitive("concatenate:", self._universe, _concat))
def _asSymbol(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.symbol_for(rcvr.get_embedded_string()))
self._install_instance_primitive(Primitive("asSymbol", self._universe, _asSymbol))
def _length(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_integer(rcvr.get_embedded_string().length()))
self._install_instance_primitive(Primitive("length", self._universe, _length))
def _equals(ivkbl, frame, interpreter):
op1 = frame.pop()
op2 = frame.pop() # rcvr
if op1.get_class() == self._universe.stringClass:
if op1.get_embedded_string() == op2.get_embedded_string():
frame.push(self._universe.trueObject)
return
frame.push(self._universe.falseObject)
self._install_instance_primitive(Primitive("=", self._universe, _equals))
def _substring(ivkbl, frame, interpreter):
end = frame.pop()
start = frame.pop()
rcvr = frame.pop()
try:
frame.push(self._universe.new_string(rcvr.get_embedded_string()[
start.get_embedded_integer():end.get_embedded_integer() + 1]))
except IndexError, e:
frame.push(self._universe.new_string("Error - index out of bounds: %s" % e))
self._install_instance_primitive(Primitive("primSubstringFrom:to:", self._universe, _substring))
def _hashcode(ivkbl, frame, interpreter):
rcvr = frame.pop()
frame.push(self._universe.new_integer(hash(rcvr.get_embedded_string())))
self._install_instance_primitive(Primitive("hashcode", self._universe, _hashcode))
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