[Subversion] / BytecodeAssembler / peak / util / assembler.txt  

Diff of /BytecodeAssembler/peak/util/assembler.txt

Parent Directory | Revision Log

version 2112, Thu Dec 22 05:26:05 2005 UTC version 2139, Tue May 23 05:28:31 2006 UTC
Line 1 
Line 1 
 ======================================================  =======================================================
 Generating Python Bytecode with ``dispatch.assembler``  Generating Python Bytecode with ``peak.util.assembler``
 ======================================================  =======================================================
   
   Simple usage::
   
       >>> from peak.util.assembler import Code
       >>> c = Code()
       >>> c.LOAD_CONST(42)
       >>> c.RETURN_VALUE()
   
       >>> eval(c.code())
       42
   
     >>> from dispatch.assembler import *  
     >>> from dis import dis      >>> from dis import dis
       >>> dis(c.code())
         0           0 LOAD_CONST               0 (42)
                     3 RETURN_VALUE
   
 Line number tracking:  Line number tracking::
   
     >>> def simple_code(flno, slno, consts=1, ):      >>> def simple_code(flno, slno, consts=1, ):
     ...     c = Code()      ...     c = Code()
Line 42 
Line 54 
     572         360 RETURN_VALUE      572         360 RETURN_VALUE
   
   
 Stack size tracking:  Stack size tracking::
   
     >>> c = Code()      >>> c = Code()
     >>> c.LOAD_CONST(1)      >>> c.LOAD_CONST(1)
Line 63 
Line 75 
     >>> c.stack_size      >>> c.stack_size
     3      3
   
 Stack underflow detection/recovery, and global/local variable names:  Stack underflow detection/recovery, and global/local variable names::
   
     >>> c = Code()      >>> c = Code()
     >>> c.LOAD_GLOBAL('foo')      >>> c.LOAD_GLOBAL('foo')
Line 94 
Line 106 
   
   
   
 Function calls and raise:  Function calls and raise::
   
     >>> c = Code()      >>> c = Code()
     >>> c.LOAD_GLOBAL('locals')      >>> c.LOAD_GLOBAL('locals')
Line 168 
Line 180 
                   3 LOAD_CONST               0 (1)                    3 LOAD_CONST               0 (1)
                   6 RAISE_VARARGS            1                    6 RAISE_VARARGS            1
   
 Sequence building, unpacking, dup'ing:  Sequence building, unpacking, dup'ing::
   
     >>> c = Code()      >>> c = Code()
     >>> c.LOAD_CONST(1)      >>> c.LOAD_CONST(1)
Line 229 
Line 241 
     XXX Need tests for MAKE_CLOSURE/MAKE_FUNCTION      XXX Need tests for MAKE_CLOSURE/MAKE_FUNCTION
   
   
 Labels and backpatching forward references:  Labels and backpatching forward references::
   
     >>> c = Code()      >>> c = Code()
     >>> ref = c.JUMP_ABSOLUTE()      >>> ref = c.JUMP_ABSOLUTE()


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

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help