Mercurial > lcfOS
comparison python/ir/builder.py @ 174:3eb06f5fb987
Added memory alloc for locals
author | Windel Bouwman |
---|---|
date | Fri, 19 Apr 2013 19:22:52 +0200 |
parents | 5a7d37d615ee |
children | 46d62dadd61b |
comparison
equal
deleted
inserted
replaced
173:c1d2b6b9f9a7 | 174:3eb06f5fb987 |
---|---|
7 a = 0 | 7 a = 0 |
8 while True: | 8 while True: |
9 yield a | 9 yield a |
10 a = a + 1 | 10 a = a + 1 |
11 self.nums = NumGen() | 11 self.nums = NumGen() |
12 def gen(self): | 12 def gen(self, prefix=None): |
13 return '{0}{1}'.format(self.prefix, self.nums.__next__()) | 13 if not prefix: |
14 prefix = self.prefix | |
15 return '{0}{1}'.format(prefix, self.nums.__next__()) | |
14 | 16 |
15 class ValueGenerator(NameGenerator): | 17 class ValueGenerator(NameGenerator): |
16 def __init__(self): | 18 def __init__(self): |
17 super().__init__('t') | 19 super().__init__('t') |
18 def gen(self): | 20 def gen(self, prefix=None): |
19 v = Value(super().gen()) | 21 v = Value(super().gen(prefix)) |
20 return v | 22 return v |
21 | 23 |
22 class BBGenerator(NameGenerator): | 24 class BBGenerator(NameGenerator): |
23 def __init__(self): | 25 def __init__(self): |
24 super().__init__('lab') | 26 super().__init__('lab') |