comparison python/ppci/ir.py @ 364:c49459768aaa

Work on globals
author Windel Bouwman
date Wed, 19 Mar 2014 20:24:03 +0100
parents 396e5cefba13
children 9667d78ba79e
comparison
equal deleted inserted replaced
363:396e5cefba13 364:c49459768aaa
6 def label_name(dut): 6 def label_name(dut):
7 """ Function that returns the assembly code label name """ 7 """ Function that returns the assembly code label name """
8 if isinstance(dut, Block): 8 if isinstance(dut, Block):
9 f = dut.function 9 f = dut.function
10 return label_name(f) + '_' + dut.name 10 return label_name(f) + '_' + dut.name
11 elif isinstance(dut, Function): 11 elif isinstance(dut, Function) or isinstance(dut, GlobalVariable):
12 return label_name(dut.module) + '_' + dut.name 12 return label_name(dut.module) + '_' + dut.name
13 elif isinstance(dut, Module): 13 elif isinstance(dut, Module):
14 return dut.name 14 return dut.name
15 else: 15 else:
16 raise NotImplementedError(str(dut)) 16 raise NotImplementedError(str(dut))
30 """ Add a function to this module """ 30 """ Add a function to this module """
31 self.functions.append(f) 31 self.functions.append(f)
32 f.module = self 32 f.module = self
33 33
34 def add_variable(self, v): 34 def add_variable(self, v):
35 assert type(v) is GlobalVariable
35 self.variables.append(v) 36 self.variables.append(v)
37 v.module = self
36 38
37 def get_variables(self): 39 def get_variables(self):
38 return self.variables 40 return self.variables
39 41
40 Variables = property(get_variables) 42 Variables = property(get_variables)