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

Added Primitive class


Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 601e52da
from som.vmobjects.object import Object
from som.vmobjects.invokable import Invokable
class Primitive(Object, Invokable):
# Static field indices and number of primitive fields
SIGNATURE_INDEX = 1 + Object.CLASS_INDEX
HOLDER_INDEX = 1 + SIGNATURE_INDEX
NUMBER_OF_PRIMITIVE_FIELDS = 1 + HOLDER_INDEX
def __init__(self, signature_string, universe, invoke, is_empty = None):
super(Primitive, self).__init__(universe.nilObject)
# Set the class of this primitive to be the universal primitive class
self.set_class(universe.primitiveClass)
# Set the signature of this primitive
self._set_signature(universe.symbol_for(signature_string))
self.invoke = invoke
if is_empty:
self.is_empty = is_empty
def is_primitive(self):
return True
def get_signature(self):
# Get the signature by reading the field with signature index
return self.get_field(self.SIGNATURE_INDEX)
def _set_signature(self, value):
# Set the signature by writing to the field with signature index
self.set_field(self.SIGNATURE_INDEX, value)
def get_holder(self):
# Get the holder of this method by reading the field with holder index
return self.get_field(self.HOLDER_INDEX)
def set_holder(self, value):
# Set the holder of this method by writing to the field with holder index
self.set_field(self.HOLDER_INDEX, value)
def _get_default_number_of_fields(self):
# Return the default number of fields for a primitive
return self.NUMBER_OF_PRIMITIVE_FIELDS
def is_empty(self):
# By default a primitive is not empty
return False
@classmethod
def get_empty_primitive(cls, signature_string, universe):
# Return an empty primitive with the given signature
def invoke(self, frame, interpreter):
# Write a warning to the screen
universe.println("Warning: undefined primitive " +
self.get_signature().get_string() + " called")
# The empty primitives are empty
def is_empty(self): return True
return Primitive(signature_string, universe, invoke, is_empty)
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