micropython

Change of rsvp.py

460:f78fbedff1b0
rsvp.py
     1.1 --- a/rsvp.py	Mon Aug 29 23:39:18 2011 +0200
     1.2 +++ b/rsvp.py	Mon Aug 29 23:45:18 2011 +0200
     1.3 @@ -47,7 +47,9 @@
     1.4    * Registers: working context/value,
     1.5                 assignment source context/value,
     1.6                 current exception value,
     1.7 -               boolean status value
     1.8 +               boolean status value,
     1.9 +               object list start (constant),
    1.10 +               parameter list start (constant)
    1.11  """
    1.12  
    1.13  from micropython.program import DataValue, ReplaceableContext, PlaceholderContext, FragmentObject
    1.14 @@ -92,12 +94,12 @@
    1.15  
    1.16          # Add the object list.
    1.17  
    1.18 -        self.objlist_start = len(self.memory)
    1.19 +        objlist_start = len(self.memory)
    1.20          self.memory += objlist.as_raw()
    1.21  
    1.22          # Add the parameter list.
    1.23  
    1.24 -        self.paramlist_start = len(self.memory)
    1.25 +        paramlist_start = len(self.memory)
    1.26          self.memory += paramlist.as_raw()
    1.27  
    1.28          # A reference to the native library.
    1.29 @@ -139,13 +141,18 @@
    1.30              "source",
    1.31              "source_context",
    1.32              "exception",
    1.33 -            "status"
    1.34 +            "status",
    1.35 +            "objlist",
    1.36 +            "paramlist"
    1.37              )
    1.38          self.registers = {}
    1.39  
    1.40          for name in self.register_names:
    1.41              self.registers[name] = None
    1.42  
    1.43 +        self.registers["objlist"] = objlist_start
    1.44 +        self.registers["paramlist"] = paramlist_start
    1.45 +
    1.46          self.instruction = None
    1.47  
    1.48          # Constants.
    1.49 @@ -530,7 +537,7 @@
    1.50  
    1.51      def LoadAttrIndex(self, index, instruction):
    1.52          data = self.load(self.registers[instruction.working])
    1.53 -        element = self.load(self.objlist_start + data.classcode + index)
    1.54 +        element = self.load(self.registers["objlist"] + data.classcode + index)
    1.55  
    1.56          if element is not None:
    1.57              attr_index, static_attr, offset = element
    1.58 @@ -550,7 +557,7 @@
    1.59  
    1.60      def LoadAttrIndexContextCond(self, index, instruction):
    1.61          data = self.load(self.registers[instruction.working])
    1.62 -        element = self.load(self.objlist_start + data.classcode + index)
    1.63 +        element = self.load(self.registers["objlist"] + data.classcode + index)
    1.64  
    1.65          if element is not None:
    1.66              attr_index, static_attr, offset = element
    1.67 @@ -573,7 +580,7 @@
    1.68  
    1.69      def StoreAttrIndex(self, index, instruction):
    1.70          data = self.load(self.registers[instruction.working])
    1.71 -        element = self.load(self.objlist_start + data.classcode + index)
    1.72 +        element = self.load(self.registers["objlist"] + data.classcode + index)
    1.73  
    1.74          if element is not None:
    1.75              attr_index, static_attr, offset = element
    1.76 @@ -614,7 +621,7 @@
    1.77      def StoreFrameIndex(self, index, instruction):
    1.78          frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
    1.79          data = self.load(self.registers[instruction.working])
    1.80 -        element = self.load(self.paramlist_start + data.funccode + index)
    1.81 +        element = self.load(self.registers["paramlist"] + data.funccode + index)
    1.82  
    1.83          if element is not None:
    1.84              # NOTE: Need to ensure correct positioning where a context has been generated.
    1.85 @@ -832,7 +839,7 @@
    1.86  
    1.87          # Find the table entry for the descendant.
    1.88  
    1.89 -        element = self.load(self.objlist_start + target_data.classcode + data.attrcode)
    1.90 +        element = self.load(self.registers["objlist"] + target_data.classcode + data.attrcode)
    1.91  
    1.92          if element is not None:
    1.93              attr_index, static_attr, offset = element