-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style(*): fix bugs and format the code
please refer to the work log for details
- Loading branch information
1 parent
14cc972
commit 968efcf
Showing
55 changed files
with
4,662 additions
and
4,549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# .clang-format for Qt Creator | ||
# | ||
# This is for clang-format >= 5.0. | ||
# | ||
# The configuration below follows the Qt Creator Coding Rules [1] as closely as | ||
# possible. For documentation of the options, see [2]. | ||
# | ||
# Use ../../tests/manual/clang-format-for-qtc/test.cpp for documenting problems | ||
# or testing changes. | ||
# | ||
# In case you update this configuration please also update the qtcStyle() in src\plugins\clangformat\clangformatutils.cpp | ||
# | ||
# [1] https://doc-snapshots.qt.io/qtcreator-extending/coding-style.html | ||
# [2] https://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||
# | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: DontAlign | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: DontAlign | ||
AlignOperands: AlignAfterOperator | ||
AlignTrailingComments: false | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortLambdasOnASingleLine: None | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterClass: false | ||
AfterControlStatement: Never | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: All | ||
BreakBeforeBraces: Custom | ||
BreakBeforeInheritanceComma: false | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeComma | ||
BreakAfterJavaFieldAnnotations: true | ||
BreakStringLiterals: true | ||
ColumnLimit: 90 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 8 | ||
Cpp11BracedListStyle: false | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- forever # avoids { wrapped to next line | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeCategories: | ||
- Regex: '^<Q.*' | ||
Priority: 200 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IndentCaseLabels: false | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
# Do not add QT_BEGIN_NAMESPACE/QT_END_NAMESPACE as this will indent lines in between. | ||
MacroBlockBegin: "" | ||
MacroBlockEnd: "" | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBlockIndentWidth: 4 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 150 | ||
PenaltyBreakBeforeFirstCallParameter: 300 | ||
PenaltyBreakComment: 500 | ||
PenaltyBreakFirstLessLess: 400 | ||
PenaltyBreakString: 600 | ||
PenaltyExcessCharacter: 50 | ||
PenaltyReturnTypeOnItsOwnLine: 300 | ||
PointerAlignment: Right | ||
ReflowComments: true | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: true | ||
SpaceAfterTemplateKeyword: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: c++17 | ||
TabWidth: 4 | ||
UseTab: Always | ||
IncludeBlocks: Preserve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.cache | ||
.vscode | ||
bin | ||
build | ||
CMakeFiles | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Win32", | ||
"includePath": [ | ||
"${workspaceFolder}/include/stdc_implemented/", | ||
"${workspaceFolder}/src/ast/", | ||
"${workspaceFolder}/src/data_type/", | ||
"${workspaceFolder}/src/vm/", | ||
"${workspaceFolder}/src/ir/", | ||
"${workspaceFolder}/src/compiler/", | ||
"${workspaceFolder}/src/sfn/", | ||
"${workspaceFolder}/src/" | ||
], | ||
"defines": [], | ||
"compilerPath": "D:/TDM-GCC10/bin/g++.exe", | ||
"compilerArgs": [ | ||
"-lm", | ||
"-O2" | ||
], | ||
"cStandard": "c11", | ||
"cppStandard": "c++11", | ||
"intelliSenseMode": "gcc-x64" | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"files.associations": { | ||
"array": "cpp", | ||
"string_view": "cpp", | ||
"initializer_list": "cpp", | ||
"ranges": "cpp", | ||
"utility": "cpp", | ||
"new": "cpp", | ||
"ostream": "cpp", | ||
"iostream": "cpp", | ||
"string": "cpp", | ||
"optional": "cpp", | ||
"istream": "cpp", | ||
"system_error": "cpp", | ||
"functional": "cpp", | ||
"tuple": "cpp", | ||
"type_traits": "cpp", | ||
"*.tcc": "cpp", | ||
"compare": "cpp", | ||
"typeinfo": "cpp", | ||
"memory_resource": "cpp" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# 2024/06/24 工作日志 | ||
|
||
本次主要整理了代码的风格,并且发布了2.4.5。 | ||
|
||
### 修复了部分问题 | ||
|
||
将析构的函数也定义为虚函数,防止了可能的内存泄露。 | ||
|
||
### 格式化代码 | ||
|
||
本建议来自于[一个issue](https://github.com/CLimber-Rong/stamon/issues/1)。 | ||
|
||
感谢其提议,我对代码的风格进行了如下调整: | ||
|
||
1. 将嵌套的namespace整合成一个namespace | ||
|
||
例如: | ||
|
||
```C++ | ||
namespace stamon { | ||
namespace ast { | ||
... | ||
} | ||
} | ||
``` | ||
在整合之后成为: | ||
```C++ | ||
namespace stamon::ast { | ||
... | ||
} | ||
``` | ||
|
||
这么做可以节约代码的缩进空间。 | ||
|
||
2. 在 namespace 的末尾加上注释 | ||
|
||
例如: | ||
|
||
```C++ | ||
namespace stamon { | ||
} // namespace stamon | ||
``` | ||
3. 不在头文件中且在上层namespace中using下层namespace | ||
即不再使用``using namespace stamon:xxx;``,而是在访问成员时使用``xxx::xxxxx``。 | ||
4. 将一些能放入namespace的常量值放入了namespace里 | ||
5. 不要用 #ifndef #define 来防止头文件被重复包含,而是使用#pragma once | ||
与此同时,我对未来的代码编写做出了一些改变: | ||
1. 将宏用 do {} while(0) 包裹,同时在调用宏的时候在末尾加上分号 | ||
2. 将一些能封装为函数的宏封装为函数 | ||
3. 加入了我喜欢的.clang-format,以后的代码可能都使用其进行格式化 | ||
### 接下来要做的事 | ||
1. 编写AST的解释器 | ||
2. 编写词法分析的保存功能 | ||
3. 编写AST的O1优化器 | ||
4. 完善标准库 | ||
5. 支持编译为平面字节码 |
Oops, something went wrong.