def box_for_var(self, elem): try: return self._cache[self.type_system, elem] except KeyError: pass if elem.startswith('i'): # integer box = BoxInt() _box_counter_more_than(elem[1:]) elif elem.startswith('f'): box = BoxFloat() _box_counter_more_than(elem[1:]) elif elem.startswith('p'): # pointer ts = getattr(self.cpu, 'ts', llhelper) box = ts.BoxRef() _box_counter_more_than(elem[1:]) else: for prefix, boxclass in self.boxkinds.iteritems(): if elem.startswith(prefix): box = boxclass() break else: raise ParseError("Unknown variable type: %s" % elem) self._cache[self.type_system, elem] = box box._str = elem return box