Lines Matching refs:blocks

1164     def __init__(self, blocks):  argument
1165 self.blocks = blocks
1168 return len(self.blocks)
1171 return self.blocks[n]
1174 return repr(self.blocks)
1177 result = '\n'.join([str(b) for b in self.blocks])
1183 for i, b in enumerate(self.blocks):
1190 self.blocks = optimize_if01(self.blocks)
1194 for b in self.blocks:
1200 for b in self.blocks:
1252 for b in self.blocks:
1260 for b in self.blocks:
1296 for block in self.blocks:
1403 self.blocks = blocksToKeep
1408 for b in self.blocks:
1447 self.blocks.insert(2, Block(replacement.tokens, directive='include'))
1536 blocks = []
1552 blocks.append(Block(buf))
1586 blocks.append(Block(ret, directive=directive,
1591 blocks.append(Block(ret[2:], directive=directive,
1596 blocks.append(Block(buf))
1601 blocks.append(Block(ret[2:], directive=directive,
1606 blocks.append(Block(buf))
1614 blocks.append(Block(buf))
1625 blocks.append(Block(buf))
1631 return BlockList(blocks)
1644 blocks = BlockParser().parse(CppStringTokenizer('\n'.join(lines)))
1645 return map(lambda a: str(a), blocks)
1675 def find_matching_endif(blocks, i): argument
1677 n = len(blocks)
1680 if blocks[i].isDirective():
1681 dir_ = blocks[i].directive
1694 def optimize_if01(blocks): argument
1697 n = len(blocks)
1701 while j < n and not blocks[j].isIf():
1704 logging.debug("appending lines %d to %d", blocks[i].lineno,
1705 blocks[j-1].lineno)
1706 result += blocks[i:j]
1709 expr = blocks[j].expr
1712 result.append(blocks[j])
1718 start_dir = blocks[j].directive
1719 j = find_matching_endif(blocks, j + 1)
1723 dir_ = blocks[j].directive
1726 blocks[i].lineno, blocks[j].lineno)
1729 result += blocks[j:j+1]
1734 "to %d)", blocks[i].lineno, blocks[j-1].lineno)
1736 blocks[j].directive = "elif"
1738 blocks[j].directive = "if"
1739 blocks[j].expr = CppExpr(CppStringTokenizer("1").tokens)
1745 blocks[j].directive = "elif"
1747 blocks[j].directive = "if"
1752 k = find_matching_endif(blocks, j + 1)
1756 result += blocks[j+1:k]
1759 start_dir = blocks[j].directive
1760 dir_ = blocks[k].directive
1763 blocks[j].lineno, blocks[k].lineno)
1766 blocks[j].tokens = CppStringTokenizer("1").tokens
1767 result += blocks[j:j+1]
1768 result += optimize_if01(blocks[j+1:k])
1771 result += blocks[k:k+1]
1776 blocks[j].lineno, blocks[k].lineno)
1779 blocks[j].tokens = CppStringTokenizer("1").tokens
1780 result += blocks[j:j+1]
1781 result += optimize_if01(blocks[j+1:k])
1783 blocks[k].directive = "elif"
1785 blocks[k].directive = "if"
1786 blocks[k].expr = CppExpr(CppStringTokenizer("0").tokens)
1791 blocks[j].lineno, blocks[k].lineno)
1792 result += optimize_if01(blocks[j+1:k])
1793 blocks[k].expr = CppExpr(CppStringTokenizer("0").tokens)
1800 blocks = BlockParser().parse(CppStringTokenizer(text))
1801 blocks.optimizeAll(macros)
1802 blocks.write(out)
1996 blocks = BlockParser().parse(CppStringTokenizer(text))
1997 blocks.removeStructs(structs)
1998 blocks.write(out)
2140 blocks = BlockParser().parse(CppStringTokenizer(text))
2142 blocks.removeStructs(kernel_structs_to_remove)
2143 blocks.removeVarsAndFuncs(keep)
2144 blocks.replaceTokens(kernel_token_replacements)
2145 blocks.optimizeAll(None)
2147 blocks.write(out)