Lines Matching refs:blocks
1167 def __init__(self, blocks): argument
1168 self.blocks = blocks
1171 return len(self.blocks)
1174 return self.blocks[n]
1177 return repr(self.blocks)
1180 result = '\n'.join([str(b) for b in self.blocks])
1186 for i, b in enumerate(self.blocks):
1193 self.blocks = optimize_if01(self.blocks)
1197 for b in self.blocks:
1209 for b in self.blocks:
1217 for b in self.blocks:
1253 for block in self.blocks:
1360 self.blocks = blocksToKeep
1365 for b in self.blocks:
1404 self.blocks.insert(2, Block(replacement.tokens, directive='include'))
1493 blocks = []
1509 blocks.append(Block(buf))
1543 blocks.append(Block(ret, directive=directive,
1548 blocks.append(Block(ret[2:], directive=directive,
1553 blocks.append(Block(buf))
1558 blocks.append(Block(ret[2:], directive=directive,
1563 blocks.append(Block(buf))
1571 blocks.append(Block(buf))
1582 blocks.append(Block(buf))
1588 return BlockList(blocks)
1601 blocks = BlockParser().parse(CppStringTokenizer('\n'.join(lines)))
1602 return map(lambda a: str(a), blocks)
1632 def find_matching_endif(blocks, i): argument
1634 n = len(blocks)
1637 if blocks[i].isDirective():
1638 dir_ = blocks[i].directive
1651 def optimize_if01(blocks): argument
1654 n = len(blocks)
1658 while j < n and not blocks[j].isIf():
1661 logging.debug("appending lines %d to %d", blocks[i].lineno,
1662 blocks[j-1].lineno)
1663 result += blocks[i:j]
1666 expr = blocks[j].expr
1669 result.append(blocks[j])
1675 start_dir = blocks[j].directive
1676 j = find_matching_endif(blocks, j + 1)
1680 dir_ = blocks[j].directive
1683 blocks[i].lineno, blocks[j].lineno)
1686 result += blocks[j:j+1]
1691 "to %d)", blocks[i].lineno, blocks[j-1].lineno)
1693 blocks[j].directive = "elif"
1695 blocks[j].directive = "if"
1696 blocks[j].expr = CppExpr(CppStringTokenizer("1").tokens)
1702 blocks[j].directive = "elif"
1704 blocks[j].directive = "if"
1709 k = find_matching_endif(blocks, j + 1)
1713 result += blocks[j+1:k]
1716 start_dir = blocks[j].directive
1717 dir_ = blocks[k].directive
1720 blocks[j].lineno, blocks[k].lineno)
1723 blocks[j].tokens = CppStringTokenizer("1").tokens
1724 result += blocks[j:j+1]
1725 result += optimize_if01(blocks[j+1:k])
1728 result += blocks[k:k+1]
1733 blocks[j].lineno, blocks[k].lineno)
1736 blocks[j].tokens = CppStringTokenizer("1").tokens
1737 result += blocks[j:j+1]
1738 result += optimize_if01(blocks[j+1:k])
1740 blocks[k].directive = "elif"
1742 blocks[k].directive = "if"
1743 blocks[k].expr = CppExpr(CppStringTokenizer("0").tokens)
1748 blocks[j].lineno, blocks[k].lineno)
1749 result += optimize_if01(blocks[j+1:k])
1750 blocks[k].expr = CppExpr(CppStringTokenizer("0").tokens)
1757 blocks = BlockParser().parse(CppStringTokenizer(text))
1758 blocks.replaceTokens(kernel_token_replacements)
1759 blocks.optimizeAll(macros)
1760 blocks.write(out)
1958 blocks = BlockParser().parse(CppStringTokenizer(text))
1959 blocks.removeVarsAndFuncs(keep)
1960 blocks.replaceTokens(kernel_token_replacements)
1961 blocks.optimizeAll(None)
1962 blocks.write(out)