Commit 23f54217 authored by Carl Friedrich Bolz's avatar Carl Friedrich Bolz

don't store _local_offset

retrieving it from the method is fine
parent cd7e32db
......@@ -23,7 +23,6 @@ class Frame(Array):
Array.__init__(self, nilObject, num_elements)
self._stack_pointer = 0
self._bytecode_index = 0
self._local_offset = 0
self._method = method
self._context = context
self._previous_frame = previous_frame if previous_frame else nilObject
......@@ -78,6 +77,9 @@ class Frame(Array):
# Get the method by reading the field with method index
return self._method
def get_number_of_arguments(self):
return self.get_method().get_number_of_arguments()
def _get_default_number_of_fields(self):
# Return the default number of fields in a frame
return self.NUMBER_OF_FRAME_FIELDS
......@@ -104,10 +106,9 @@ class Frame(Array):
def reset_stack_pointer(self):
# arguments are stored in front of local variables
self._local_offset = self.get_method().get_number_of_arguments()
# Set the stack pointer to its initial value thereby clearing the stack
self.set_stack_pointer(self._local_offset +
self.set_stack_pointer(self.get_number_of_arguments() +
self.get_method().get_number_of_locals().get_embedded_integer() - 1)
def get_bytecode_index(self):
......@@ -129,10 +130,10 @@ class Frame(Array):
self.set_indexable_field(self.get_stack_pointer() - index, value)
def _get_local(self, index):
return self.get_indexable_field(self._local_offset + index)
return self.get_indexable_field(self.get_number_of_arguments() + index)
def _set_local(self, index, value):
self.set_indexable_field(self._local_offset + index, value)
self.set_indexable_field(self.get_number_of_arguments() + index, value)
def get_local(self, index, context_level):
# Get the local with the given index in the given context
......
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