1.1 --- a/rsvp.py Sun Aug 28 18:30:40 2011 +0200
1.2 +++ b/rsvp.py Mon Aug 29 23:39:18 2011 +0200
1.3 @@ -88,17 +88,31 @@
1.4 self.memory = memory
1.5 self._objlist = objlist
1.6 self._paramlist = paramlist
1.7 - self.objlist = objlist.as_raw()
1.8 - self.paramlist = paramlist.as_raw()
1.9 + end_of_code = len(self.memory)
1.10 +
1.11 + # Add the object list.
1.12 +
1.13 + self.objlist_start = len(self.memory)
1.14 + self.memory += objlist.as_raw()
1.15 +
1.16 + # Add the parameter list.
1.17 +
1.18 + self.paramlist_start = len(self.memory)
1.19 + self.memory += paramlist.as_raw()
1.20 +
1.21 + # A reference to the native library.
1.22 +
1.23 self.library = None
1.24
1.25 + # Program counter and machine configuration.
1.26 +
1.27 self.pc = pc or 0
1.28 self.debug = debug
1.29 self.abort_upon_exception = abort_upon_exception
1.30
1.31 # Profiling.
1.32
1.33 - self.coverage = [0] * len(self.memory)
1.34 + self.coverage = [0] * end_of_code
1.35 self.counter = 0
1.36 self.cost = 0
1.37
1.38 @@ -112,7 +126,7 @@
1.39 # Exception handler stacks are used to reset the state of the main
1.40 # stacks.
1.41
1.42 - self.handler_stack = [len(self.memory) - 1] # final handler is the end of the code
1.43 + self.handler_stack = [end_of_code - 1] # final handler is the end of the code
1.44 self.handler_local_sp_stack = []
1.45 self.handler_invocation_sp_stack = []
1.46 self.handler_pc_stack = []
1.47 @@ -516,7 +530,7 @@
1.48
1.49 def LoadAttrIndex(self, index, instruction):
1.50 data = self.load(self.registers[instruction.working])
1.51 - element = self.objlist[data.classcode + index]
1.52 + element = self.load(self.objlist_start + data.classcode + index)
1.53
1.54 if element is not None:
1.55 attr_index, static_attr, offset = element
1.56 @@ -536,7 +550,7 @@
1.57
1.58 def LoadAttrIndexContextCond(self, index, instruction):
1.59 data = self.load(self.registers[instruction.working])
1.60 - element = self.objlist[data.classcode + index]
1.61 + element = self.load(self.objlist_start + data.classcode + index)
1.62
1.63 if element is not None:
1.64 attr_index, static_attr, offset = element
1.65 @@ -559,7 +573,7 @@
1.66
1.67 def StoreAttrIndex(self, index, instruction):
1.68 data = self.load(self.registers[instruction.working])
1.69 - element = self.objlist[data.classcode + index]
1.70 + element = self.load(self.objlist_start + data.classcode + index)
1.71
1.72 if element is not None:
1.73 attr_index, static_attr, offset = element
1.74 @@ -600,7 +614,7 @@
1.75 def StoreFrameIndex(self, index, instruction):
1.76 frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
1.77 data = self.load(self.registers[instruction.working])
1.78 - element = self.paramlist[data.funccode + index]
1.79 + element = self.load(self.paramlist_start + data.funccode + index)
1.80
1.81 if element is not None:
1.82 # NOTE: Need to ensure correct positioning where a context has been generated.
1.83 @@ -818,7 +832,7 @@
1.84
1.85 # Find the table entry for the descendant.
1.86
1.87 - element = self.objlist[target_data.classcode + data.attrcode]
1.88 + element = self.load(self.objlist_start + target_data.classcode + data.attrcode)
1.89
1.90 if element is not None:
1.91 attr_index, static_attr, offset = element