comparison python/ppci/c3/codegenerator.py @ 362:c05ab629976a

Added CPUID for arm
author Windel Bouwman
date Sat, 15 Mar 2014 10:56:34 +0100
parents 42343d189e14
children 396e5cefba13
comparison
equal deleted inserted replaced
361:614a7f6d4d4d 362:c05ab629976a
38 self.logger.debug('Generating ir-code for {}'.format(pkg.name), extra={'c3_ast':pkg}) 38 self.logger.debug('Generating ir-code for {}'.format(pkg.name), extra={'c3_ast':pkg})
39 self.varMap = {} # Maps variables to storage locations. 39 self.varMap = {} # Maps variables to storage locations.
40 self.funcMap = {} 40 self.funcMap = {}
41 self.m = ir.Module(pkg.name) 41 self.m = ir.Module(pkg.name)
42 try: 42 try:
43 for s in pkg.innerScope.Functions: 43 # Only generate function if function contains a body:
44 real_functions = list(filter(lambda f: f.body, pkg.innerScope.Functions))
45 #real_functions = list(filter(None, pkg.innerScope.Functions))
46 for s in real_functions:
44 f = self.newFunction(s.name) 47 f = self.newFunction(s.name)
45 self.funcMap[s] = f 48 self.funcMap[s] = f
46 for v in pkg.innerScope.Variables: 49 for v in pkg.innerScope.Variables:
47 self.varMap[v] = self.newTemp() 50 self.varMap[v] = self.newTemp()
48 for s in pkg.innerScope.Functions: 51 for s in real_functions:
49 self.gen_function(s) 52 self.gen_function(s)
50 except SemanticError as e: 53 except SemanticError as e:
51 self.error(e.msg, e.loc) 54 self.error(e.msg, e.loc)
52 if self.pkg.ok: 55 if self.pkg.ok:
53 return self.m 56 return self.m