Mercurial > lcfOS
comparison python/c3/builder.py @ 293:6aa721e7b10b
Try to improve build sequence
author | Windel Bouwman |
---|---|
date | Thu, 28 Nov 2013 20:39:37 +0100 |
parents | bd2593de3ff8 |
children | 917eab04b8b7 |
comparison
equal
deleted
inserted
replaced
292:534b94b40aa8 | 293:6aa721e7b10b |
---|---|
17 self.al = Analyzer(diag) | 17 self.al = Analyzer(diag) |
18 self.cg = CodeGenerator() | 18 self.cg = CodeGenerator() |
19 | 19 |
20 def checkSource(self, srcs, imps=[]): | 20 def checkSource(self, srcs, imps=[]): |
21 """ Performs syntax and type check. """ | 21 """ Performs syntax and type check. """ |
22 packages = {} | 22 iter(srcs) |
23 s_pkgs = [] | 23 iter(imps) |
24 for src in srcs: | 24 def doParse(srcs): |
25 pkg = self.parser.parseSource(src) | 25 for src in srcs: |
26 if not pkg: | |
27 self.ok = False | |
28 continue | |
29 # Store for later use: | |
30 packages[pkg.name] = pkg | |
31 s_pkgs.append(pkg) | |
32 if imps: | |
33 for src in imps: | |
34 pkg = self.parser.parseSource(src) | 26 pkg = self.parser.parseSource(src) |
35 if not pkg: | 27 if pkg: |
28 yield pkg | |
29 else: | |
36 self.ok = False | 30 self.ok = False |
37 continue | 31 s_pkgs = set(doParse(srcs)) |
38 # Store for later use: | 32 print(s_pkgs) |
39 packages[pkg.name] = pkg | 33 i_pkgs = set(doParse(imps)) |
34 all_pkgs = s_pkgs | i_pkgs | |
40 # Fix scopes: | 35 # Fix scopes: |
41 for pkg in packages.values(): | 36 def doF(f, pkgs): |
42 if not AddScope(self.diag).addScope(pkg): | 37 for pkg in pkgs: |
43 self.ok = False | 38 if f(pkg): |
39 yield pkg | |
40 else: | |
41 self.ok = False | |
42 all_pkgs = set(doF(AddScope(self.diag).addScope, all_pkgs)) | |
44 # TODO: fix error handling better | 43 # TODO: fix error handling better |
45 for pkg in packages.values(): | 44 def doA(pkgs): |
46 if not self.al.analyzePackage(pkg, packages): | 45 packages = {pkg.name: pkg for pkg in pkgs} |
47 self.ok = False | 46 for pkg in pkgs: |
48 continue | 47 if self.al.analyzePackage(pkg, packages): |
49 for pkg in packages.values(): | 48 yield pkg |
50 if not self.tc.checkPackage(pkg): | 49 else: |
51 self.ok = False | 50 self.ok = False |
52 continue | 51 all_pkgs = set(doA(all_pkgs)) |
53 for pkg in s_pkgs: | 52 all_pkgs = set(doF(self.tc.checkPackage, all_pkgs)) |
54 yield pkg | 53 return all_pkgs & s_pkgs |
55 | 54 |
56 def build(self, srcs, imps=[]): | 55 def build(self, srcs, imps=[]): |
57 """ Create IR-code from sources """ | 56 """ Create IR-code from sources """ |
58 self.ok = True | 57 self.ok = True |
59 for pkg in self.checkSource(srcs, imps): | 58 for pkg in self.checkSource(srcs, imps): |