1.1 --- a/docs/invocation.txt Wed Aug 27 00:45:14 2008 +0200
1.2 +++ b/docs/invocation.txt Mon Sep 01 01:32:32 2008 +0200
1.3 @@ -93,11 +93,13 @@
1.4
1.5 f(obj, 1, 2) # f known as C at compile-time
1.6
1.7 - f -> C.__new__ - don't get any context information
1.8 - -> any __init__ method will be called from C.__new__
1.9 - obj -> argument #1
1.10 - 1 -> argument #2
1.11 - 2 -> argument #3
1.12 + f -> C.__init__
1.13 + -> new instance is argument #1
1.14 + obj -> argument #2
1.15 + 1 -> argument #3
1.16 + 2 -> argument #4
1.17 +
1.18 + The new instance must be manually provided as the result after the call.
1.19
1.20 Argument lists for unknown callables:
1.21
1.22 @@ -116,6 +118,24 @@
1.23
1.24 <context> is instance: no change
1.25
1.26 +Argument lists in instantiators:
1.27 +
1.28 + f(obj, 1, 2) # f not known at compile-time
1.29 +
1.30 + f -> C.__new__ (known and called at run-time)
1.31 +
1.32 + Need to call C.__init__(<instance>, obj, 1, 2), preferably with the existing
1.33 + frame:
1.34 +
1.35 + <insert instance before received arguments>
1.36 + obj -> argument #1
1.37 + 1 -> argument #2
1.38 + 2 -> argument #3
1.39 +
1.40 + Then jump without switching frames.
1.41 + It should be possible to replace the old, tentative context information in the
1.42 + frame.
1.43 +
1.44 Defaults for unknown callables:
1.45
1.46 f(obj) # f not known at compile-time
2.1 --- a/docs/structures.txt Wed Aug 27 00:45:14 2008 +0200
2.2 +++ b/docs/structures.txt Mon Sep 01 01:32:32 2008 +0200
2.3 @@ -166,7 +166,8 @@
2.4 0 1 2 3 4 5 6
2.5 classcode attrcode invocation invocation __class__ attribute ...
2.6 reference #args, reference reference
2.7 - #defaults
2.8 + defaults
2.9 + reference
2.10
2.11 Here, the classcode refers to the attribute lookup table for the object. Since
2.12 classes and instances share the same classcode, they might resemble the
2.13 @@ -177,14 +178,16 @@
2.14 0 1 2 3 4 5 6
2.15 code for C attrcode __new__ __new__ class type attribute ...
2.16 for C reference #args, reference reference
2.17 - #defaults
2.18 + defaults
2.19 + reference
2.20
2.21 Instance of C:
2.22
2.23 0 1 2 3 4 5 6
2.24 code for C attrcode C.__call__ C.__call__ class C attribute ...
2.25 for C reference #args, reference reference
2.26 - (if exists) #defaults
2.27 + (if exists) defaults
2.28 + reference
2.29
2.30 The __new__ reference would lead to code consisting of the following
2.31 instructions:
2.32 @@ -203,7 +206,8 @@
2.33 0 1 2 3 4 5 6
2.34 code for attrcode code code class attribute ...
2.35 function for reference #args, function (default)
2.36 - function #defaults reference reference
2.37 + function defaults reference reference
2.38 + reference
2.39
2.40 Here, the code reference would lead to code for the function. Note that the
2.41 function locals are completely distinct from this structure and are not
3.1 --- a/lib/builtins.py Wed Aug 27 00:45:14 2008 +0200
3.2 +++ b/lib/builtins.py Mon Sep 01 01:32:32 2008 +0200
3.3 @@ -96,6 +96,9 @@
3.4 class frozenset(object):
3.5 def __init__(self, iterable): pass
3.6
3.7 +class function(object):
3.8 + pass
3.9 +
3.10 class int(object):
3.11 def __init__(self, number_or_string=None): pass
3.12 def __iadd__(self, other): pass
4.1 --- a/micropython/__init__.py Wed Aug 27 00:45:14 2008 +0200
4.2 +++ b/micropython/__init__.py Mon Sep 01 01:32:32 2008 +0200
4.3 @@ -103,6 +103,20 @@
4.4 else:
4.5 del self.modules[name]
4.6
4.7 + def finalise(self):
4.8 +
4.9 + "Finalise the program."
4.10 +
4.11 + for module in self.get_modules():
4.12 +
4.13 + # Fix the attributes.
4.14 +
4.15 + module.finalise_attributes()
4.16 +
4.17 + for obj in module.all_objects:
4.18 + if isinstance(obj, (micropython.inspect.Class, micropython.inspect.Function)):
4.19 + obj.finalise_attributes()
4.20 +
4.21 def get_modules(self):
4.22
4.23 "Return all modules known to the importer."
4.24 @@ -113,8 +127,12 @@
4.25
4.26 "Return a dictionary mapping modules to structures."
4.27
4.28 + if self.code is not None:
4.29 + return self.code
4.30 +
4.31 objtable = self.get_object_table()
4.32 paramtable = self.get_parameter_table()
4.33 + self.finalise()
4.34
4.35 image = []
4.36
4.37 @@ -129,10 +147,6 @@
4.38 if not with_builtins and module.name == "__builtins__":
4.39 continue
4.40
4.41 - # Fix the attributes.
4.42 -
4.43 - module.finalise_attributes()
4.44 -
4.45 pos = len(image)
4.46
4.47 # Position the module in the image and make a translation.
4.48 @@ -156,10 +170,6 @@
4.49 for obj in module.all_objects:
4.50 if isinstance(obj, micropython.inspect.Class):
4.51
4.52 - # Fix the attributes.
4.53 -
4.54 - obj.finalise_attributes()
4.55 -
4.56 # Position the class in the image.
4.57
4.58 obj.location = pos
4.59 @@ -175,18 +185,21 @@
4.60 image += obj.attributes_as_list()
4.61 pos += len(attributes.keys())
4.62
4.63 - # Class-level code is generated separately.
4.64 - # The code location is set within the code generation
4.65 - # process for the module.
4.66 + # Generate the instantiator/initialiser.
4.67 + # Append the function code to the image.
4.68
4.69 - # NOTE: Generate module and function code here.
4.70 + instantiator = obj.get_instantiator()
4.71 + instantiator.code_location = pos
4.72 + code = trans.get_instantiator_code(obj)
4.73 + image += code
4.74 + pos += len(code)
4.75 +
4.76 + # Class-level code is generated separately at the module
4.77 + # level, and the code location is set within the code
4.78 + # generation process for the module.
4.79
4.80 elif isinstance(obj, micropython.inspect.Function):
4.81
4.82 - # Fix the attributes.
4.83 -
4.84 - obj.finalise_attributes()
4.85 -
4.86 # Position the function in the image.
4.87
4.88 obj.location = pos
5.1 --- a/micropython/ast.py Wed Aug 27 00:45:14 2008 +0200
5.2 +++ b/micropython/ast.py Mon Sep 01 01:32:32 2008 +0200
5.3 @@ -138,6 +138,44 @@
5.4 self.unit.temp_usage = self.max_temp_position + 1
5.5 return self.code
5.6
5.7 + def get_instantiator_code(self, cls):
5.8 +
5.9 + "Return the code for the given class 'cls'."
5.10 +
5.11 + self.unit = cls.get_instantiator()
5.12 + self.code = []
5.13 + self.temp_positions = set()
5.14 + self.max_temp_position = -1
5.15 +
5.16 + init_method = cls.get_init_method()
5.17 +
5.18 + # Convert this frame back to being an invocation frame.
5.19 +
5.20 + self.new_op(RecoverFrame())
5.21 +
5.22 + # Fix the current frame to include a new storage slot at the beginning.
5.23 +
5.24 + self.new_op(AdjustFrame(-1))
5.25 +
5.26 + # Make an object.
5.27 +
5.28 + self.new_op(MakeObject(len(cls.instance_attributes())))
5.29 + self.new_op(StoreFrame(0))
5.30 +
5.31 + # Invoke the appropriate initialiser.
5.32 +
5.33 + self.new_op(LoadAddress(init_method))
5.34 + self.new_op(LoadCallable())
5.35 + self.new_op(JumpWithFrame())
5.36 +
5.37 + # Store the object as the result.
5.38 +
5.39 + self.new_op(LoadName(init_method.all_locals()["self"])) # load the context in the invocation frame
5.40 + self.new_op(StoreResult())
5.41 + self.new_op(Return())
5.42 +
5.43 + return self.code
5.44 +
5.45 # Name-related methods.
5.46
5.47 def get_scope(self, name):
5.48 @@ -261,6 +299,9 @@
5.49 if temp_position in self.temp_positions:
5.50 self.temp_positions.remove(temp_position)
5.51
5.52 + def set_frame_usage(self, node, extend):
5.53 + extend.attr = self.max_temp_position + node.unit.local_usage # NOTE: See get_code for similar code.
5.54 +
5.55 # Code writing methods.
5.56
5.57 def new_op(self, op):
5.58 @@ -390,8 +431,7 @@
5.59 LoadCallable,
5.60 TestIdentity, TestIdentityAddress, CheckSelf, # as one of the operands
5.61 CheckFrame,
5.62 - LoadContext, # as the object providing the result
5.63 - JumpWithFrame # as the target
5.64 + LoadContext # as the object providing the result
5.65 ))
5.66
5.67 def _is_resultant_no_operation(self, instruction):
5.68 @@ -532,15 +572,6 @@
5.69 target = last.attr.value
5.70 context = last.attr.context
5.71
5.72 - # Handle calls to classes.
5.73 -
5.74 - if isinstance(target, Class):
5.75 - target = target.get_instantiator()
5.76 - context = Undefined()
5.77 -
5.78 - # A special context is chosen to avoid generating unnecessary
5.79 - # context loading and checking instructions.
5.80 -
5.81 return target, context
5.82 else:
5.83 return None
5.84 @@ -785,7 +816,7 @@
5.85
5.86 target, context, temp = self._generateCallFuncContext()
5.87 self._generateCallFuncArgs(target, context, temp, args, node)
5.88 - return temp
5.89 + return temp, target
5.90
5.91 def _generateCallFuncContext(self):
5.92
5.93 @@ -803,6 +834,8 @@
5.94 target, context = None, None
5.95
5.96 # Store the target in temporary storage for subsequent referencing.
5.97 + # NOTE: This may not be appropriate for class invocations
5.98 + # NOTE: (instantiation).
5.99
5.100 temp = self._optimise_temp_storage()
5.101
5.102 @@ -814,6 +847,13 @@
5.103 self.new_op(LoadContext())
5.104 self.new_op(StoreFrame(0))
5.105
5.106 + # For known instantiations, provide a new object as the first argument
5.107 + # to the __init__ method.
5.108 +
5.109 + elif isinstance(target, Class):
5.110 + self.new_op(MakeObject(len(target.instance_attributes())))
5.111 + self.new_op(StoreFrame(0))
5.112 +
5.113 # Otherwise omit the context.
5.114
5.115 else:
5.116 @@ -849,9 +889,22 @@
5.117 if target is None or isinstance(context, Instance):
5.118 ncontext = 1
5.119 expect_context = 0
5.120 +
5.121 + # Handle calls to classes.
5.122 +
5.123 + elif isinstance(target, Class):
5.124 + ncontext = 1
5.125 + expect_context = 0
5.126 + target = target.get_init_method()
5.127 +
5.128 + # Method calls via classes.
5.129 +
5.130 elif isinstance(context, Class):
5.131 ncontext = 0
5.132 expect_context = 1
5.133 +
5.134 + # Function calls.
5.135 +
5.136 else:
5.137 ncontext = 0
5.138 expect_context = 0
5.139 @@ -991,7 +1044,7 @@
5.140 raise TranslateError(self.module.full_name(), node,
5.141 "Argument %r not supplied for %r: need at least %d argument(s)." % (i+1, target.name, nargs_min))
5.142
5.143 - nargs = len(args)
5.144 + nargs = frame_pos
5.145
5.146 if nargs > nargs_max and not target.has_star and not target.has_dstar:
5.147 raise TranslateError(self.module.full_name(), node,
5.148 @@ -1049,11 +1102,15 @@
5.149 self.new_op(LoadAddress(target.default_attrs[pos - nargs_min]))
5.150 self.new_op(StoreFrame(pos))
5.151
5.152 - def _doCallFunc(self, instruction):
5.153 + def _doCallFunc(self, instruction, target=None):
5.154
5.155 "Make the invocation."
5.156
5.157 - self.new_op(instruction)
5.158 + if isinstance(target, Class):
5.159 + self.new_op(LoadAddress(target.get_init_method()))
5.160 + else:
5.161 + self.new_op(instruction)
5.162 + self.new_op(LoadCallable())
5.163 self.new_op(JumpWithFrame())
5.164
5.165 def _endCallFuncArgs(self, nargs):
5.166 @@ -1063,10 +1120,13 @@
5.167 self.frame_makers[-1].attr = nargs
5.168 self.frame_makers.pop()
5.169
5.170 - def _endCallFunc(self, instruction=None, load_result=1):
5.171 + def _endCallFunc(self, instruction=None, target=None, load_result=1):
5.172
5.173 "Finish the invocation and tidy up afterwards."
5.174
5.175 + if isinstance(target, Class):
5.176 + self.new_op(LoadName(target.get_init_method().all_locals()["self"])) # load the context in the invocation frame
5.177 + self.new_op(StoreResult())
5.178 self.new_op(DropFrame())
5.179 if load_result:
5.180 self.new_op(LoadResult())
5.181 @@ -1482,9 +1542,9 @@
5.182
5.183 self._startCallFunc()
5.184 self.dispatch(node.node)
5.185 - temp = self._generateCallFunc(node.args, node)
5.186 - self._doCallFunc(temp)
5.187 - self._endCallFunc(temp)
5.188 + temp, target = self._generateCallFunc(node.args, node)
5.189 + self._doCallFunc(temp, target)
5.190 + self._endCallFunc(temp, target)
5.191
5.192 def visitClass(self, node):
5.193
5.194 @@ -1632,9 +1692,9 @@
5.195 self._startCallFunc()
5.196 self.dispatch(node.list)
5.197 self._generateAttr(node, "__iter__", self.attribute_load_instructions)
5.198 - temp = self._generateCallFunc([], node)
5.199 - self._doCallFunc(temp)
5.200 - self._endCallFunc(temp)
5.201 + temp, target = self._generateCallFunc([], node)
5.202 + self._doCallFunc(temp, target)
5.203 + self._endCallFunc(temp, target)
5.204
5.205 temp_iterator = self._optimise_temp_storage()
5.206
5.207 @@ -1647,9 +1707,9 @@
5.208 self._startCallFunc()
5.209 self.new_op(temp_iterator)
5.210 self._generateAttr(node, "next", self.attribute_load_instructions)
5.211 - temp = self._generateCallFunc([], node)
5.212 - self._doCallFunc(temp)
5.213 - self._endCallFunc(temp)
5.214 + temp, target = self._generateCallFunc([], node)
5.215 + self._doCallFunc(temp, target)
5.216 + self._endCallFunc(temp, target)
5.217
5.218 # Test for StopIteration.
5.219
5.220 @@ -1717,7 +1777,7 @@
5.221
5.222 self.new_op(Return())
5.223
5.224 - extend.attr = self.max_temp_position + node.unit.local_usage # NOTE: See get_code for similar code.
5.225 + self.set_frame_usage(node, extend)
5.226
5.227 def visitGenExpr(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExpr")
5.228
6.1 --- a/micropython/data.py Wed Aug 27 00:45:14 2008 +0200
6.2 +++ b/micropython/data.py Mon Sep 01 01:32:32 2008 +0200
6.3 @@ -436,10 +436,12 @@
6.4 "Return a function which can be used to instantiate the class."
6.5
6.6 if self.instantiator is None:
6.7 - init_method = self.all_class_attributes()["__init__"].value
6.8 - self.instantiator = init_method.function_from_method()
6.9 + self.instantiator = self.get_init_method().function_from_method()
6.10 return self.instantiator
6.11
6.12 + def get_init_method(self):
6.13 + return self.all_class_attributes()["__init__"].value
6.14 +
6.15 # Class-specific methods.
6.16
6.17 def add_base(self, base):
7.1 --- a/micropython/rsvp.py Wed Aug 27 00:45:14 2008 +0200
7.2 +++ b/micropython/rsvp.py Mon Sep 01 01:32:32 2008 +0200
7.3 @@ -20,13 +20,39 @@
7.4 """
7.5
7.6 from micropython.common import Label
7.7 -from micropython.data import Attr, Const, Instance
7.8 +from micropython.data import Attr, Class, Const, Function
7.9
7.10 -def raw(code):
7.11 +def raw(code, objtable, paramtable):
7.12 new_code = []
7.13 for item in code:
7.14 if isinstance(item, Attr):
7.15 - new_code.append((item.context and item.context.location, item.value and item.value.location)) # no useful context is provided
7.16 + new_code.append((
7.17 + item.context and item.context.location,
7.18 + item.value and item.value.location # no useful context is provided
7.19 + ))
7.20 + elif isinstance(item, Class):
7.21 + # NOTE: Need initialiser details!
7.22 + new_code.append((
7.23 + objtable.as_list().get_code(item.full_name()),
7.24 + objtable.get_index(item.full_name()),
7.25 + item.get_instantiator().code_location,
7.26 + len(item.get_instantiator().positional_names)
7.27 + ))
7.28 + elif isinstance(item, Const):
7.29 + # NOTE: Need class details!
7.30 + new_code.append((
7.31 + None, #objtable.as_list().get_code(item.full_name()),
7.32 + None, #objtable.get_index(item.full_name()),
7.33 + None, None
7.34 + ))
7.35 + elif isinstance(item, Function):
7.36 + # NOTE: Need class and parameter details! Should arguably be types.FunctionType.
7.37 + new_code.append((
7.38 + objtable.as_list().get_code("__builtins__.function"),
7.39 + objtable.get_index("__builtins__.function"),
7.40 + item.code_location,
7.41 + len(item.positional_names)
7.42 + ))
7.43 else:
7.44 new_code.append(item)
7.45 return new_code
7.46 @@ -66,6 +92,9 @@
7.47 else:
7.48 return ""
7.49
7.50 + def get_operand(self):
7.51 + return None
7.52 +
7.53 class FrameRelativeInstruction(Instruction):
7.54
7.55 "An instruction operating on the current frame."
7.56 @@ -175,6 +204,7 @@
7.57
7.58 class MakeFrame(Immediate): "Make a new invocation frame."
7.59 class DropFrame(Instruction): "Drop an invocation frame."
7.60 +class RecoverFrame(Instruction): "Recover the current frame as an invocation frame."
7.61 class StoreFrame(Immediate): "Store the current value as an argument for the parameter with the given position."
7.62 class StoreFrameIndex(Immediate): "Store the current value as an argument for the parameter with the given index."
7.63 class LoadCallable(Instruction): "Load the target of an invocation."
7.64 @@ -185,8 +215,9 @@
7.65
7.66 # Invocation-related instructions, using a special result "register".
7.67
7.68 -class JumpWithFrame(Instruction): "Jump, adopting the invocation frame, to the callable found as the current value."
7.69 +class JumpWithFrame(Instruction): "Jump, adopting the invocation frame, to the current callable."
7.70 class ExtendFrame(Immediate): "Extend the current frame for temporary storage use."
7.71 +class AdjustFrame(Immediate): "Adjust the current frame for corrected invocations."
7.72 class Return(Instruction): "Return from a subprogram."
7.73 class LoadResult(Instruction): "Load into the current value a returned value."
7.74 class StoreResult(Instruction): "Store the current value as a value to be returned."
8.1 --- a/micropython/table.py Wed Aug 27 00:45:14 2008 +0200
8.2 +++ b/micropython/table.py Mon Sep 01 01:32:32 2008 +0200
8.3 @@ -46,6 +46,12 @@
8.4 def __getitem__(self, i):
8.5 return self.displaced[i]
8.6
8.7 + def get_code(self, name):
8.8 +
8.9 + "Return the code/offset of the given 'name'."
8.10 +
8.11 + return self.offsets.get(name)
8.12 +
8.13 # Simulation methods.
8.14
8.15 def access(self, objname, attrname):
8.16 @@ -222,15 +228,6 @@
8.17 self.names = self.names or list(self.attributes)
8.18 return self.names
8.19
8.20 - def get_code(self, name):
8.21 -
8.22 - "Return the code of the given 'name'."
8.23 -
8.24 - try:
8.25 - return self.object_names().index(name)
8.26 - except ValueError:
8.27 - raise TableError, "Name %r is not registered as an object in the table." % name
8.28 -
8.29 def get_index(self, name):
8.30
8.31 "Return the index of the given 'name'."
8.32 @@ -320,6 +317,12 @@
8.33
8.34 return self.displaced_list
8.35
8.36 + def as_raw(self):
8.37 +
8.38 + "Return the raw contents of the table as a list of values."
8.39 +
8.40 + return self.as_list().as_raw()
8.41 +
8.42 class ObjectTable(Table):
8.43
8.44 "An object table."
9.1 --- a/rsvp.py Wed Aug 27 00:45:14 2008 +0200
9.2 +++ b/rsvp.py Mon Sep 01 01:32:32 2008 +0200
9.3 @@ -90,6 +90,23 @@
9.4 self.result = None
9.5 self.exception = None
9.6
9.7 + def dump(self):
9.8 + print "PC", self.pc
9.9 + print "PC stack", self.pc_stack
9.10 + print "Frame stack", self.frame_stack
9.11 + print "Local stack pointers", self.local_sp_stack
9.12 + print "Invocation stack pointers", self.invocation_sp_stack
9.13 + print "Handler stack", self.handler_stack
9.14 + print
9.15 + print "Instruction", self.instruction
9.16 + print "Operand", self.operand
9.17 + print "Value", self.value
9.18 + print "Status", self.status
9.19 + print "Source", self.source
9.20 + print "Callable", self.callable
9.21 + print "Result", self.result
9.22 + print "Exception", self.exception
9.23 +
9.24 def load(self, address):
9.25
9.26 "Return the value at the given 'address'."
9.27 @@ -149,18 +166,14 @@
9.28 "Execute code in the memory at the current PC address."
9.29
9.30 self.instruction = self.load(self.pc)
9.31 - self.operand = self.instruction.get_operand()
9.32 -
9.33 - instruction_name = self.instruction.__class__.__name__
9.34 - if self.debug:
9.35 - print "%8d %s" % (self.pc, instruction_name)
9.36 -
9.37 - method = self.get_method(instruction_name)
9.38
9.39 # Process any inputs of the instruction.
9.40
9.41 self.process_inputs()
9.42 - next_pc = method()
9.43 +
9.44 + # Perform the instruction itself.
9.45 +
9.46 + next_pc = self.perform(self.instruction)
9.47
9.48 # Update the program counter.
9.49
9.50 @@ -169,15 +182,26 @@
9.51 else:
9.52 self.pc = next_pc
9.53
9.54 - def get_method(self, instruction_name):
9.55 + def get_method(self, instruction):
9.56 +
9.57 + "Return the handler method for the given 'instruction'."
9.58
9.59 - "Return the handler method for the given 'instruction_name'."
9.60 -
9.61 + instruction_name = instruction.__class__.__name__
9.62 + if self.debug:
9.63 + print "%8d %s" % (self.pc, instruction_name)
9.64 method = getattr(self, instruction_name, None)
9.65 if method is None:
9.66 raise IllegalInstruction, (self.pc, instruction_name)
9.67 return method
9.68
9.69 + def perform(self, instruction):
9.70 +
9.71 + "Perform the 'instruction', returning the next PC value or None."
9.72 +
9.73 + self.operand = instruction.get_operand()
9.74 + method = self.get_method(instruction)
9.75 + return method()
9.76 +
9.77 def process_inputs(self):
9.78
9.79 """
9.80 @@ -188,8 +212,7 @@
9.81
9.82 for input in (self.instruction.input, self.instruction.source):
9.83 if input is not None:
9.84 - method = self.get_method(input)
9.85 - method()
9.86 + self.perform(input)
9.87
9.88 def jump(self, addr, next):
9.89
9.90 @@ -294,6 +317,9 @@
9.91 frame = self.invocation_sp_stack.pop()
9.92 self.frame_stack = self.frame_stack[:frame] # reset stack before call
9.93
9.94 + def RecoverFrame(self):
9.95 + self.local_sp_stack.pop()
9.96 +
9.97 def StoreFrame(self):
9.98 frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
9.99 self.frame_stack[frame + self.operand] = self.value
9.100 @@ -372,6 +398,14 @@
9.101 frame = self.local_sp_stack[-1]
9.102 frame.extend([None] * self.operand)
9.103
9.104 + def AdjustFrame(self):
9.105 + if self.operand > 0:
9.106 + frame.append([None] * self.operand)
9.107 + elif self.operand == -1:
9.108 + self.invocation_sp_stack[-1] -= 1
9.109 + else:
9.110 + raise Exception, "AdjustFrame %r" % self.operand
9.111 +
9.112 def Return(self):
9.113 self.pc = self.pull_pc()
9.114
10.1 --- a/test.py Wed Aug 27 00:45:14 2008 +0200
10.2 +++ b/test.py Mon Sep 01 01:32:32 2008 +0200
10.3 @@ -28,8 +28,14 @@
10.4 "".join(entry and "#" or "_" for entry in table_slice)
10.5
10.6 def machine(importer):
10.7 - rc = raw(importer.code)
10.8 - rm = rsvp.RSVPMachine(rc)
10.9 + print "Making the image..."
10.10 + make(importer)
10.11 + rc = raw(importer.get_image())
10.12 + print "Getting raw tables..."
10.13 + objtable = importer.get_object_table().as_raw()
10.14 + paramtable = importer.get_parameter_table().as_raw()
10.15 + print "Initialising the machine..."
10.16 + rm = rsvp.RSVPMachine(rc, objtable, paramtable)
10.17 rm.pc = importer.code_location
10.18 return rm
10.19
11.1 --- a/tests/call_method.py Wed Aug 27 00:45:14 2008 +0200
11.2 +++ b/tests/call_method.py Mon Sep 01 01:32:32 2008 +0200
11.3 @@ -1,6 +1,9 @@
11.4 #!/usr/bin/env python
11.5
11.6 class C:
11.7 + def __init__(self, x):
11.8 + pass
11.9 +
11.10 def f(self, a, b, c):
11.11 self.g(a)
11.12 m = self.g
11.13 @@ -12,7 +15,7 @@
11.14 def h(self, p):
11.15 pass
11.16
11.17 -c = C()
11.18 +c = C(123)
11.19 c.f(1, 2, 3)
11.20
11.21 f = c.f