<s> """<STR_LIT>""" <EOL> import dis <EOL> import types <EOL> import sys <EOL> from pycompiler import misc <EOL> from pycompiler . consts import CO_OPTIMIZED , CO_NEWLOCALS , CO_VARARGS , CO_VARKEYWORDS <EOL> class FlowGraph : <EOL> def __init__ ( self ) : <EOL> self . current = self . entry = Block ( ) <EOL> self . exit = Block ( "<STR_LIT>" ) <EOL> self . blocks = misc . Set ( ) <EOL> self . blocks . add ( self . entry ) <EOL> self . blocks . add ( self . exit ) <EOL> def startBlock ( self , block ) : <EOL> if self . _debug : <EOL> if self . current : <EOL> print ( "<STR_LIT:end>" , repr ( self . current ) ) <EOL> print ( "<STR_LIT>" , self . current . next ) <EOL> print ( "<STR_LIT:U+0020>" , self . current . get_children ( ) ) <EOL> print ( repr ( block ) ) <EOL> self . current = block <EOL> def nextBlock ( self , block = None ) : <EOL> if block is None : <EOL> block = self . newBlock ( ) <EOL> self . current . addNext ( block ) <EOL> self . startBlock ( block ) <EOL> def newBlock ( self ) : <EOL> b = Block ( ) <EOL> self . blocks . add ( b ) <EOL> return b <EOL> def startExitBlock ( self ) : <EOL> self . startBlock ( self . exit ) <EOL> _debug = <NUM_LIT:0> <EOL> def _enable_debug ( self ) : <EOL> self . _debug = <NUM_LIT:1> <EOL> def _disable_debug ( self ) : <EOL> self . _debug = <NUM_LIT:0> <EOL> def emit ( self , * inst ) : <EOL> if self . _debug : <EOL> print ( "<STR_LIT:\t>" , inst ) <EOL> if inst [ <NUM_LIT:0> ] in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> self . current . addOutEdge ( self . exit ) <EOL> if len ( inst ) == <NUM_LIT:2> and isinstance ( inst [ <NUM_LIT:1> ] , Block ) : <EOL> self . current . addOutEdge ( inst [ <NUM_LIT:1> ] ) <EOL> self . current . emit ( inst ) <EOL> def getBlocksInOrder ( self ) : <EOL> """<STR_LIT>""" <EOL> for b in self . blocks . elements ( ) : <EOL> if b is self . exit : <EOL> continue <EOL> if not b . next : <EOL> b . addNext ( self . exit ) <EOL> order = dfs_postorder ( self . entry , { } ) <EOL> order . reverse ( ) <EOL> self . fixupOrder ( order , self . exit ) <EOL> if not self . exit in order : <EOL> order . append ( self . exit ) <EOL> return order <EOL> def fixupOrder ( self , blocks , default_next ) : <EOL> """<STR_LIT>""" <EOL> self . fixupOrderHonorNext ( blocks , default_next ) <EOL> self . fixupOrderForward ( blocks , default_next ) <EOL> def fixupOrderHonorNext ( self , blocks , default_next ) : <EOL> """<STR_LIT>""" <EOL> index = { } <EOL> for i in range ( len ( blocks ) ) : <EOL> index [ blocks [ i ] ] = i <EOL> for i in range ( <NUM_LIT:0> , len ( blocks ) - <NUM_LIT:1> ) : <EOL> b = blocks [ i ] <EOL> n = blocks [ i + <NUM_LIT:1> ] <EOL> if not b . next or b . next [ <NUM_LIT:0> ] == default_next or b . next [ <NUM_LIT:0> ] == n : <EOL> continue <EOL> cur = b <EOL> chain = [ ] <EOL> elt = cur <EOL> while elt . next and elt . next [ <NUM_LIT:0> ] != default_next : <EOL> chain . append ( elt . next [ <NUM_LIT:0> ] ) <EOL> elt = elt . next [ <NUM_LIT:0> ] <EOL> l = [ ] <EOL> for b in chain : <EOL> assert index [ b ] > i <EOL> l . append ( ( index [ b ] , b ) ) <EOL> l . sort ( ) <EOL> l . reverse ( ) <EOL> for j , b in l : <EOL> del blocks [ index [ b ] ] <EOL> blocks = blocks [ : i ] + [ cur ] + [ chain ] + blocks [ i + <NUM_LIT:1> : ] <EOL> for i in range ( len ( blocks ) ) : <EOL> index [ blocks [ i ] ] = i <EOL> def fixupOrderForward ( self , blocks , default_next ) : <EOL> """<STR_LIT>""" <EOL> index = { } <EOL> chains = [ ] <EOL> cur = [ ] <EOL> for b in blocks : <EOL> index [ b ] = len ( chains ) <EOL> cur . append ( b ) <EOL> if b . next and b . next [ <NUM_LIT:0> ] == default_next : <EOL> chains . append ( cur ) <EOL> cur = [ ] <EOL> chains . append ( cur ) <EOL> while <NUM_LIT:1> : <EOL> constraints = [ ] <EOL> for i in range ( len ( chains ) ) : <EOL> l = chains [ i ] <EOL> for b in l : <EOL> for c in b . get_children ( ) : <EOL> if index [ c ] < i : <EOL> forward_p = <NUM_LIT:0> <EOL> for inst in b . insts : <EOL> if inst [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> if inst [ <NUM_LIT:1> ] == c : <EOL> forward_p = <NUM_LIT:1> <EOL> if not forward_p : <EOL> continue <EOL> constraints . append ( ( index [ c ] , i ) ) <EOL> if not constraints : <EOL> break <EOL> goes_before , a_chain = constraints [ <NUM_LIT:0> ] <EOL> assert a_chain > goes_before <EOL> c = chains [ a_chain ] <EOL> chains . remove ( c ) <EOL> chains . insert ( goes_before , c ) <EOL> while len ( blocks ) > <NUM_LIT:0> : <EOL> del blocks [ <NUM_LIT:0> ] <EOL> for c in chains : <EOL> for b in c : <EOL> blocks . append ( b ) <EOL> def getBlocks ( self ) : <EOL> return self . blocks . elements ( ) <EOL> def getRoot ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . entry <EOL> def getContainedGraphs ( self ) : <EOL> l = [ ] <EOL> for b in self . getBlocks ( ) : <EOL> l . extend ( b . getContainedGraphs ( ) ) <EOL> return l <EOL> def dfs_postorder ( b , seen ) : <EOL> """<STR_LIT>""" <EOL> order = [ ] <EOL> seen [ b ] = b <EOL> for c in b . get_children ( ) : <EOL> if c in seen : <EOL> continue <EOL> order = order + dfs_postorder ( c , seen ) <EOL> order . append ( b ) <EOL> return order <EOL> class Block : <EOL> _count = <NUM_LIT:0> <EOL> def __init__ ( self , label = '<STR_LIT>' ) : <EOL> self . insts = [ ] <EOL> self . inEdges = misc . Set ( ) <EOL> self . outEdges = misc . Set ( ) <EOL> self . label = label <EOL> self . bid = Block . _count <EOL> self . next = [ ] <EOL> Block . _count = Block . _count + <NUM_LIT:1> <EOL> def __repr__ ( self ) : <EOL> if self . label : <EOL> return "<STR_LIT>" % ( self . label , self . bid ) <EOL> else : <EOL> return "<STR_LIT>" % ( self . bid ) <EOL> def __str__ ( self ) : <EOL> insts = map ( str , self . insts ) <EOL> return "<STR_LIT>" % ( self . label , self . bid , <EOL> '<STR_LIT:\n>' . join ( insts ) ) <EOL> def emit ( self , inst ) : <EOL> op = inst [ <NUM_LIT:0> ] <EOL> if op [ : <NUM_LIT:4> ] == '<STR_LIT>' : <EOL> self . outEdges . add ( inst [ <NUM_LIT:1> ] ) <EOL> self . insts . append ( inst ) <EOL> def getInstructions ( self ) : <EOL> return self . insts <EOL> def addInEdge ( self , block ) : <EOL> self . inEdges . add ( block ) <EOL> def addOutEdge ( self , block ) : <EOL> self . outEdges . add ( block ) <EOL> def addNext ( self , block ) : <EOL> self . next . append ( block ) <EOL> assert len ( self . next ) == <NUM_LIT:1> , map ( str , self . next ) <EOL> _uncond_transfer = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def pruneNext ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> op , arg = self . insts [ - <NUM_LIT:1> ] <EOL> except ( IndexError , ValueError ) : <EOL> return <EOL> if op in self . _uncond_transfer : <EOL> self . next = [ ] <EOL> def get_children ( self ) : <EOL> if self . next and self . next [ <NUM_LIT:0> ] in self . outEdges : <EOL> self . outEdges . remove ( self . next [ <NUM_LIT:0> ] ) <EOL> return self . outEdges . elements ( ) + self . next <EOL> def getContainedGraphs ( self ) : <EOL> """<STR_LIT>""" <EOL> contained = [ ] <EOL> for inst in self . insts : <EOL> if len ( inst ) == <NUM_LIT:1> : <EOL> continue <EOL> op = inst [ <NUM_LIT:1> ] <EOL> if hasattr ( op , '<STR_LIT>' ) : <EOL> contained . append ( op . graph ) <EOL> return contained <EOL> RAW = "<STR_LIT>" <EOL> FLAT = "<STR_LIT>" <EOL> CONV = "<STR_LIT>" <EOL> DONE = "<STR_LIT>" <EOL> class PyFlowGraph ( FlowGraph ) : <EOL> super_init = FlowGraph . __init__ <EOL> def __init__ ( self , name , filename , args = ( ) , optimized = <NUM_LIT:0> , klass = None ) : <EOL> self . super_init ( ) <EOL> self . hasjrel = misc . Set ( ) <EOL> self . hasjabs = misc . Set ( ) <EOL> for i in dis . hasjrel : <EOL> self . hasjrel . add ( dis . opname [ i ] ) <EOL> for i in dis . hasjabs : <EOL> self . hasjabs . add ( dis . opname [ i ] ) <EOL> self . name = name <EOL> self . filename = filename <EOL> self . docstring = None <EOL> self . args = args <EOL> self . argcount = getArgCount ( args ) <EOL> self . klass = klass <EOL> if optimized : <EOL> self . flags = CO_OPTIMIZED | CO_NEWLOCALS <EOL> else : <EOL> self . flags = <NUM_LIT:0> <EOL> self . consts = [ ] <EOL> self . names = [ ] <EOL> self . freevars = [ ] <EOL> self . cellvars = [ ] <EOL> self . closure = [ ] <EOL> self . varnames = list ( args ) or [ ] <EOL> for i in range ( len ( self . varnames ) ) : <EOL> var = self . varnames [ i ] <EOL> if isinstance ( var , TupleArg ) : <EOL> self . varnames [ i ] = var . getName ( ) <EOL> self . stage = RAW <EOL> for name , obj in dir ( self ) : <EOL> if name [ : <NUM_LIT:9> ] == "<STR_LIT>" : <EOL> opname = name [ <NUM_LIT:9> : ] <EOL> self . _converters [ opname ] = obj <EOL> for num in range ( len ( dis . opname ) ) : <EOL> opnum [ dis . opname [ num ] ] = num <EOL> def setDocstring ( self , doc ) : <EOL> self . docstring = doc <EOL> def setFlag ( self , flag ) : <EOL> self . flags = self . flags | flag <EOL> if flag == CO_VARARGS : <EOL> self . argcount = self . argcount - <NUM_LIT:1> <EOL> def checkFlag ( self , flag ) : <EOL> if self . flags & flag : <EOL> return <NUM_LIT:1> <EOL> def setFreeVars ( self , names ) : <EOL> self . freevars = list ( names ) <EOL> def setCellVars ( self , names ) : <EOL> self . cellvars = names <EOL> def getCode ( self ) : <EOL> """<STR_LIT>""" <EOL> assert self . stage == RAW <EOL> self . computeStackDepth ( ) <EOL> self . flattenGraph ( ) <EOL> assert self . stage == FLAT <EOL> self . convertArgs ( ) <EOL> assert self . stage == CONV <EOL> self . makeByteCode ( ) <EOL> assert self . stage == DONE <EOL> return self . newCodeObject ( ) <EOL> def dump ( self , io = None ) : <EOL> if io : <EOL> save = sys . stdout <EOL> sys . stdout = io <EOL> pc = <NUM_LIT:0> <EOL> for t in self . insts : <EOL> opname = t [ <NUM_LIT:0> ] <EOL> if opname == "<STR_LIT>" : <EOL> print ( ) <EOL> if len ( t ) == <NUM_LIT:1> : <EOL> print ( "<STR_LIT:\t>" , "<STR_LIT>" % pc , opname ) <EOL> pc = pc + <NUM_LIT:1> <EOL> else : <EOL> print ( "<STR_LIT:\t>" , "<STR_LIT>" % pc , opname , t [ <NUM_LIT:1> ] ) <EOL> pc = pc + <NUM_LIT:3> <EOL> if io : <EOL> sys . stdout = save <EOL> def computeStackDepth ( self ) : <EOL> """<STR_LIT>""" <EOL> depth = { } <EOL> exit = None <EOL> for b in self . getBlocks ( ) : <EOL> depth [ b ] = findDepth ( b . getInstructions ( ) ) <EOL> seen = { } <EOL> def max_depth ( b , d ) : <EOL> if b in seen : <EOL> return d <EOL> seen [ b ] = <NUM_LIT:1> <EOL> d = d + depth [ b ] <EOL> children = b . get_children ( ) <EOL> if children : <EOL> return max ( [ max_depth ( c , d ) for c in children ] ) <EOL> else : <EOL> if not b . label == "<STR_LIT>" : <EOL> return max_depth ( self . exit , d ) <EOL> else : <EOL> return d <EOL> self . stacksize = max_depth ( self . entry , <NUM_LIT:0> ) <EOL> def flattenGraph ( self ) : <EOL> """<STR_LIT>""" <EOL> assert self . stage == RAW <EOL> self . insts = insts = [ ] <EOL> pc = <NUM_LIT:0> <EOL> begin = { } <EOL> end = { } <EOL> for b in self . getBlocksInOrder ( ) : <EOL> begin [ b ] = pc <EOL> for inst in b . getInstructions ( ) : <EOL> insts . append ( inst ) <EOL> if len ( inst ) == <NUM_LIT:1> : <EOL> pc = pc + <NUM_LIT:1> <EOL> elif inst [ <NUM_LIT:0> ] != "<STR_LIT>" : <EOL> pc = pc + <NUM_LIT:3> <EOL> end [ b ] = pc <EOL> pc = <NUM_LIT:0> <EOL> for i in range ( len ( insts ) ) : <EOL> inst = insts [ i ] <EOL> if len ( inst ) == <NUM_LIT:1> : <EOL> pc = pc + <NUM_LIT:1> <EOL> elif inst [ <NUM_LIT:0> ] != "<STR_LIT>" : <EOL> pc = pc + <NUM_LIT:3> <EOL> opname = inst [ <NUM_LIT:0> ] <EOL> if self . hasjrel . has_elt ( opname ) : <EOL> oparg = inst [ <NUM_LIT:1> ] <EOL> offset = begin [ oparg ] - pc <EOL> insts [ i ] = opname , offset <EOL> elif self . hasjabs . has_elt ( opname ) : <EOL> insts [ i ] = opname , begin [ inst [ <NUM_LIT:1> ] ] <EOL> self . stage = FLAT <EOL> def convertArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> assert self . stage == FLAT <EOL> self . consts . insert ( <NUM_LIT:0> , self . docstring ) <EOL> self . sort_cellvars ( ) <EOL> for i in range ( len ( self . insts ) ) : <EOL> t = self . insts [ i ] <EOL> if len ( t ) == <NUM_LIT:2> : <EOL> opname , oparg = t <EOL> conv = self . _converters . get ( opname , None ) <EOL> if conv : <EOL> self . insts [ i ] = opname , conv ( self , oparg ) <EOL> self . stage = CONV <EOL> def sort_cellvars ( self ) : <EOL> """<STR_LIT>""" <EOL> cells = { } <EOL> for name in self . cellvars : <EOL> cells [ name ] = <NUM_LIT:1> <EOL> self . cellvars = [ name for name in self . varnames <EOL> if name in cells ] <EOL> for name in self . cellvars : <EOL> del cells [ name ] <EOL> self . cellvars = self . cellvars + cells . keys ( ) <EOL> self . closure = self . cellvars + self . freevars <EOL> def _lookupName ( self , name , list ) : <EOL> """<STR_LIT>""" <EOL> t = type ( name ) <EOL> for i in range ( len ( list ) ) : <EOL> if t == type ( list [ i ] ) and list [ i ] == name : <EOL> return i <EOL> end = len ( list ) <EOL> list . append ( name ) <EOL> return end <EOL> _converters = { } <EOL> def _convert_LOAD_CONST ( self , arg ) : <EOL> if hasattr ( arg , '<STR_LIT>' ) : <EOL> arg = arg . getCode ( ) <EOL> return self . _lookupName ( arg , self . consts ) <EOL> def _convert_LOAD_FAST ( self , arg ) : <EOL> self . _lookupName ( arg , self . names ) <EOL> return self . _lookupName ( arg , self . varnames ) <EOL> _convert_STORE_FAST = _convert_LOAD_FAST <EOL> _convert_DELETE_FAST = _convert_LOAD_FAST <EOL> def _convert_LOAD_NAME ( self , arg ) : <EOL> if self . klass is None : <EOL> self . _lookupName ( arg , self . varnames ) <EOL> return self . _lookupName ( arg , self . names ) <EOL> def _convert_NAME ( self , arg ) : <EOL> if self . klass is None : <EOL> self . _lookupName ( arg , self . varnames ) <EOL> return self . _lookupName ( arg , self . names ) <EOL> _convert_STORE_NAME = _convert_NAME <EOL> _convert_DELETE_NAME = _convert_NAME <EOL> _convert_IMPORT_NAME = _convert_NAME <EOL> _convert_IMPORT_FROM = _convert_NAME <EOL> _convert_STORE_ATTR = _convert_NAME <EOL> _convert_LOAD_ATTR = _convert_NAME <EOL> _convert_DELETE_ATTR = _convert_NAME <EOL> _convert_LOAD_GLOBAL = _convert_NAME <EOL> _convert_STORE_GLOBAL = _convert_NAME <EOL> _convert_DELETE_GLOBAL = _convert_NAME <EOL> def _convert_DEREF ( self , arg ) : <EOL> self . _lookupName ( arg , self . names ) <EOL> self . _lookupName ( arg , self . varnames ) <EOL> return self . _lookupName ( arg , self . closure ) <EOL> _convert_LOAD_DEREF = _convert_DEREF <EOL> _convert_STORE_DEREF = _convert_DEREF <EOL> def _convert_LOAD_CLOSURE ( self , arg ) : <EOL> self . _lookupName ( arg , self . varnames ) <EOL> return self . _lookupName ( arg , self . closure ) <EOL> _cmp = list ( dis . cmp_op ) <EOL> def _convert_COMPARE_OP ( self , arg ) : <EOL> return self . _cmp . index ( arg ) <EOL> def makeByteCode ( self ) : <EOL> assert self . stage == CONV <EOL> self . lnotab = lnotab = LineAddrTable ( ) <EOL> for t in self . insts : <EOL> opname = t [ <NUM_LIT:0> ] <EOL> if len ( t ) == <NUM_LIT:1> : <EOL> lnotab . addCode ( self . opnum [ opname ] ) <EOL> else : <EOL> oparg = t [ <NUM_LIT:1> ] <EOL> if opname == "<STR_LIT>" : <EOL> lnotab . nextLine ( oparg ) <EOL> continue <EOL> hi , lo = twobyte ( oparg ) <EOL> try : <EOL> lnotab . addCode ( self . opnum [ opname ] , lo , hi ) <EOL> except ValueError : <EOL> print ( opname , oparg ) <EOL> print ( self . opnum [ opname ] , lo , hi ) <EOL> raise <EOL> self . stage = DONE <EOL> opnum = { } <EOL> def newCodeObject ( self ) : <EOL> assert self . stage == DONE <EOL> if ( self . flags & CO_NEWLOCALS ) == <NUM_LIT:0> : <EOL> nlocals = <NUM_LIT:0> <EOL> else : <EOL> nlocals = len ( self . varnames ) <EOL> argcount = self . argcount <EOL> if self . flags & CO_VARKEYWORDS : <EOL> argcount = argcount - <NUM_LIT:1> <EOL> return types . CodeType ( argcount , nlocals , self . stacksize , self . flags , <EOL> self . lnotab . getCode ( ) , self . getConsts ( ) , <EOL> tuple ( self . names ) , tuple ( self . varnames ) , <EOL> self . filename , self . name , self . lnotab . firstline , <EOL> self . lnotab . getTable ( ) , tuple ( self . freevars ) , <EOL> tuple ( self . cellvars ) ) <EOL> def getConsts ( self ) : <EOL> """<STR_LIT>""" <EOL> l = [ ] <EOL> for elt in self . consts : <EOL> if isinstance ( elt , PyFlowGraph ) : <EOL> elt = elt . getCode ( ) <EOL> l . append ( elt ) <EOL> return tuple ( l ) <EOL> def isJump ( opname ) : <EOL> if opname [ : <NUM_LIT:4> ] == '<STR_LIT>' : <EOL> return <NUM_LIT:1> <EOL> class TupleArg : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , count , names ) : <EOL> self . count = count <EOL> self . names = names <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . count , self . names ) <EOL> def getName ( self ) : <EOL> return "<STR_LIT>" % self . count <EOL> def getArgCount ( args ) : <EOL> argcount = len ( args ) <EOL> if args : <EOL> for arg in args : <EOL> if isinstance ( arg , TupleArg ) : <EOL> numNames = len ( misc . flatten ( arg . names ) ) <EOL> argcount = argcount - numNames <EOL> return argcount <EOL> def twobyte ( val ) : <EOL> """<STR_LIT>""" <EOL> assert isinstance ( val , int ) <EOL> return divmod ( val , <NUM_LIT> ) <EOL> class LineAddrTable : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . code = [ ] <EOL> self . codeOffset = <NUM_LIT:0> <EOL> self . firstline = <NUM_LIT:0> <EOL> self . lastline = <NUM_LIT:0> <EOL> self . lastoff = <NUM_LIT:0> <EOL> self . lnotab = [ ] <EOL> def addCode ( self , * args ) : <EOL> for arg in args : <EOL> self . code . append ( chr ( arg ) ) <EOL> self . codeOffset = self . codeOffset + len ( args ) <EOL> def nextLine ( self , lineno ) : <EOL> if self . firstline == <NUM_LIT:0> : <EOL> self . firstline = lineno <EOL> self . lastline = lineno <EOL> else : <EOL> addr = self . codeOffset - self . lastoff <EOL> line = lineno - self . lastline <EOL> if line >= <NUM_LIT:0> : <EOL> push = self . lnotab . append <EOL> while addr > <NUM_LIT:255> : <EOL> push ( <NUM_LIT:255> ) ; push ( <NUM_LIT:0> ) <EOL> addr -= <NUM_LIT:255> <EOL> while line > <NUM_LIT:255> : <EOL> push ( addr ) ; push ( <NUM_LIT:255> ) <EOL> line -= <NUM_LIT:255> <EOL> addr = <NUM_LIT:0> <EOL> if addr > <NUM_LIT:0> or line > <NUM_LIT:0> : <EOL> push ( addr ) ; push ( line ) <EOL> self . lastline = lineno <EOL> self . lastoff = self . codeOffset <EOL> def getCode ( self ) : <EOL> return '<STR_LIT>' . join ( self . code ) <EOL> def getTable ( self ) : <EOL> return '<STR_LIT>' . join ( map ( chr , self . lnotab ) ) <EOL> class StackDepthTracker : <EOL> def findDepth ( self , insts , debug = <NUM_LIT:0> ) : <EOL> depth = <NUM_LIT:0> <EOL> maxDepth = <NUM_LIT:0> <EOL> for i in insts : <EOL> opname = i [ <NUM_LIT:0> ] <EOL> if debug : <EOL> print ( i ) , <EOL> delta = self . effect . get ( opname , None ) <EOL> if delta is not None : <EOL> depth = depth + delta <EOL> else : <EOL> for pat , pat_delta in self . patterns : <EOL> if opname [ : len ( pat ) ] == pat : <EOL> delta = pat_delta <EOL> depth = depth + delta <EOL> break <EOL> if delta is None : <EOL> meth = getattr ( self , opname , None ) <EOL> if meth is not None : <EOL> depth = depth + meth ( i [ <NUM_LIT:1> ] ) <EOL> if depth > maxDepth : <EOL> maxDepth = depth <EOL> if debug : <EOL> print ( depth , maxDepth ) <EOL> return maxDepth <EOL> effect = { <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:3> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:3> , <EOL> '<STR_LIT>' : - <NUM_LIT:3> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:3> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:2> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> } <EOL> patterns = [ <EOL> ( '<STR_LIT>' , - <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ] <EOL> def UNPACK_SEQUENCE ( self , count ) : <EOL> return count - <NUM_LIT:1> <EOL> def BUILD_TUPLE ( self , count ) : <EOL> return - count + <NUM_LIT:1> <EOL> def BUILD_LIST ( self , count ) : <EOL> return - count + <NUM_LIT:1> <EOL> def CALL_FUNCTION ( self , argc ) : <EOL> hi , lo = divmod ( argc , <NUM_LIT> ) <EOL> return - ( lo + hi * <NUM_LIT:2> ) <EOL> def CALL_FUNCTION_VAR ( self , argc ) : <EOL> return self . CALL_FUNCTION ( argc ) - <NUM_LIT:1> <EOL> def CALL_FUNCTION_KW ( self , argc ) : <EOL> return self . CALL_FUNCTION ( argc ) - <NUM_LIT:1> <EOL> def CALL_FUNCTION_VAR_KW ( self , argc ) : <EOL> return self . CALL_FUNCTION ( argc ) - <NUM_LIT:2> <EOL> def MAKE_FUNCTION ( self , argc ) : <EOL> return - argc <EOL> def MAKE_CLOSURE ( self , argc ) : <EOL> return - argc <EOL> def BUILD_SLICE ( self , argc ) : <EOL> if argc == <NUM_LIT:2> : <EOL> return - <NUM_LIT:1> <EOL> elif argc == <NUM_LIT:3> : <EOL> return - <NUM_LIT:2> <EOL> def DUP_TOPX ( self , argc ) : <EOL> return argc <EOL> findDepth = StackDepthTracker ( ) . findDepth </s>
