# HG changeset patch # User Paul Boddie # Date 1238895681 -7200 # Node ID 617f1f7f56ec93e5ce38bfc767a3cee67d3618de # Parent 072c14d15074a2fd11efade435bf45ef490e512a Fixed constant loading. Added bool to the builtins in order to ensure its presence. Changed various load operations to have identical contexts and values (in order to support callable instances). Added a simple boolean native method. diff -r 072c14d15074 -r 617f1f7f56ec lib/builtins.py --- a/lib/builtins.py Sun Apr 05 03:05:59 2009 +0200 +++ b/lib/builtins.py Sun Apr 05 03:41:21 2009 +0200 @@ -336,5 +336,6 @@ StopIteration TypeError ellipsis +bool # vim: tabstop=4 expandtab shiftwidth=4 diff -r 072c14d15074 -r 617f1f7f56ec micropython/trans.py --- a/micropython/trans.py Sun Apr 05 03:05:59 2009 +0200 +++ b/micropython/trans.py Sun Apr 05 03:41:21 2009 +0200 @@ -1137,11 +1137,11 @@ end_block = self.new_block() self.new_op(JumpIfTrue(true_block)) - self.new_op(LoadAddress(self.importer.get_predefined_constant("False"))) + self.new_op(LoadConst(self.importer.get_predefined_constant("False"))) self.new_op(Jump(end_block)) self.set_block(true_block) - self.new_op(LoadAddress(self.importer.get_predefined_constant("True"))) + self.new_op(LoadConst(self.importer.get_predefined_constant("True"))) self.set_block(end_block) diff -r 072c14d15074 -r 617f1f7f56ec rsvp.py --- a/rsvp.py Sun Apr 05 03:05:59 2009 +0200 +++ b/rsvp.py Sun Apr 05 03:41:21 2009 +0200 @@ -325,7 +325,7 @@ # Instructions. def LoadConst(self): - self.value = None, self.operand + self.value = self.operand, self.operand def LoadName(self): frame = self.local_sp_stack[-1] @@ -478,7 +478,7 @@ def LoadContext(self): context, ref = self.value - self.value = None, context + self.value = context, context def CheckFrame(self): operand = self.operand @@ -561,7 +561,7 @@ return self.operand def LoadException(self): - self.value = None, self.exception + self.value = self.exception, self.exception def StoreException(self): self.exception = self.value[1] @@ -696,11 +696,20 @@ else: self.result = self.false_constant, self.false_constant + def builtins_bool_bool(self): + frame = self.local_sp_stack[-1] + + # Get operands addresses. + + left_context, left = self.frame_stack[frame] + self.result = left, left + native_functions = { "__builtins__.object.__init__" : builtins_object_init, "__builtins__.int.__init__" : builtins_int_init, "__builtins__.int.__add__" : builtins_int_add, "__builtins__.int.__bool__" : builtins_int_bool, + "__builtins__.bool.__bool__" : builtins_bool_bool, } # vim: tabstop=4 expandtab shiftwidth=4