Skip to content

Commit fbd6da1

Browse files
committed
Fix formatting style
1 parent 5335e93 commit fbd6da1

10 files changed

Lines changed: 36 additions & 33 deletions

File tree

cli/source/subcommands/docs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace pl::cli::sub {
3535
}
3636

3737
std::string getTypeName(const core::ast::ASTNode *type) {
38-
if(auto typeApp = dynamic_cast<const core::ast::ASTNodeTypeApplication*>(type); typeApp != nullptr) {
38+
if (auto typeApp = dynamic_cast<const core::ast::ASTNodeTypeApplication*>(type); typeApp != nullptr) {
3939
return fmt::format("{}{}", getTypeEndian(typeApp), getTypeName(typeApp->getType().get()));
4040
} else if (auto typeDecl = dynamic_cast<const core::ast::ASTNodeTypeDecl*>(type); typeDecl != nullptr) {
4141
return typeDecl->getName();

lib/include/pl/core/parser_manager.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ namespace pl::core {
3636

3737
void reset() {
3838
this->m_onceIncluded.clear();
39-
for(const auto &[_, types] : this->m_parsedTypes) {
40-
for(const auto &[_, type] : types) {
41-
if(type != nullptr && type->isValid()) {
42-
if(auto builtinType = dynamic_cast<ast::ASTNodeBuiltinType*>(type->getType().get()); builtinType != nullptr) {
43-
if(builtinType->getType() != Token::ValueType::CustomType) {
39+
for (const auto &[_, types] : this->m_parsedTypes) {
40+
for (const auto &[_, type] : types) {
41+
if (type != nullptr && type->isValid()) {
42+
if (auto builtinType = dynamic_cast<ast::ASTNodeBuiltinType*>(type->getType().get()); builtinType != nullptr) {
43+
if (builtinType->getType() != Token::ValueType::CustomType) {
4444
type->setType(nullptr);
4545
}
4646
}
@@ -49,6 +49,7 @@ namespace pl::core {
4949
}
5050
}
5151
}
52+
5253
this->m_parsedTypes.clear();
5354
}
5455

lib/source/pl/core/ast/ast_node_type_application.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace pl::core::ast {
5757
[[maybe_unused]] auto context = evaluator->updateRuntime(this);
5858
auto evaluatedTemplateArguments = this->evaluateTemplateArguments(evaluator);
5959
auto evaluatedType = std::make_unique<ASTNodeTypeApplication>(this->m_type);
60-
if(this->m_type == nullptr) {
60+
if (this->m_type == nullptr) {
6161
auto& templateTypeParameters = evaluator->getTypeTemplateParameters();
62-
if(this->m_templateParameterIndex >= templateTypeParameters.size()) {
62+
if (this->m_templateParameterIndex >= templateTypeParameters.size()) {
6363
err::E0004.throwError("Template parameter index out of bounds.", {}, this->getLocation());
6464
} else {
6565
evaluatedType->m_type = templateTypeParameters[this->m_templateParameterIndex];
@@ -78,14 +78,14 @@ namespace pl::core::ast {
7878
void ASTNodeTypeApplication::createPatterns(Evaluator *evaluator, std::vector<std::shared_ptr<ptrn::Pattern>> &resultPatterns) const {
7979
[[maybe_unused]] auto context = evaluator->updateRuntime(this);
8080
auto actualType = this->m_type;
81-
if(actualType == nullptr) {
81+
if (actualType == nullptr) {
8282
auto& templateTypeParameters = evaluator->getTypeTemplateParameters();
83-
if(this->m_templateParameterIndex >= templateTypeParameters.size()) {
83+
if (this->m_templateParameterIndex >= templateTypeParameters.size()) {
8484
err::E0004.throwError("Template parameter index out of bounds.", {}, this->getLocation());
8585
}
8686
actualType = templateTypeParameters[this->m_templateParameterIndex];
8787

88-
if(actualType.get() == this) {
88+
if (actualType.get() == this) {
8989
err::E0004.throwError("Recursive type definition detected.", {}, this->getLocation());
9090
}
9191
}
@@ -101,9 +101,9 @@ namespace pl::core::ast {
101101
for(auto& pattern : resultPatterns) {
102102
if (!pattern->hasOverriddenEndian())
103103
pattern->setEndian(evaluator->getDefaultEndian());
104-
if(auto typeDecl = dynamic_cast<ASTNodeTypeDecl*>(actualType.get()); typeDecl != nullptr) {
104+
if (auto typeDecl = dynamic_cast<ASTNodeTypeDecl*>(actualType.get()); typeDecl != nullptr) {
105105
if (!typeDecl->getName().empty()) {
106-
if(this->m_templateArguments.empty()) {
106+
if (this->m_templateArguments.empty()) {
107107
pattern->setTypeName(typeDecl->getName());
108108
} else {
109109
pattern->setTypeName(fmt::format("{}<{}>", typeDecl->getName(), templateTypeString));
@@ -114,13 +114,13 @@ namespace pl::core::ast {
114114
}
115115

116116
const ast::ASTNode* ASTNodeTypeApplication::getTypeDefinition(Evaluator *evaluator) const{
117-
if(this->m_type == nullptr) {
117+
if (this->m_type == nullptr) {
118118
auto& templateTypeParameters = evaluator->getTypeTemplateParameters();
119-
if(this->m_templateParameterIndex >= templateTypeParameters.size()) {
119+
if (this->m_templateParameterIndex >= templateTypeParameters.size()) {
120120
err::E0004.throwError("Template parameter index out of bounds.", {}, this->getLocation());
121121
}
122122
auto type = templateTypeParameters[this->m_templateParameterIndex].get();
123-
if(auto typeApp = dynamic_cast<ASTNodeTypeApplication*>(type); typeApp != nullptr) {
123+
if (auto typeApp = dynamic_cast<ASTNodeTypeApplication*>(type); typeApp != nullptr) {
124124
return typeApp->getTypeDefinition(evaluator);
125125
}
126126
}
@@ -138,7 +138,7 @@ namespace pl::core::ast {
138138
[[nodiscard]] const std::string ASTNodeTypeApplication::getTypeName() const {
139139
if(auto typeDecl = dynamic_cast<const ASTNodeTypeDecl*>(this->m_type.get()); typeDecl != nullptr) {
140140
std::string typeName = typeDecl->getName();
141-
if(this->m_templateArguments.empty()) {
141+
if (this->m_templateArguments.empty()) {
142142
return typeName;
143143
} else {
144144
return fmt::format("{}<{}>", typeName, computeTemplateTypeString(this->m_templateArguments));

lib/source/pl/core/ast/ast_node_type_decl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ namespace pl::core::ast {
8080

8181
for (size_t i = 0; i < this->m_templateParameters.size(); i++) {
8282
auto &templateParameter = this->m_templateParameters[i];
83-
if(i >= templateArguments.size()) {
84-
83+
if (i >= templateArguments.size()) {
8584
break;
8685
}
86+
8787
if (!templateParameter->isType()) {
8888
auto& argument = templateArguments[i];
8989
auto literal = dynamic_cast<ASTNodeLiteral*>(argument.get());
@@ -144,21 +144,21 @@ namespace pl::core::ast {
144144
}
145145

146146
const ASTNode* ASTNodeTypeDecl::getTypeDefinition(Evaluator *evaluator) const {
147-
if(m_type == nullptr)
147+
if (m_type == nullptr)
148148
err::E0004.throwError(fmt::format("Cannot use incomplete type '{}' before it has been defined.", this->m_name), "Try defining this type further up in your code before trying to instantiate it.", this->getLocation());
149-
else if(auto typeApp = dynamic_cast<ASTNodeTypeApplication*>(m_type.get()); typeApp != nullptr)
149+
else if (auto typeApp = dynamic_cast<ASTNodeTypeApplication*>(m_type.get()); typeApp != nullptr)
150150
return typeApp->getTypeDefinition(evaluator);
151151
else
152152
return m_type.get();
153153
}
154154

155155
[[nodiscard]] const std::string ASTNodeTypeDecl::getTypeName() const {
156-
if(this->isTemplateType()) {
156+
if (this->isTemplateType()) {
157157
std::string typeName = this->m_name + "<";
158-
for(const auto& param : this->m_templateParameters) {
158+
for (const auto& param : this->m_templateParameters) {
159159
typeName += param->getName().get() + ", ";
160160
}
161-
if(!this->m_templateParameters.empty()) {
161+
if (!this->m_templateParameters.empty()) {
162162
typeName = typeName.substr(0, typeName.size() - 2);
163163
}
164164
typeName += ">";

lib/source/pl/core/parser.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ namespace pl::core {
13151315
type->setTemplateParameterIndex(index);
13161316
return type;
13171317
}
1318-
if(templateType->isType()){
1318+
if (templateType->isType()){
13191319
index++;
13201320
}
13211321
}
@@ -1558,7 +1558,6 @@ namespace pl::core {
15581558

15591559
if (!sequence(tkn::Operator::Assign)) {
15601560
// Forward declaration
1561-
15621561
auto typeName = getNamespacePrefixedNames(name).back();
15631562
if (typedefIdentifier != nullptr)
15641563
typedefIdentifier->setType(Token::Identifier::IdentifierType::UDT);
@@ -2813,17 +2812,18 @@ namespace pl::core {
28132812
}
28142813

28152814
void Parser::reset() {
2816-
for(const auto &[_, type] : this->m_types) {
2817-
if(type != nullptr && type->isValid()) {
2818-
if(auto builtinType = dynamic_cast<ast::ASTNodeBuiltinType*>(type->getType().get()); builtinType != nullptr) {
2819-
if(builtinType->getType() != Token::ValueType::CustomType) {
2815+
for (const auto &[_, type] : this->m_types) {
2816+
if (type != nullptr && type->isValid()) {
2817+
if (auto builtinType = dynamic_cast<ast::ASTNodeBuiltinType*>(type->getType().get()); builtinType != nullptr) {
2818+
if (builtinType->getType() != Token::ValueType::CustomType) {
28202819
type->setType(nullptr);
28212820
}
28222821
} else {
28232822
type->setType(nullptr);
28242823
}
28252824
}
28262825
}
2826+
28272827
this->m_types.clear();
28282828
this->m_currTemplateType.clear();
28292829
this->m_matchedOptionals.clear();

lib/source/pl/core/validator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ namespace pl::core {
186186
return false;
187187
}
188188
}
189-
} else if(const auto compoundNode = dynamic_cast<ast::ASTNodeCompoundStatement *>(node); compoundNode != nullptr) {
189+
} else if (const auto compoundNode = dynamic_cast<ast::ASTNodeCompoundStatement *>(node); compoundNode != nullptr) {
190190
if (!this->validateNodes(compoundNode->getStatements(), false))
191191
return false;
192192
}

lib/source/pl/pattern_language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace pl {
5353
if (this->m_flattenThread.joinable())
5454
this->m_flattenThread.join();
5555
this->m_parserManager.reset();
56-
if(this->m_internals.parser)
56+
if (this->m_internals.parser)
5757
this->m_internals.parser->reset();
5858
this->m_patterns.clear();
5959
this->m_flattenedPatterns.clear();

tests/include/test_patterns/test_pattern_custom_builtin_type.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ namespace pl::test {
2929
return 2;
3030
}
3131
};
32+
3233
}

tests/include/test_patterns/test_pattern_template_parameters_scope.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ namespace pl::test {
118118
)";
119119
}
120120
};
121+
121122
}

tests/source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int runTests(int argc, char **argv) {
109109
test->m_runtime = &runtime;
110110
test->setup();
111111

112-
for(size_t i = 0; i < test->repeatTimes(); i++) {
112+
for (size_t i = 0; i < test->repeatTimes(); i++) {
113113
auto result = runtime.executeString(test->getSourceCode());
114114

115115
// Check if compilation succeeded

0 commit comments

Comments
 (0)