def flatten(tup): elts = [] for elt in tup: if isinstance(elt, tuple): elts = elts + flatten(elt) else: elts.append(elt) return elts class Set: def __init__(self): self.elts = {} def __len__(self): return len(self.elts) def __contains__(self, elt): return elt in self.elts def add(self, elt): self.elts[elt] = elt def elements(self): return self.elts.keys() def has_elt(self, elt): return elt in self.elts def remove(self, elt): del self.elts[elt] def copy(self): c = Set() c.elts.update(self.elts) return c class Stack: def __init__(self): self.stack = [] self.pop = self.stack.pop def __len__(self): return len(self.stack) def push(self, elt): self.stack.append(elt) def top(self): return self.stack[-1] def __getitem__(self, index): # needed by visitContinue() return self.stack[index] MANGLE_LEN = 256 # magic constant from compile.c def mangle(name, klass): if not name.startswith('__'): return name if len(name) + 2 >= MANGLE_LEN: return name if name.endswith('__'): return name try: i = 0 while klass[i] == '_': i = i + 1 except IndexError: return name klass = klass[i:] tlen = len(klass) + len(name) if tlen > MANGLE_LEN: klass = klass[:MANGLE_LEN-tlen] return "_%s%s" % (klass, name) def set_filename(filename, tree): """Set the filename attribute to filename on every node in tree""" worklist = [tree] while worklist: node = worklist.pop(0) node.filename = filename worklist.extend(node.getChildNodes())
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__init__.py | File | 1023 B | 0644 |
|
__init__.pyc | File | 1.27 KB | 0644 |
|
__init__.pyo | File | 1.27 KB | 0644 |
|
ast.py | File | 36.63 KB | 0644 |
|
ast.pyc | File | 70.43 KB | 0644 |
|
ast.pyo | File | 70.43 KB | 0644 |
|
consts.py | File | 468 B | 0644 |
|
consts.pyc | File | 737 B | 0644 |
|
consts.pyo | File | 737 B | 0644 |
|
future.py | File | 1.85 KB | 0644 |
|
future.pyc | File | 2.89 KB | 0644 |
|
future.pyo | File | 2.89 KB | 0644 |
|
misc.py | File | 1.75 KB | 0644 |
|
misc.pyc | File | 3.65 KB | 0644 |
|
misc.pyo | File | 3.65 KB | 0644 |
|
pyassem.py | File | 23.7 KB | 0644 |
|
pyassem.pyc | File | 25.34 KB | 0644 |
|
pyassem.pyo | File | 24.78 KB | 0644 |
|
pycodegen.py | File | 46.69 KB | 0644 |
|
pycodegen.pyc | File | 55.19 KB | 0644 |
|
pycodegen.pyo | File | 54.76 KB | 0644 |
|
symbols.py | File | 14.15 KB | 0644 |
|
symbols.pyc | File | 17.26 KB | 0644 |
|
symbols.pyo | File | 17.23 KB | 0644 |
|
syntax.py | File | 1.41 KB | 0644 |
|
syntax.pyc | File | 1.84 KB | 0644 |
|
syntax.pyo | File | 1.84 KB | 0644 |
|
transformer.py | File | 51.87 KB | 0644 |
|
transformer.pyc | File | 46.53 KB | 0644 |
|
transformer.pyo | File | 44.76 KB | 0644 |
|
visitor.py | File | 3.8 KB | 0644 |
|
visitor.pyc | File | 4.09 KB | 0644 |
|
visitor.pyo | File | 4.09 KB | 0644 |
|