Example #1
0
 def targetcode(self):
     '''
     生成汇编代码
     :return:
     '''
     self.textBrowser.clear()
     t = Translate()
     s = self.textEdit.toPlainText()
     fg, info = t.entry(s)
     if fg:
         # t.optimize_code()
         ass_codes = gen_assemcodes(t.codes)
         info = ''.join(ass_codes)
         self.textBrowser.setText(info)
         self.textBrowser.selectAll()
         self.textBrowser.copy()
         # 提示已经复制到剪切板
         icon = QtGui.QIcon()
         icon.addPixmap(QtGui.QPixmap("icons/logo.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
         qw = QtWidgets.QWidget()
         qw.setWindowIcon(icon)
         QMessageBox.warning(qw, 'Tips', '汇编代码已复制!')
     else:
         pickle.dump((False, None), open('data/midway_sheet.pkl', 'wb'))
         info = '----- error !\n' + '\n'.join(info)
         self.textBrowser.setText(info)
     self.save()
Example #2
0
 def midcode(self):
     '''
     生成中间代码
     :return:
     '''
     self.textBrowser.clear()
     t = Translate()
     s = self.textEdit.toPlainText()
     fg, info = t.entry(s)
     if fg:
         t.optimize_code()
         pickle.dump((True, t.codes), open('data/midway_sheet.pkl', 'wb'))
     else:
         pickle.dump((False, None), open('data/midway_sheet.pkl', 'wb'))
         info = '----- error !\n' + '\n'.join(info)
         self.textBrowser.setText(info)
     self.save()