comparison python/ppci/c3/builder.py @ 334:6f4753202b9a

Added more recipes
author Windel Bouwman
date Thu, 13 Feb 2014 22:02:08 +0100
parents 2e7f55319858
children 5477e499b039
comparison
equal deleted inserted replaced
333:dcae6574c974 334:6f4753202b9a
29 self.topScope = topScope 29 self.topScope = topScope
30 self.packages = packages 30 self.packages = packages
31 31
32 """ Scope is attached to the correct modules. """ 32 """ Scope is attached to the correct modules. """
33 def addScope(self, pkg): 33 def addScope(self, pkg):
34 self.logger.info('Adding scoping to package {}'.format(pkg.name)) 34 self.logger.debug('Adding scoping to package {}'.format(pkg.name))
35 self.pkg = pkg 35 self.pkg = pkg
36 # Prepare top level scope and set scope to all objects: 36 # Prepare top level scope and set scope to all objects:
37 self.scopeStack = [self.topScope] 37 self.scopeStack = [self.topScope]
38 modScope = Scope(self.CurrentScope) 38 modScope = Scope(self.CurrentScope)
39 self.scopeStack.append(modScope) 39 self.scopeStack.append(modScope)
40 self.visit(pkg, self.enterScope, self.quitScope) 40 self.visit(pkg, self.enterScope, self.quitScope)
41 assert len(self.scopeStack) == 2 41 assert len(self.scopeStack) == 2
42 42
43 self.logger.info('Resolving imports for package {}'.format(pkg.name)) 43 self.logger.debug('Resolving imports for package {}'.format(pkg.name))
44 # Handle imports: 44 # Handle imports:
45 for i in pkg.imports: 45 for i in pkg.imports:
46 if i not in self.packages: 46 if i not in self.packages:
47 self.error('Cannot import {}'.format(i)) 47 self.error('Cannot import {}'.format(i))
48 continue 48 continue
93 self.cg = CodeGenerator(diag) 93 self.cg = CodeGenerator(diag)
94 self.topScope = createTopScope(target) # Scope with built in types 94 self.topScope = createTopScope(target) # Scope with built in types
95 95
96 def build(self, srcs, imps=[]): 96 def build(self, srcs, imps=[]):
97 """ Create IR-code from sources """ 97 """ Create IR-code from sources """
98 self.logger.info('Building {} source files'.format(len(srcs))) 98 self.logger.debug('Building {} source files'.format(len(srcs)))
99 iter(srcs) # Check if srcs are iterable 99 iter(srcs) # Check if srcs are iterable
100 iter(imps) 100 iter(imps)
101 self.ok = True 101 self.ok = True
102 self.pkgs = {} 102 self.pkgs = {}
103 103