Mercurial > lcfOS
comparison python/ide.py @ 165:598d3888a11c
Added front class and fided AST view
author | Windel Bouwman |
---|---|
date | Fri, 22 Mar 2013 15:12:38 +0100 |
parents | e023d3ce1d63 |
children | 0b5b2ee6b435 |
comparison
equal
deleted
inserted
replaced
164:e023d3ce1d63 | 165:598d3888a11c |
---|---|
12 from astviewer import AstViewer | 12 from astviewer import AstViewer |
13 #from codeeditor import CodeEdit | 13 #from codeeditor import CodeEdit |
14 from codeedit import CodeEdit | 14 from codeedit import CodeEdit |
15 stutil = __import__('st-util') | 15 stutil = __import__('st-util') |
16 import testc3 | 16 import testc3 |
17 import c3 | |
17 | 18 |
18 lcfospng = base64.decodestring(b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A\n/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEhMKBk7B678AAAA/SURBVFjD\n7dbBCQAgDATBi9h/y7EFA4Kf2QLCwH1S6XQu6sqoujublc8BAAAAAAAAAAB8B+zXT6YJAAAAAKYd\nWSgFQNUyijIAAAAASUVORK5CYII=\n') | 19 lcfospng = base64.decodestring(b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A\n/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEhMKBk7B678AAAA/SURBVFjD\n7dbBCQAgDATBi9h/y7EFA4Kf2QLCwH1S6XQu6sqoujublc8BAAAAAAAAAAB8B+zXT6YJAAAAAKYd\nWSgFQNUyijIAAAAASUVORK5CYII=\n') |
19 | 20 |
20 class BuildOutput(QTextEdit): | 21 class BuildOutput(QTextEdit): |
21 """ Build output component """ | 22 """ Build output component """ |
116 | 117 |
117 class Ide(QMainWindow): | 118 class Ide(QMainWindow): |
118 def __init__(self, parent=None): | 119 def __init__(self, parent=None): |
119 super(Ide, self).__init__(parent) | 120 super(Ide, self).__init__(parent) |
120 self.setWindowTitle('LCFOS IDE') | 121 self.setWindowTitle('LCFOS IDE') |
121 self.compiler = None # TODO | |
122 icon = QPixmap() | 122 icon = QPixmap() |
123 icon.loadFromData(lcfospng) | 123 icon.loadFromData(lcfospng) |
124 self.setWindowIcon(QIcon(icon)) | 124 self.setWindowIcon(QIcon(icon)) |
125 | 125 |
126 # Create menus: | 126 # Create menus: |
199 | 199 |
200 ce = self.newFile() | 200 ce = self.newFile() |
201 ce.Source = testc3.testsrc | 201 ce.Source = testc3.testsrc |
202 | 202 |
203 self.diag = ppci.DiagnosticsManager() | 203 self.diag = ppci.DiagnosticsManager() |
204 self.c3front = c3.Builder(self.diag) | |
204 | 205 |
205 # File handling: | 206 # File handling: |
206 def newProject(self): | 207 def newProject(self): |
207 filename = QFileDialog.getSaveFileName(self, \ | 208 filename = QFileDialog.getSaveFileName(self, \ |
208 "Select new projectfile", "", "lcfos Project files (*.lcp2)") | 209 "Select new projectfile", "", "lcfos Project files (*.lcp2)") |
317 # Error handling: | 318 # Error handling: |
318 def nodeSelected(self, node): | 319 def nodeSelected(self, node): |
319 ce = self.activeMdiChild() | 320 ce = self.activeMdiChild() |
320 if not ce: | 321 if not ce: |
321 return | 322 return |
322 if node.location: | 323 if node.loc: |
323 row, col = node.location | 324 row, col = node.loc.row, node.loc.col |
324 ce.highlightErrorLocation( row, col ) | 325 ce.setRowCol( row, col ) |
325 else: | 326 else: |
326 ce.clearErrors() | 327 ce.clearErrors() |
327 | 328 |
328 def errorSelected(self, err): | 329 def errorSelected(self, err): |
329 ce = self.activeMdiChild() | 330 ce = self.activeMdiChild() |
338 ce = self.activeMdiChild() | 339 ce = self.activeMdiChild() |
339 print('BUILD file') | 340 print('BUILD file') |
340 if ce: | 341 if ce: |
341 source = ce.Source | 342 source = ce.Source |
342 self.buildOutput.clear() | 343 self.buildOutput.clear() |
343 self.buildOutput.append(str(self.compiler)) | 344 self.buildOutput.append('Starting build') |
344 ast = testc3.c3compile(source, self.diag) | 345 ir = self.c3front.build(source) |
345 #ast = self.compiler.compilesource(source) | 346 ast = self.c3front.pkg |
346 print('setting ast', ast) | 347 print('setting ast', ast) |
347 self.astViewer.setAst(ast) | 348 self.astViewer.setAst(ast) |
348 self.buildOutput.append("Done!") | 349 self.buildOutput.append("Done!") |
349 def buildProject(self): | 350 def buildProject(self): |
350 """ Build project """ | 351 """ Build project """ |
351 print('BUILD project') | 352 print('BUILD project') |
352 self.buildOutput.clear() | 353 self.buildOutput.clear() |
353 self.diag.diags.clear() | 354 self.diag.diags.clear() |
354 self.buildOutput.append(str(self.compiler)) | |
355 self.buildFile() | 355 self.buildFile() |
356 #mods = self.compiler.compileProject(self.project) | |
357 | 356 |
358 self.builderrors.setErrorList(self.diag.diags) | 357 self.builderrors.setErrorList(self.diag.diags) |
359 #self.astViewer.setAst(mods[0]) | 358 #self.astViewer.setAst(mods[0]) |
360 for err in self.diag.diags: | 359 for err in self.diag.diags: |
361 self.buildOutput.append(str(err)) | 360 self.buildOutput.append(str(err)) |