Commit 5865b2c0 by Stefan Marr

Pass class in Object constructor to avoid set afterwards

Signed-off-by: Stefan Marr <git@stefan-marr.de>
1 parent 038bffe8
......@@ -378,9 +378,7 @@ class Universe(object):
num_bytecodes, signature)
def new_instance(self, instance_class):
result = Object(self.nilObject, instance_class.get_number_of_instance_fields())
result.set_class(instance_class)
return result
return Object(self.nilObject, instance_class.get_number_of_instance_fields(), instance_class)
@staticmethod
def new_integer(value):
......
......@@ -8,10 +8,11 @@ class Object(AbstractObject):
# Static field indices and number of object fields
NUMBER_OF_OBJECT_FIELDS = 0
def __init__(self, nilObject, number_of_fields = -1):
num_fields = number_of_fields if number_of_fields != -1 else self._get_default_number_of_fields()
def __init__(self, nilObject, number_of_fields = -1, obj_class = None):
num_fields = (number_of_fields if number_of_fields != -1
else self._get_default_number_of_fields())
self._fields = [nilObject] * num_fields
self._class = nilObject
self._class = obj_class or nilObject
def get_class(self, universe):
return self._class
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!