[Subversion] / BytecodeAssembler / README.txt  

Diff of /BytecodeAssembler/README.txt

Parent Directory | Revision Log

version 2573, Mon Aug 4 22:17:03 2008 UTC version 2575, Tue Aug 12 18:09:37 2008 UTC
Line 18 
Line 18 
   
 .. _BytecodeAssembler reference manual: http://peak.telecommunity.com/DevCenter/BytecodeAssembler#toc  .. _BytecodeAssembler reference manual: http://peak.telecommunity.com/DevCenter/BytecodeAssembler#toc
   
   Changes since version 0.5:
   
   * Fix incorrect stack size calculation for ``MAKE_CLOSURE`` on Python 2.5+
   
 Changes since version 0.3:  Changes since version 0.3:
   
 * New node types:  * New node types:
Line 353 
Line 357 
     >>> c = Code()      >>> c = Code()
     >>> c.co_cellvars = ('a','b')      >>> c.co_cellvars = ('a','b')
   
       >>> import sys
     >>> c.LOAD_CLOSURE('a')      >>> c.LOAD_CLOSURE('a')
     >>> c.LOAD_CLOSURE('b')      >>> c.LOAD_CLOSURE('b')
       >>> if sys.version>='2.5':
       ...     c.BUILD_TUPLE(2) # In Python 2.5+, free vars must be in a tuple
     >>> c.LOAD_CONST(None)  # in real code, this'd be a Python code constant      >>> c.LOAD_CONST(None)  # in real code, this'd be a Python code constant
     >>> c.MAKE_CLOSURE(0,2) # no defaults, 2 free vars in the new function      >>> c.MAKE_CLOSURE(0,2) # no defaults, 2 free vars in the new function
   
       >>> c.stack_size         # This will be 1, no matter what Python version
       1
   
 The ``COMPARE_OP`` method takes an argument which can be a valid comparison  The ``COMPARE_OP`` method takes an argument which can be a valid comparison
 integer constant, or a string containing a Python operator, e.g.::  integer constant, or a string containing a Python operator, e.g.::
   
Line 2752 
Line 2762 
       ...        ...
     AssertionError: Stack underflow      AssertionError: Stack underflow
   
     >>> c.LOAD_CONST(1)      >>> c = Code()
     >>> c.LOAD_CONST(2) # simulate being a function      >>> c.LOAD_CONST(1) # closure
     >>> c.MAKE_CLOSURE(1, 0)      >>> if sys.version>='2.5': c.BUILD_TUPLE(1)
       >>> c.LOAD_CONST(2) # default
       >>> c.LOAD_CONST(3) # simulate being a function
       >>> c.MAKE_CLOSURE(1, 1)
     >>> c.stack_size      >>> c.stack_size
     1      1
   
     >>> c = Code()      >>> c = Code()
     >>> c.LOAD_CONST(1)      >>> c.LOAD_CONST(1)
     >>> c.LOAD_CONST(2)      >>> c.LOAD_CONST(2)
       >>> if sys.version>='2.5': c.BUILD_TUPLE(2)
     >>> c.LOAD_CONST(3) # simulate being a function      >>> c.LOAD_CONST(3) # simulate being a function
     >>> c.MAKE_CLOSURE(1, 1)      >>> c.MAKE_CLOSURE(0, 2)
     >>> c.stack_size      >>> c.stack_size
     1      1
   
   
   
 Labels and backpatching forward references::  Labels and backpatching forward references::
   
     >>> c = Code()      >>> c = Code()


Generate output suitable for use with a patch program
Legend:
Removed from v.2573  
changed lines
  Added in v.2575

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help