Mercurial > lcfOS
comparison python/c3/builder.py @ 226:240111e0456f
Work on named types
author | Windel Bouwman |
---|---|
date | Fri, 12 Jul 2013 17:25:31 +0200 |
parents | 1c7364bd74c7 |
children | 6ed3d3a82a63 |
comparison
equal
deleted
inserted
replaced
225:1c7364bd74c7 | 226:240111e0456f |
---|---|
6 """ | 6 """ |
7 Generates IR-code from c3 source. | 7 Generates IR-code from c3 source. |
8 Reports errors to the diagnostics system | 8 Reports errors to the diagnostics system |
9 """ | 9 """ |
10 def __init__(self, diag): | 10 def __init__(self, diag): |
11 self.diag = diag | 11 self.diag = diag |
12 self.parser = Parser(diag) | 12 self.parser = Parser(diag) |
13 self.tc = TypeChecker(diag) | 13 self.tc = TypeChecker(diag) |
14 self.al = Analyzer(diag) | 14 self.al = Analyzer(diag) |
15 self.cg = CodeGenerator() | 15 self.cg = CodeGenerator() |
16 def build(self, src): | 16 def build(self, src): |
17 """ Create IR-code from sources """ | 17 """ Create IR-code from sources """ |
18 pkg = self.parser.parseSource(src) | 18 pkg = self.parser.parseSource(src) |
19 if not pkg: | 19 if not pkg: |
20 return | 20 return |
21 self.pkg = pkg | 21 self.pkg = pkg |
22 # TODO: merge the two below? | 22 # TODO: merge the two below? |
23 #AstPrinter().printAst(pkg) | 23 #AstPrinter().printAst(pkg) |
24 if not self.al.analyzePackage(pkg): | 24 if not self.al.analyzePackage(pkg): |
25 return | 25 return |
26 if not self.tc.checkPackage(pkg): | 26 if not self.tc.checkPackage(pkg): |
27 return | 27 return |
28 | 28 |
29 # Only return ircode when everything is OK | 29 # Only return ircode when everything is OK |
30 ircode = self.cg.gencode(pkg) | 30 return self.cg.gencode(pkg) |
31 return ircode | |
32 | 31 |