'Compute the max stack depth.
Approach is to compute the stack effect of each basic block.
Then find the path through the code with the largest total
effect.'

def computeStackDepth(self):

    depth = {}
    exit = None
    for b in self.getBlocks():
        depth[b] = findDepth(b.getInstructions())
    seen = {}
    def max_depth(b, d):
        if (b in seen):
            return d
        seen[b] = 1
        d = (d + depth[b])
        children = b.get_children()
        if children:
            return max([max_depth(c, d) for c in children])
        elif (not (b.label == 'exit')):
            return max_depth(self.exit, d)
        else:
            return d
    self.stacksize = max_depth(self.entry, 0)
