Use currently supported opcodes when instantiating syntax highlighter
MODIFY
src/editor/codeeditor.cpp
src/editor/codeeditor.cpp
@@ -144,14 +144,20 @@ void CodeEditor::resizeEvent(QResizeEvent* e) {
m_lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
}
-void CodeEditor::setSourceType(SourceType type) {
+void CodeEditor::setSourceType(SourceType type, const std::set<QString>& supportedOpcodes) {
m_sourceType = type;
// Creates AsmHighlighter object and connects it to the current document
switch (m_sourceType) {
- case SourceType::Assembly:
- m_highlighter = std::make_unique<RVSyntaxHighlighter>(document(), m_errors);
+ case SourceType::Assembly: {
+ auto* isa = ProcessorHandler::get()->currentISA();
+ if (isa->isaID() == ISA::RV32IM) {
+ m_highlighter = std::make_unique<RVSyntaxHighlighter>(document(), m_errors, supportedOpcodes);
+ } else {
+ Q_ASSERT(false && "Unknown ISA selected");
+ }
break;
+ }
case SourceType::C:
m_highlighter = std::make_unique<CSyntaxHighlighter>(document(), m_errors);
break;

MODIFY
src/editor/codeeditor.h
src/editor/codeeditor.h
@@ -25,7 +25,7 @@ class CodeEditor : public QPlainTextEdit {
public:
CodeEditor(QWidget* parent = nullptr);
- void setSourceType(SourceType type);
+ void setSourceType(SourceType type, const std::set<QString>& supportedOpcodes);
void lineNumberAreaPaintEvent(QPaintEvent* event);
int lineNumberAreaWidth();
void setupChangedTimer();

MODIFY
src/edittab.cpp
src/edittab.cpp
@@ -187,7 +187,7 @@ void EditTab::sourceTypeChanged() {
}
// Notify the source type change to the code editor
- m_ui->codeEditor->setSourceType(m_currentSourceType);
+ m_ui->codeEditor->setSourceType(m_currentSourceType, m_assembler->getOpcodes());
}
void EditTab::emitProgramChanged() {

Use currently supported opcodes when instantiating syntax highlighter