- enhancement: Add "Languages" page group in the options dialog.

- enhancement: Add "ASM Generation" page in the options dialog.
  - change: Move "Custom C/C++ keywords" from group "Editor" to "Lanauges" in the options dialog.
  - change: Rename "Folder" page to "Folder / Reset default settings" in the options dialog.
  - enhancement: Generate asm with/without SEH directives.
  - enhancement: Generate asm using intel style/att style.
  - enhancement: make description for jump/cmov/setb instructions more explicit. (used for signed or unsigned)
This commit is contained in:
Roy Qu 2023-02-28 10:49:50 +08:00
parent 6f9a8f552f
commit 78739e388a
16 changed files with 2514 additions and 2256 deletions

View File

@ -14,6 +14,13 @@ Red Panda C++ Version 2.15
- enhancement: Show descriptions mouse tip for assebmly instructions. (editor / cpu info dialog)
- fix: When completing resigter names, an extra '%' is wrongly added.
- enhancement: Syntax check for assembly files.
- enhancement: Add "Languages" page group in the options dialog.
- enhancement: Add "ASM Generation" page in the options dialog.
- change: Move "Custom C/C++ keywords" from group "Editor" to "Lanauges" in the options dialog.
- change: Rename "Folder" page to "Folder / Reset default settings" in the options dialog.
- enhancement: Generate asm with/without SEH directives.
- enhancement: Generate asm using intel style/att style.
- enhancement: make description for jump/cmov/setb instructions more explicit. (used for signed or unsigned)
Red Panda C++ Version 2.14

View File

@ -127,6 +127,7 @@ SOURCES += \
settingsdialog/environmentshortcutwidget.cpp \
settingsdialog/executorproblemsetwidget.cpp \
settingsdialog/formattergeneralwidget.cpp \
settingsdialog/languageasmgenerationwidget.cpp \
settingsdialog/projectcompileparamaterswidget.cpp \
settingsdialog/projectcompilerwidget.cpp \
settingsdialog/projectdirectorieswidget.cpp \
@ -262,6 +263,7 @@ HEADERS += \
settingsdialog/environmentshortcutwidget.h \
settingsdialog/executorproblemsetwidget.h \
settingsdialog/formattergeneralwidget.h \
settingsdialog/languageasmgenerationwidget.h \
settingsdialog/projectcompileparamaterswidget.h \
settingsdialog/projectcompilerwidget.h \
settingsdialog/projectdirectorieswidget.h \
@ -369,6 +371,7 @@ FORMS += \
settingsdialog/environmentshortcutwidget.ui \
settingsdialog/executorproblemsetwidget.ui \
settingsdialog/formattergeneralwidget.ui \
settingsdialog/languageasmgenerationwidget.ui \
settingsdialog/projectcompileparamaterswidget.ui \
settingsdialog/projectcompilerwidget.ui \
settingsdialog/projectdirectorieswidget.ui \

View File

