Mercurial > lcfOS
comparison python/ide/ide.py @ 295:917eab04b8b7
Added disasm
author | Windel Bouwman |
---|---|
date | Thu, 28 Nov 2013 21:10:32 +0100 |
parents | 534b94b40aa8 |
children | b145f8e6050b |
comparison
equal
deleted
inserted
replaced
294:e89cca5779b0 | 295:917eab04b8b7 |
---|---|
16 sys.path.insert(0, os.path.join(p, 'utils')) | 16 sys.path.insert(0, os.path.join(p, 'utils')) |
17 import ppci | 17 import ppci |
18 from astviewer import AstViewer | 18 from astviewer import AstViewer |
19 from codeedit import CodeEdit | 19 from codeedit import CodeEdit |
20 from logview import LogView as BuildOutput | 20 from logview import LogView as BuildOutput |
21 #from disasm import Disassembly | 21 from disasm import Disassembly |
22 stutil = __import__('st-util') | 22 stutil = __import__('st-util') |
23 import c3 | 23 import c3 |
24 import zcc | 24 import zcc |
25 import outstream | 25 import outstream |
26 from target import armtarget | |
26 | 27 |
27 | 28 |
28 def handle_exception(tp, v, tb): | 29 def handle_exception(tp, v, tb): |
29 logging.critical(str(v)) | 30 logging.critical(str(v)) |
30 tb = traceback.format_tb(tb) | 31 tb = traceback.format_tb(tb) |
77 super(AboutDialog, self).__init__(parent) | 78 super(AboutDialog, self).__init__(parent) |
78 self.setWindowTitle('About') | 79 self.setWindowTitle('About') |
79 l = QVBoxLayout(self) | 80 l = QVBoxLayout(self) |
80 txt = QTextEdit(self) | 81 txt = QTextEdit(self) |
81 txt.setReadOnly(True) | 82 txt.setReadOnly(True) |
82 with open(os.path.join('..', 'readme.rst'), 'r') as f: | 83 with open(os.path.join('..', '..', 'readme.rst'), 'r') as f: |
83 aboutText = f.read() | 84 aboutText = f.read() |
84 txt.append(aboutText) | 85 txt.append(aboutText) |
85 l.addWidget(txt) | 86 l.addWidget(txt) |
86 but = QPushButton('OK') | 87 but = QPushButton('OK') |
87 but.setDefault(True) | 88 but.setDefault(True) |
273 self.showLoc(loc) | 274 self.showLoc(loc) |
274 | 275 |
275 # Build recepy: | 276 # Build recepy: |
276 def parseFile(self): | 277 def parseFile(self): |
277 self.logger.info('Parsing!') | 278 self.logger.info('Parsing!') |
278 ce = self.activeMdiChild() | 279 |
279 if not ce: | 280 def doBuild(self): |
280 return | |
281 self.diag.clear() | |
282 pkg = self.c3front.parse(ce.Source) | |
283 | |
284 # Set errors: | |
285 self.builderrors.setErrorList(self.diag.diags) | |
286 ce.setErrors(self.diag.diags) | |
287 self.astViewer.setAst(pkg) | |
288 if pkg: | |
289 c3.AstPrinter().printAst(pkg) | |
290 self.logger.info('Done!') | |
291 | |
292 def buildFile(self): | |
293 ce = self.activeMdiChild() | |
294 if not ce: | |
295 return | |
296 fn = ce.FileName | |
297 self.diag.clear() | |
298 outs = outstream.TextOutputStream() | |
299 if not zcc.zcc([io.StringIO(ce.Source)], [], outs, self.diag): | |
300 # Set errors: | |
301 self.builderrors.setErrorList(self.diag.diags) | |
302 ce.setErrors(self.diag.diags) | |
303 return | |
304 | |
305 def buildFileAndFlash(self): | |
306 ce = self.activeMdiChild() | 281 ce = self.activeMdiChild() |
307 if not ce: | 282 if not ce: |
308 return | 283 return |
309 fn = ce.FileName | 284 fn = ce.FileName |
310 self.diag.clear() | 285 self.diag.clear() |
311 outs = outstream.TextOutputStream() | 286 outs = outstream.TextOutputStream() |
312 imps = [open(ce.FileName, 'r') for ce in self.allChildren() if ce.FileName and ce.FileName != fn] | 287 imps = [open(ce.FileName, 'r') for ce in self.allChildren() if ce.FileName and ce.FileName != fn] |
313 if not zcc.zcc([open(fn, 'r')], imps, outs, self.diag): | 288 if not zcc.zcc([open(fn, 'r')], imps, armtarget, outs, self.diag): |
314 # Set errors: | 289 # Set errors: |
315 self.builderrors.setErrorList(self.diag.diags) | 290 self.builderrors.setErrorList(self.diag.diags) |
316 ce.setErrors(self.diag.diags) | 291 ce.setErrors(self.diag.diags) |
317 return | 292 return |
318 | 293 return outs |
319 outs.dump() | 294 |
295 def buildFile(self): | |
296 self.doBuild() | |
297 | |
298 def buildFileAndFlash(self): | |
299 outs = self.doBuild() | |
300 if not outs: | |
301 return | |
302 | |
320 code_s = outs.getSection('code') | 303 code_s = outs.getSection('code') |
321 self.disasm.dm.setInstructions(code_s.instructions) | 304 self.disasm.dm.setInstructions(code_s.instructions) |
322 self.debugInfo = code_s.debugInfos() | 305 self.debugInfo = code_s.debugInfos() |
323 if self.ctrlToolbar.device: | 306 if self.ctrlToolbar.device: |
324 logging.info('Flashing stm32f4 discovery') | 307 logging.info('Flashing stm32f4 discovery') |