1.1 --- a/micropython/ast.py Mon Jun 01 02:41:57 2009 +0200
1.2 +++ b/micropython/ast.py Mon Jun 01 21:10:47 2009 +0200
1.3 @@ -384,9 +384,9 @@
1.4
1.5 self._startCallFunc()
1.6 self.dispatch(node.node)
1.7 - temp, target = self._generateCallFunc(node.args, node)
1.8 - self._doCallFunc(temp, target)
1.9 - self._endCallFunc(temp, target)
1.10 + temp_target, target, temp_context = self._generateCallFunc(node.args, node)
1.11 + self._doCallFunc(temp_target, target)
1.12 + self._endCallFunc(temp_target, target, temp_context)
1.13
1.14 def visitConst(self, node):
1.15 const = self.importer.get_constant(node.value)
1.16 @@ -433,9 +433,9 @@
1.17 self.dispatch(node.expr)
1.18 self._startCallFunc()
1.19 self._generateAttr(node, "__getitem__", self.attribute_load_instructions)
1.20 - temp, target = self._generateCallFunc(node.subs, node)
1.21 - self._doCallFunc(temp, target)
1.22 - self._endCallFunc(temp, target)
1.23 + temp_target, target, temp_context = self._generateCallFunc(node.subs, node)
1.24 + self._doCallFunc(temp_target, target)
1.25 + self._endCallFunc(temp_target, target, temp_context)
1.26
1.27 def visitTuple(self, node):
1.28 self._generateSequence("tuple", node)
1.29 @@ -478,9 +478,9 @@
1.30 self._startCallFunc()
1.31 self.new_op(self.expr_temp[-1])
1.32 self._generateAttr(node, "__getitem__", self.attribute_load_instructions)
1.33 - temp, target = self._generateCallFunc([compiler.ast.Const(i)], node)
1.34 - self._doCallFunc(temp, target)
1.35 - self._endCallFunc(temp, target)
1.36 + temp_target, target, temp_context = self._generateCallFunc([compiler.ast.Const(i)], node)
1.37 + self._doCallFunc(temp_target, target)
1.38 + self._endCallFunc(temp_target, target, temp_context)
1.39
1.40 # Provide a different source value.
1.41 # NOTE: Permitting immediate usage given that neither name nor
1.42 @@ -594,14 +594,9 @@
1.43 ndefaults = len(fn.defaults)
1.44
1.45 fn.body_block = self.new_block()
1.46 - check_block = self.new_block()
1.47 -
1.48 - self._generateFunctionContextTest(node, check_block)
1.49
1.50 # Check the number of parameters and defaults.
1.51
1.52 - self.set_block(check_block)
1.53 -
1.54 self.new_op(CheckFrame((nparams, ndefaults, fn.has_star)))
1.55 if ndefaults > 0:
1.56 self.new_op(LoadFunction(fn))
1.57 @@ -649,8 +644,14 @@
1.58 # outside.
1.59
1.60 if self.unit is not node.unit:
1.61 - temp = self._generateFunctionDefaults(node.unit)
1.62 - self.new_op(LoadFunction(node.unit))
1.63 + fn = node.unit
1.64 + ndefaults = len(fn.defaults)
1.65 + temp = self._generateFunctionDefaults(fn)
1.66 +
1.67 + if ndefaults > 0:
1.68 + self.new_op(LoadConst(fn))
1.69 + else:
1.70 + self.new_op(LoadFunction(fn))
1.71
1.72 # Populate the new object required for the function.
1.73
1.74 @@ -672,14 +673,9 @@
1.75 ndefaults = len(fn.defaults)
1.76
1.77 fn.body_block = self.new_block()
1.78 - check_block = self.new_block()
1.79 -
1.80 - self._generateFunctionContextTest(node, check_block)
1.81
1.82 # Check the number of parameters and defaults.
1.83
1.84 - self.set_block(check_block)
1.85 -
1.86 self.new_op(CheckFrame((nparams, ndefaults, fn.has_star)))
1.87 if ndefaults > 0:
1.88 self.new_op(LoadTemp(0)) # context provides storage
1.89 @@ -756,9 +752,9 @@
1.90 self._startCallFunc()
1.91 self.dispatch(node.list)
1.92 self._generateAttr(node, "__iter__", self.attribute_load_instructions)
1.93 - temp, target = self._generateCallFunc([], node)
1.94 - self._doCallFunc(temp, target)
1.95 - self._endCallFunc(temp, target)
1.96 + temp_target, target, temp_context = self._generateCallFunc([], node)
1.97 + self._doCallFunc(temp_target, target)
1.98 + self._endCallFunc(temp_target, target, temp_context)
1.99
1.100 temp_iterator = self.optimiser.optimise_temp_storage()
1.101
1.102 @@ -775,9 +771,9 @@
1.103 self._startCallFunc()
1.104 self.new_op(temp_iterator)
1.105 self._generateAttr(node, "next", self.attribute_load_instructions)
1.106 - temp, target = self._generateCallFunc([], node)
1.107 - self._doCallFunc(temp, target)
1.108 - self._endCallFunc(temp, target)
1.109 + temp_target, target, temp_context = self._generateCallFunc([], node)
1.110 + self._doCallFunc(temp_target, target)
1.111 + self._endCallFunc(temp_target, target, temp_context)
1.112
1.113 # Record the value to be assigned.
1.114
1.115 @@ -860,6 +856,10 @@
1.116
1.117 if test is not None:
1.118 self.dispatch(test)
1.119 +
1.120 + temp = self.optimiser.optimise_temp_storage()
1.121 + self._generateTestBoolean(node, temp)
1.122 +
1.123 next_block = self.new_block()
1.124 self.new_op(JumpIfFalse(next_block))
1.125