@ -49,7 +49,8 @@ bool FileCompiler::prepareForCompile()
break;
case CppCompileType::GenerateAssemblyOnly:
stage = Settings::CompilerSet::CompilationStage::CompilationProperOnly;
compilerSet()->setCompileOption(CC_CMD_OPT_DEBUG_INFO,COMPILER_OPTION_OFF);
if (pSettings->languages().noDebugDirectivesWhenGenerateASM())
compilerSet()->setCompileOption(CC_CMD_OPT_DEBUG_INFO,COMPILER_OPTION_OFF);
break;
default:
stage = oldStage;
@ -65,7 +66,7 @@ bool FileCompiler::prepareForCompile()
log(tr("- Compiler Set Name: %1").arg(compilerSet()->name()));
log("");
FileType fileType = getFileType(mFilename);
mArguments= QString(" \"%1\"").arg(mFilename);
mArguments = QString(" \"%1\"").arg(mFilename);
if (!mOnlyCheckSyntax) {
switch(compilerSet()->compilationStage()) {
case Settings::CompilerSet::CompilationStage::PreprocessingOnly:
@ -86,6 +87,14 @@ bool FileCompiler::prepareForCompile()
mArguments+=QString(" -o \"%1\"").arg(mOutputFile);
#if defined(ARCH_X86_64) || defined(ARCH_X86)
if (mCompileType == CppCompileType::GenerateAssemblyOnly) {
if (pSettings->languages().noSEHDirectivesWhenGenerateASM())
mArguments+=" -fno-asynchronous-unwind-tables";
if (pSettings->languages().x86DialectOfASMGenerated()==Settings::Languages::X86ASMDialect::Intel)
mArguments+=" -masm=intel";
}
#endif
//remove the old file if it exists
QFile outputFile(mOutputFile);
if (outputFile.exists()) {

View File

@ -3345,8 +3345,9 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
keywords = QSynedit::ASMSyntaxer::ATTDirectives;
else if (word.startsWith("%"))
keywords = QSynedit::ASMSyntaxer::ATTRegisters;
else
else {
keywords = QSynedit::ASMSyntaxer::InstructionNames;
}
} else {
int pos = word.lastIndexOf(".");
if (pos>=0) {

View File

@ -49,7 +49,7 @@ Settings::Settings(const QString &filename):
mCodeFormatter(this),
mUI(this),
mVCS(this),
mExtTools(this)
mLanguages(this)
{
//load();
}
@ -113,7 +113,7 @@ void Settings::load()
mUI.load();
mDirs.load();
mVCS.load();
mExtTools.load();
mLanguages.load();
}
Settings::Dirs &Settings::dirs()
@ -146,9 +146,9 @@ QString Settings::filename() const
return mFilename;
}
Settings::ExtTools &Settings::extTools()
Settings::Languages &Settings::languages()
{
return mExtTools;
return mLanguages;
}
Settings::CodeCompletion& Settings::codeCompletion()
@ -5831,27 +5831,51 @@ void Settings::VCS::detectGitInPath()
}
}
const QString &Settings::ExtTools::xMakePath() const
Settings::Languages::Languages(Settings *settings):
_Base(settings,SETTING_LANGUAGES)
{
return mXMakePath;
}
void Settings::ExtTools::setXMakePath(const QString &newXMakePath)
Settings::Languages::X86ASMDialect Settings::Languages::x86DialectOfASMGenerated() const
{
mXMakePath = newXMakePath;
return mX86DialectOfASMGenerated;
}
void Settings::ExtTools::doSave()
void Settings::Languages::setX86DialectOfASMGenerated(X86ASMDialect newX86DialectOfASMGenerated)
{
saveValue("xmake_path", mXMakePath);
mX86DialectOfASMGenerated = newX86DialectOfASMGenerated;
}
void Settings::ExtTools::doLoad()
void Settings::Languages::doSave()
{
mXMakePath=stringValue("xmake_path","");
saveValue("no_debug_directives_when_generate_asm",mNoDebugDirectivesWhenGenerateASM);
saveValue("no_seh_directives_when_generate_asm",mNoSEHDirectivesWhenGenerateASM);
saveValue("x86_dialect_of_asm_generated",(int)mX86DialectOfASMGenerated);
}
Settings::ExtTools::ExtTools(Settings *settings):_Base(settings, SETTING_EXTTOOLS)
void Settings::Languages::doLoad()
{
mNoDebugDirectivesWhenGenerateASM = boolValue("no_debug_directives_when_generate_asm",true);
mNoSEHDirectivesWhenGenerateASM = boolValue("no_seh_directives_when_generate_asm",false);
mX86DialectOfASMGenerated = (X86ASMDialect)intValue("x86_dialect_of_asm_generated",(int)X86ASMDialect::ATT);
}
bool Settings::Languages::noSEHDirectivesWhenGenerateASM() const
{
return mNoSEHDirectivesWhenGenerateASM;
}
void Settings::Languages::setNoSEHDirectivesWhenGenerateASM(bool newNoSEHDirectivesWhenGenerateASM)
{
mNoSEHDirectivesWhenGenerateASM = newNoSEHDirectivesWhenGenerateASM;
}
bool Settings::Languages::noDebugDirectivesWhenGenerateASM() const
{
return mNoDebugDirectivesWhenGenerateASM;
}
void Settings::Languages::setNoDebugDirectivesWhenGenerateASM(bool newNoDebugDirectivesWhenGenerateASM)
{
mNoDebugDirectivesWhenGenerateASM = newNoDebugDirectivesWhenGenerateASM;
}

