[Python-checkins] python/nondist/sandbox/pickletools pickletools.py,1.5,1.6

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 25 Jan 2003 19:06:48 -0800


Update of /cvsroot/python/python/nondist/sandbox/pickletools
In directory sc8-pr-cvs1:/tmp/cvs-serv6684

Modified Files:
	pickletools.py 
Log Message:
Did the stack manipulation opcodes.


Index: pickletools.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/pickletools/pickletools.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** pickletools.py	26 Jan 2003 02:43:38 -0000	1.5
--- pickletools.py	26 Jan 2003 03:06:46 -0000	1.6
***************
*** 333,336 ****
--- 333,373 ----
                doc="A Python float object.")
  
+ anyobject = StackObject(
+                 name='any',
+                 obtype=object,
+                 doc="Any kind of object whatsoever.")
+ 
+ markobject = StackObject(
+                  name="mark",
+                  obtype=StackObject,
+                  doc="""'The mark' is a unique object.
+ 
+                  Opcodes that operate on a variable number of objects
+                  generally don't embed the count of objects in the opcode,
+                  or pull it off the stack.  Instead the MARK opcode is used
+                  to push a special marker object on the stack, and then
+                  some other opcodes grab all the objects from the top of
+                  the stack down to (but not including) the topmost marker
+                  object.
+                  """)
+ 
+ stackslice = StackObject(
+                  name="stackslice",
+                  obtype=StackObject,
+                  doc="""An object representing a contiguous slice of the stack.
+ 
+                  This is used in conjuction with markobject, to represent all
+                  of the stack following the topmost markobject.  For example,
+                  the POP_MARK opcode changes the stack from
+ 
+                      [..., markobject, stackslice]
+                  to
+                      [...]
+ 
+                  No matter how many object are on the stack after the topmost
+                  markobject, POP_MARK gets rid of all of them (including the
+                  topmost markobject too).
+                  """)
+ 
  ##############################################################################
  # Descriptors for pickle opcodes.
***************
*** 500,536 ****
        """),
  
!     # XXX opcodes below this point haven't been done yet.
  
!     I(name='MARK',
!       code='(',
        args=[],
!       stack_before=[],
        stack_after=[],
        proto=0,
!       doc="""XXX One-line description goes here.
! 
!       XXX Doc body goes here.
!       """),
  
!     I(name='STOP',
!       code='.',
        args=[],
!       stack_before=[],
!       stack_after=[],
        proto=0,
!       doc="""XXX One-line description goes here.
! 
!       XXX Doc body goes here.
!       """),
  
!     I(name='POP',
!       code='0',
        args=[],
        stack_before=[],
!       stack_after=[],
        proto=0,
!       doc="""XXX One-line description goes here.
  
!       XXX Doc body goes here.
        """),
  
--- 537,569 ----
        """),
  
!     # Stack manipulation.
  
!     I(name='POP',
!       code='0',
        args=[],
!       stack_before=[anyobject],
        stack_after=[],
        proto=0,
!       doc="Discard the top stack item."),
  
!     I(name='DUP',
!       code='2',
        args=[],
!       stack_before=[anyobject],
!       stack_after=[anyobject, anyobject],
        proto=0,
!       doc="Push the top stack item onto the stack again, duplicating it."),
  
!     I(name='MARK',
!       code='(',
        args=[],
        stack_before=[],
!       stack_after=[markobject],
        proto=0,
!       doc="""Push a marker object onto the stack.
  
!       The marker is a unique object, used by other opcodes to identify a
!       region of the stack containing a variable number of objects for them
!       to work on.  See markobject.doc for more detail.
        """),
  
***************
*** 538,551 ****
        code='1',
        args=[],
!       stack_before=[],
        stack_after=[],
        proto=0,
!       doc="""XXX One-line description goes here.
  
!       XXX Doc body goes here.
        """),
  
!     I(name='DUP',
!       code='2',
        args=[],
        stack_before=[],
--- 571,588 ----
        code='1',
        args=[],
!       stack_before=[markobject, stackslice],
        stack_after=[],
        proto=0,
!       doc="""Pop all the stack objects at and above the topmost marker object.
  
!       When an opcode using a variable number of stack objects is done,
!       POP_MARK is used to remove those objects, and to remove the marker
!       object that delimited their starting position on the stack.
        """),
  
!     # XXX opcodes below this point haven't been done yet.
! 
!     I(name='STOP',
!       code='.',
        args=[],
        stack_before=[],