Re: [bch-discuss] Python 2.0
Status: Alpha
Brought to you by:
mwh
|
From: Toby D. <mb...@di...> - 2000-10-05 16:11:49
|
On Thu, 5 Oct 2000 13:28:46 +0100 (BST), Michael Hudson
<mw...@ca...> wrote:
>> Is anyone looking at adding support for the new instructions in python
>> 2.0?
>
>I've been meaning to do it for a while. If you beat me to it, I certainly
>won't hold it against you!
Heres a patch for the two instructions that I am using (PRINT_ITEM_TO
and PRINT_NEWLINE_TO), and which raises a NotImplemented error for all
of those other new ones that I dont yet care about.
(If anyones interested, Ive been experimenting with allowing file-like
objects to choose their own character encoding when a unicode string
is printed)
Ive also been niggled by the way bytecodehacks imports its sibling
modules.... it assumes that the bytecodehacks package is installed as
a root package (Its more convenient for me to install it as a
sub-package below my package) Would you accept a patch to change all
of the
from bytecodehacks.ops import *
into
from ops import *
?
Index: stack_bump_methods
===================================================================
RCS file:
/cvsroot/bytecodehacks/bytecodehacks/bytecodehacks/code_gen/stack_bump_methods,v
retrieving revision 1.5
diff -c -6 -r1.5 stack_bump_methods
*** stack_bump_methods 2000/04/01 11:02:52 1.5
--- stack_bump_methods 2000/10/05 15:30:00
***************
*** 22,33 ****
--- 22,34 ----
STOP_CODE:
pass
POP_TOP:
pop()
ROT_TWO:
ROT_THREE:
+ ROT_FOUR:
pass
DUP_TOP:
push()
UNARY_POSITIVE:
UNARY_NEGATIVE:
UNARY_NOT:
***************
*** 76,87 ****
--- 77,92 ----
DELETE_SUBSCR:
pop(2)
PRINT_EXPR:
PRINT_ITEM:
pop()
PRINT_NEWLINE:
+ PRINT_ITEM_TO:
+ pop(2)
+ PRINT_NEWLINE_TO:
+ pop()
BREAK_LOOP:
pass
LOAD_LOCALS:
push()
RETURN_VALUE:
pop()
***************
*** 153,159 ****
--- 158,183 ----
num_regular_args = self.arg&0x00FF
pop(2*num_keyword_args + num_regular_args)
MAKE_FUNCTION:
pop(1 + self.arg)
BUILD_SLICE:
pop(self.arg - 1)
+ INPLACE_ADD:
+ INPLACE_SUBTRACT:
+ INPLACE_MULTIPLY:
+ INPLACE_DIVIDE:
+ INPLACE_MODULO:
+ INPLACE_LSHIFT:
+ INPLACE_RSHIFT:
+ INPLACE_AND:
+ INPLACE_XOR:
+ INPLACE_OR:
+ INPLACE_POWER:
+ IMPORT_STAR:
+ UNPACK_SEQUENCE:
+ DUP_TOPX:
+ CALL_FUNCTION_VAR:
+ CALL_FUNCTION_KW:
+ CALL_FUNCTION_VAR_KW:
+ EXTENDED_ARG:
+ raise NotImplementedError('execute for this python 2.0
instuction is not yet implemented')
Index: execute_methods
===================================================================
RCS file:
/cvsroot/bytecodehacks/bytecodehacks/bytecodehacks/code_gen/execute_methods,v
retrieving revision 1.2
diff -c -6 -r1.2 execute_methods
*** execute_methods 2000/03/15 20:55:42 1.2
--- execute_methods 2000/10/05 15:30:00
***************
*** 26,37 ****
--- 26,43 ----
stack[-2:]=[stack[-1],stack[-2]]
ROT_THREE:
stack[-3:]=[
stack[-1],
stack[-3],
stack[-2]]
+ ROT_FOUR:
+ stack[-4:]=[
+ stack[-1],
+ stack[-4],
+ stack[-3],
+ stack[-2]]
DUP_TOP:
stack.append(stack[-1])
UNARY_POSITIVE:
UNARY_NEGATIVE:
UNARY_NOT:
UNARY_CONVERT:
***************
*** 77,88 ****
--- 83,98 ----
del stack[-2:]
PRINT_EXPR:
PRINT_ITEM:
stack.pop()
PRINT_NEWLINE:
pass
+ PRINT_ITEM_TO:
+ del stack[-2:]
+ PRINT_NEWLINE_TO:
+ del stack[-1:]
BREAK_LOOP:
raise "No jumps here!"
LOAD_LOCALS:
stack.append(self)
RETURN_VALUE:
stack[:] = []
***************
*** 152,157 ****
--- 162,186 ----
num_regular_args=self.arg&0xFF
stack[-2*num_keyword_args-num_regular_args-1:]=[self]
MAKE_FUNCTION:
stack[-self.arg-1:]=[self]
BUILD_SLICE:
stack[-self.arg:]=[self]
+ INPLACE_ADD:
+ INPLACE_SUBTRACT:
+ INPLACE_MULTIPLY:
+ INPLACE_DIVIDE:
+ INPLACE_MODULO:
+ INPLACE_LSHIFT:
+ INPLACE_RSHIFT:
+ INPLACE_AND:
+ INPLACE_XOR:
+ INPLACE_OR:
+ INPLACE_POWER:
+ IMPORT_STAR:
+ UNPACK_SEQUENCE:
+ DUP_TOPX:
+ CALL_FUNCTION_VAR:
+ CALL_FUNCTION_KW:
+ CALL_FUNCTION_VAR_KW:
+ EXTENDED_ARG:
+ raise NotImplementedError('stack_manipulate for this python 2.0
instuction is not yet implemented')
Toby Dickenson
tdi...@ge...
|