View File

@ -37,10 +37,10 @@
#define SETTING_ENVIRONMENT "Environment"
#define SETTING_EXECUTOR "Executor"
#define SETTING_DEBUGGER "Debugger"
#define SETTING_EXTTOOLS "ExtTools"
#define SETTING_HISTORY "History"
#define SETTING_UI "UI"
#define SETTING_VCS "VCS"
#define SETTING_LANGUAGES "Languages"
#define SETTING_CODE_COMPLETION "CodeCompletion"
#define SETTING_CODE_FORMATTER "CodeFormatter"
#define SETTING_COMPILTER_SETS "CompilerSets"
@ -975,6 +975,31 @@ public:
void doLoad() override;
};
class Languages: public _Base {
public:
enum class X86ASMDialect {
ATT,
Intel
};
explicit Languages(Settings *settings);
bool noDebugDirectivesWhenGenerateASM() const;
void setNoDebugDirectivesWhenGenerateASM(bool newNoDebugDirectivesWhenGenerateASM);
bool noSEHDirectivesWhenGenerateASM() const;
void setNoSEHDirectivesWhenGenerateASM(bool newNoSEHDirectivesWhenGenerateASM);
X86ASMDialect x86DialectOfASMGenerated() const;
void setX86DialectOfASMGenerated(X86ASMDialect newX86DialectOfASMGenerated);
private:
bool mNoDebugDirectivesWhenGenerateASM;
bool mNoSEHDirectivesWhenGenerateASM;
X86ASMDialect mX86DialectOfASMGenerated;
protected:
void doSave() override;
void doLoad() override;
};
class UI: public _Base {
public:
explicit UI(Settings *settings);
@ -1271,22 +1296,6 @@ public:
void doLoad() override;
};
class ExtTools: public _Base {
public:
explicit ExtTools(Settings* settings);
const QString &xMakePath() const;
void setXMakePath(const QString &newXMakePath);
private:
QString mXMakePath;
// _Base interface
protected:
void doSave() override;
void doLoad() override;
};
class CompilerSet {
public:
enum class CompilationStage {
@ -1531,10 +1540,9 @@ public:
CodeFormatter &codeFormatter();
UI &ui();
VCS &vcs();
ExtTools &extTools();
Languages &languages();
QString filename() const;
private:
QString mFilename;
QSettings mSettings;
@ -1548,8 +1556,7 @@ private:
CodeFormatter mCodeFormatter;
UI mUI;
VCS mVCS;
ExtTools mExtTools;
Languages mLanguages;
};

View File

@ -0,0 +1,55 @@
#include "languageasmgenerationwidget.h"
#include "ui_languageasmgenerationwidget.h"
#include "../settings.h"
LanguageAsmGenerationWidget::LanguageAsmGenerationWidget(const QString &name, const QString &group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::LanguageAsmGenerationWidget)
{
ui->setupUi(this);
#ifndef Q_OS_WIN
ui->chkNoSEHDirectives->setVisible(false);
#endif
#if !defined(ARCH_X86_64) && !defined(ARCH_X86)
ui->grpX86Syntax->setVisible(false);
#endif
}
LanguageAsmGenerationWidget::~LanguageAsmGenerationWidget()
{
delete ui;
}
void LanguageAsmGenerationWidget::doLoad()
{
ui->chkNoDebugDirectives->setChecked(pSettings->languages().noDebugDirectivesWhenGenerateASM());
#ifdef Q_OS_WIN
ui->chkNoSEHDirectives->setChecked(pSettings->languages().noSEHDirectivesWhenGenerateASM());
#endif
#if defined(ARCH_X86_64) || defined(ARCH_X86)
switch(pSettings->languages().x86DialectOfASMGenerated()) {
case Settings::Languages::X86ASMDialect::ATT:
ui->rbATT->setChecked(true);
break;
case Settings::Languages::X86ASMDialect::Intel:
ui->rbIntel->setChecked(true);
break;
}
#endif
}
void LanguageAsmGenerationWidget::doSave()
{
pSettings->languages().setNoDebugDirectivesWhenGenerateASM(ui->chkNoDebugDirectives->isChecked());
#ifdef Q_OS_WIN
pSettings->languages().setNoSEHDirectivesWhenGenerateASM(ui->chkNoSEHDirectives->isChecked());
#endif
#if defined(ARCH_X86_64) || defined(ARCH_X86)
if (ui->rbATT->isChecked()) {
pSettings->languages().setX86DialectOfASMGenerated(Settings::Languages::X86ASMDialect::ATT);
} else {
pSettings->languages().setX86DialectOfASMGenerated(Settings::Languages::X86ASMDialect::Intel);
}
#endif
pSettings->languages().save();
}

View File

@ -0,0 +1,27 @@
#ifndef LANGUAGEASMGENERATIONWIDGET_H
#define LANGUAGEASMGENERATIONWIDGET_H
#include "settingswidget.h"
namespace Ui {
class LanguageAsmGenerationWidget;
}
class LanguageAsmGenerationWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit LanguageAsmGenerationWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~LanguageAsmGenerationWidget();
private:
Ui::LanguageAsmGenerationWidget *ui;
// SettingsWidget interface
protected:
void doLoad() override;
void doSave() override;
};
#endif // LANGUAGEASMGENERATIONWIDGET_H

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LanguageAsmGenerationWidget</class>
<widget class="QWidget" name="LanguageAsmGenerationWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="chkNoDebugDirectives">
<property name="text">
<string>Don't generate debug directives</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkNoSEHDirectives">
<property name="text">
<string>Don't generate SEH directives </string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="grpX86Syntax">
<property name="title">
<string>Instruction syntax:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="rbATT">
<property name="text">
<string>AT&amp;&amp;T</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbIntel">
<property name="text">
<string>Intel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -17,7 +17,6 @@
#ifndef PROJECTCOMPILEPARAMATERSWIDGET_H
#define PROJECTCOMPILEPARAMATERSWIDGET_H
#include <QWidget>
#include "settingswidget.h"
namespace Ui {

View File

@ -39,6 +39,7 @@
#include "executorproblemsetwidget.h"
#include "debuggeneralwidget.h"
#include "formattergeneralwidget.h"
#include "languageasmgenerationwidget.h"
#include "projectgeneralwidget.h"
#include "projectfileswidget.h"
#include "projectcompilerwidget.h"
@ -149,13 +150,6 @@ PSettingsDialog SettingsDialog::optionDialog()
widget = new EnvironmentShortcutWidget(tr("Shortcuts"),tr("Environment"));
dialog->addWidget(widget);
widget = new EnvironmentFoldersWidget(tr("Folders"),tr("Environment"));
connect((EnvironmentFoldersWidget*)widget,
&EnvironmentFoldersWidget::shouldQuitApp,
dialog.get(),
&SettingsDialog::closeAndQuit);
dialog->addWidget(widget);
#ifdef Q_OS_LINUX
widget = new EnvironmentProgramsWidget(tr("Terminal"),tr("Environment"));
dialog->addWidget(widget);
@ -164,6 +158,13 @@ PSettingsDialog SettingsDialog::optionDialog()
widget = new EnvironmentPerformanceWidget(tr("Performance"),tr("Environment"));
dialog->addWidget(widget);
widget = new EnvironmentFoldersWidget(tr("Folders / Restore Default Settings"),tr("Environment"));
connect((EnvironmentFoldersWidget*)widget,
&EnvironmentFoldersWidget::shouldQuitApp,
dialog.get(),
&SettingsDialog::closeAndQuit);
dialog->addWidget(widget);
widget = new CompilerSetOptionWidget(tr("Compiler Set"),tr("Compiler"));
dialog->addWidget(widget);
@ -200,10 +201,13 @@ PSettingsDialog SettingsDialog::optionDialog()
widget = new EditorAutoSaveWidget(tr("Auto save"),tr("Editor"));
dialog->addWidget(widget);
widget = new EditorCustomCTypeKeywordsWidget(tr("Custom C/C++ Keywords"),tr("Editor"));
widget = new EditorMiscWidget(tr("Misc"),tr("Editor"));
dialog->addWidget(widget);
widget = new EditorMiscWidget(tr("Misc"),tr("Editor"));
widget = new EditorCustomCTypeKeywordsWidget(tr("Custom C/C++ Keywords"),tr("Languages"));
dialog->addWidget(widget);
widget = new LanguageAsmGenerationWidget(tr("ASM Generation"),tr("Languages"));
dialog->addWidget(widget);
widget = new ExecutorGeneralWidget(tr("General"),tr("Program Runner"));

View File

@ -3051,6 +3051,33 @@
<translation>Descrição</translation>
</message>
</context>
<context>
<name>LanguageAsmGenerationWidget</name>
<message>
<source>Form</source>
<translation type="unfinished">Configuração</translation>
</message>
<message>
<source>Don&apos;t generate debug directives</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Don&apos;t generate SEH directives </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>AT&amp;&amp;T</source>
<translation type="unfinished">AT&amp;&amp;T</translation>
</message>
<message>
<source>Intel</source>
<translation type="unfinished">Intel</translation>
</message>
<message>
<source>Instruction syntax:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MacroInfoModel</name>
<message>
@ -7161,7 +7188,7 @@
</message>
<message>
<source>Folders</source>
<translation>Pastas</translation>
<translation type="vanished">Pastas</translation>
</message>
<message>
<source>Terminal</source>
@ -7303,6 +7330,18 @@
<source>Custom C/C++ Keywords</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Folders / Restore Default Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Languages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ASM Generation</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsWidget</name>

File diff suppressed because it is too large Load Diff

View File

@ -2888,6 +2888,33 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LanguageAsmGenerationWidget</name>
<message>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Don&apos;t generate debug directives</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Don&apos;t generate SEH directives </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>AT&amp;&amp;T</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Intel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Instruction syntax:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MacroInfoModel</name>
<message>
@ -6640,10 +6667,6 @@
<source>Shortcuts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Folders</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Terminal</source>
<translation type="unfinished"></translation>
@ -6780,6 +6803,18 @@
<source>Custom C/C++ Keywords</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Folders / Restore Default Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Languages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ASM Generation</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsWidget</name>

View File

@ -90,8 +90,8 @@ const QSet<QString> ASMSyntaxer::Directives {
"section","global","extern","segment",
"db","dw","dd","dq","dt","do","dy","dz",
"resb","resw","resd","resq","rest","reso","resy","resz",
"equ","times","byte""word","dword","qword","tword",
"xmmword","ymmword","zmmword","fword","tbyte","oword"
"equ","times","byte","word","dword","qword","tword",
"xmmword","ymmword","zmmword","fword","tbyte","oword","ptr",
#endif
};
@ -101,6 +101,13 @@ const QSet<QString> ASMSyntaxer::ATTDirectives {
".intel_style",".att_syntax",
".intel_mnemonic",".att_mnemonic",
".tfloat",".hfloat",".bfloat16",
#endif
#ifdef Q_OS_WIN
".seh_proc",".seh_endprologue",".seh_handler",
".seh_eh",".seh_32",".seh_no32",".seh_endproc",
".seh_setframe",".seh_stackalloc",".seh_pushreg",
".seh_savereg",".seh_savemm",".seh_savexmm",
".seh_pushframe",".seh_scope",
#endif
".abort",".align",".altmacro",".ascii",
".asciz",".attach",".balign",".bss",
@ -121,9 +128,6 @@ const QSet<QString> ASMSyntaxer::ATTDirectives {
".previous",".print",".protected",".psize",
".purgem",".pushsection",".quad",".reloc",
".rept", ".sbttl", ".scl", ".section",
".seh_pushreg",".seh_setframe",
".seh_stackalloc",".seh_endprologue",
".seh_proc",".seh_endproc",
".set", ".short", ".single", ".size",
".skip", ".sleb128", ".space_size", ".stabd",
".stabn", ".stabs", ".string", ".string8", ".string16",

File diff suppressed because it is too large Load Diff