mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-01 17:17:55 -05:00
Reformat code with clang format
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
#include "MemberComputations.h"
|
||||
|
||||
#include "Domain/Definition/ArrayDeclarationModifier.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
#include "StructureComputations.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "StructureComputations.h"
|
||||
#include "Domain/Definition/ArrayDeclarationModifier.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
|
||||
MemberComputations::MemberComputations(const MemberInformation* member)
|
||||
: m_info(member)
|
||||
{
|
||||
@ -21,10 +21,12 @@ bool MemberComputations::ShouldIgnore() const
|
||||
bool MemberComputations::ContainsNonEmbeddedReference() const
|
||||
{
|
||||
const auto& declarationModifiers = m_info->m_member->m_type_declaration->m_declaration_modifiers;
|
||||
return std::any_of(declarationModifiers.begin(), declarationModifiers.end(), [](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
bool MemberComputations::ContainsSinglePointerReference() const
|
||||
@ -81,9 +83,8 @@ const IEvaluation* MemberComputations::GetArrayPointerCountEvaluation() const
|
||||
return nullptr;
|
||||
|
||||
const auto* lastModifier = declarationModifiers[declarationModifiers.size() - 1].get();
|
||||
return lastModifier->GetType() == DeclarationModifierType::POINTER
|
||||
? dynamic_cast<const PointerDeclarationModifier*>(lastModifier)->GetCountEvaluation()
|
||||
: nullptr;
|
||||
return lastModifier->GetType() == DeclarationModifierType::POINTER ? dynamic_cast<const PointerDeclarationModifier*>(lastModifier)->GetCountEvaluation()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
bool MemberComputations::IsArray() const
|
||||
@ -135,10 +136,12 @@ bool MemberComputations::IsPointerToArray() const
|
||||
if (lastModifier->GetType() != DeclarationModifierType::ARRAY)
|
||||
return false;
|
||||
|
||||
return std::any_of(declarationModifiers.begin(), declarationModifiers.end(), [](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<int> MemberComputations::GetPointerToArraySizes() const
|
||||
@ -164,7 +167,7 @@ int MemberComputations::GetPointerDepth() const
|
||||
{
|
||||
auto depth = 0;
|
||||
const auto& declarationModifiers = m_info->m_member->m_type_declaration->m_declaration_modifiers;
|
||||
for(const auto& declarationModifier : declarationModifiers)
|
||||
for (const auto& declarationModifier : declarationModifiers)
|
||||
{
|
||||
if (declarationModifier->GetType() == DeclarationModifierType::POINTER)
|
||||
depth++;
|
||||
@ -204,11 +207,13 @@ bool MemberComputations::HasDynamicArraySize() const
|
||||
{
|
||||
const auto& declarationModifiers = m_info->m_member->m_type_declaration->m_declaration_modifiers;
|
||||
|
||||
return std::any_of(declarationModifiers.begin(), declarationModifiers.end(), [](const std::unique_ptr<DeclarationModifier>& declarationModifier)
|
||||
{
|
||||
return declarationModifier->GetType() == DeclarationModifierType::ARRAY
|
||||
&& dynamic_cast<ArrayDeclarationModifier*>(declarationModifier.get())->m_dynamic_size_evaluation;
|
||||
});
|
||||
return std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& declarationModifier)
|
||||
{
|
||||
return declarationModifier->GetType() == DeclarationModifierType::ARRAY
|
||||
&& dynamic_cast<ArrayDeclarationModifier*>(declarationModifier.get())->m_dynamic_size_evaluation;
|
||||
});
|
||||
}
|
||||
|
||||
bool MemberComputations::IsDynamicMember() const
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "MemberDeclarationModifierComputations.h"
|
||||
|
||||
#include "Domain/Definition/ArrayDeclarationModifier.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
#include "MemberComputations.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "MemberComputations.h"
|
||||
#include "Domain/Definition/ArrayDeclarationModifier.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
|
||||
DeclarationModifierComputations::DeclarationModifierComputations(const MemberInformation* member, std::vector<int> modifierIndices)
|
||||
: m_information(member),
|
||||
m_modifier_indices(std::move(modifierIndices))
|
||||
@ -135,16 +135,17 @@ bool DeclarationModifierComputations::IsSinglePointer() const
|
||||
{
|
||||
auto* declarationModifier = GetDeclarationModifier();
|
||||
|
||||
if (declarationModifier != nullptr
|
||||
&& declarationModifier->GetType() == DeclarationModifierType::POINTER
|
||||
if (declarationModifier != nullptr && declarationModifier->GetType() == DeclarationModifierType::POINTER
|
||||
&& !dynamic_cast<PointerDeclarationModifier*>(declarationModifier)->CountEvaluationIsArray(m_combined_index))
|
||||
{
|
||||
const auto following = GetFollowingDeclarationModifiers();
|
||||
|
||||
return !std::any_of(following.begin(), following.end(), [](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return !std::any_of(following.begin(),
|
||||
following.end(),
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -154,16 +155,17 @@ bool DeclarationModifierComputations::IsArrayPointer() const
|
||||
{
|
||||
auto* declarationModifier = GetDeclarationModifier();
|
||||
|
||||
if (declarationModifier != nullptr
|
||||
&& declarationModifier->GetType() == DeclarationModifierType::POINTER
|
||||
if (declarationModifier != nullptr && declarationModifier->GetType() == DeclarationModifierType::POINTER
|
||||
&& dynamic_cast<PointerDeclarationModifier*>(declarationModifier)->CountEvaluationIsArray(m_combined_index))
|
||||
{
|
||||
const auto following = GetFollowingDeclarationModifiers();
|
||||
|
||||
return !std::any_of(following.begin(), following.end(), [](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return !std::any_of(following.begin(),
|
||||
following.end(),
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -189,14 +191,14 @@ bool DeclarationModifierComputations::IsPointerArray() const
|
||||
return false;
|
||||
|
||||
const auto thisDeclModIsArray = declarationModifier->GetType() == DeclarationModifierType::POINTER
|
||||
&& dynamic_cast<PointerDeclarationModifier*>(declarationModifier)->CountEvaluationIsArray(m_combined_index)
|
||||
|| declarationModifier->GetType() == DeclarationModifierType::ARRAY;
|
||||
&& dynamic_cast<PointerDeclarationModifier*>(declarationModifier)->CountEvaluationIsArray(m_combined_index)
|
||||
|| declarationModifier->GetType() == DeclarationModifierType::ARRAY;
|
||||
|
||||
if (!thisDeclModIsArray)
|
||||
return false;
|
||||
|
||||
const auto nextDeclModIsSinglePointer = nextDeclarationModifier->GetType() == DeclarationModifierType::POINTER
|
||||
&& !dynamic_cast<PointerDeclarationModifier*>(nextDeclarationModifier)->AnyCountEvaluationIsArray();
|
||||
&& !dynamic_cast<PointerDeclarationModifier*>(nextDeclarationModifier)->AnyCountEvaluationIsArray();
|
||||
|
||||
return nextDeclModIsSinglePointer;
|
||||
}
|
||||
@ -229,14 +231,13 @@ bool DeclarationModifierComputations::IsDynamicArray() const
|
||||
return false;
|
||||
|
||||
return declarationModifier->GetType() == DeclarationModifierType::ARRAY
|
||||
&& dynamic_cast<ArrayDeclarationModifier*>(declarationModifier)->m_dynamic_size_evaluation != nullptr;
|
||||
&& dynamic_cast<ArrayDeclarationModifier*>(declarationModifier)->m_dynamic_size_evaluation != nullptr;
|
||||
}
|
||||
|
||||
const IEvaluation* DeclarationModifierComputations::GetDynamicArraySizeEvaluation() const
|
||||
{
|
||||
auto* declarationModifier = GetDeclarationModifier();
|
||||
if (declarationModifier == nullptr
|
||||
|| declarationModifier->GetType() != DeclarationModifierType::ARRAY)
|
||||
if (declarationModifier == nullptr || declarationModifier->GetType() != DeclarationModifierType::ARRAY)
|
||||
return nullptr;
|
||||
|
||||
return dynamic_cast<ArrayDeclarationModifier*>(declarationModifier)->m_dynamic_size_evaluation.get();
|
||||
@ -246,8 +247,12 @@ unsigned DeclarationModifierComputations::GetAlignment() const
|
||||
{
|
||||
const auto following = GetFollowingDeclarationModifiers();
|
||||
|
||||
return std::any_of(following.begin(), following.end(), [](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
}) ? m_information->m_member->GetAlignment() : m_information->m_member->m_type_declaration->m_type->GetAlignment();
|
||||
return std::any_of(following.begin(),
|
||||
following.end(),
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
})
|
||||
? m_information->m_member->GetAlignment()
|
||||
: m_information->m_member->m_type_declaration->m_type->GetAlignment();
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Domain/Information/MemberInformation.h"
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
#include "Domain/Information/MemberInformation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
class DeclarationModifierComputations
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "StructureComputations.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "MemberComputations.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
StructureComputations::StructureComputations(const StructureInformation* structure)
|
||||
: m_info(structure)
|
||||
{
|
||||
@ -48,4 +48,4 @@ std::vector<MemberInformation*> StructureComputations::GetUsedMembers() const
|
||||
}
|
||||
|
||||
return members;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "DeclarationModifier.h"
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ArrayDeclarationModifier final : public DeclarationModifier
|
||||
{
|
||||
|
@ -42,21 +42,6 @@ const BaseTypeDefinition* const BaseTypeDefinition::UNSIGNED_LONG = new BaseType
|
||||
const BaseTypeDefinition* const BaseTypeDefinition::LONG_LONG = new BaseTypeDefinition("long long", 8);
|
||||
const BaseTypeDefinition* const BaseTypeDefinition::UNSIGNED_LONG_LONG = new BaseTypeDefinition("unsigned long long", 8);
|
||||
const BaseTypeDefinition* const BaseTypeDefinition::VOID = new BaseTypeDefinition("void", 0);
|
||||
const BaseTypeDefinition* const BaseTypeDefinition::ALL_BASE_TYPES[]
|
||||
{
|
||||
FLOAT,
|
||||
DOUBLE,
|
||||
BOOL,
|
||||
CHAR,
|
||||
UNSIGNED_CHAR,
|
||||
SHORT,
|
||||
UNSIGNED_SHORT,
|
||||
INT,
|
||||
UNSIGNED_INT,
|
||||
LONG,
|
||||
UNSIGNED_LONG,
|
||||
LONG_LONG,
|
||||
UNSIGNED_LONG_LONG,
|
||||
VOID
|
||||
};
|
||||
const size_t BaseTypeDefinition::ALL_BASE_TYPES_COUNT = std::extent<decltype(ALL_BASE_TYPES)>::value;
|
||||
const BaseTypeDefinition* const BaseTypeDefinition::ALL_BASE_TYPES[]{
|
||||
FLOAT, DOUBLE, BOOL, CHAR, UNSIGNED_CHAR, SHORT, UNSIGNED_SHORT, INT, UNSIGNED_INT, LONG, UNSIGNED_LONG, LONG_LONG, UNSIGNED_LONG_LONG, VOID};
|
||||
const size_t BaseTypeDefinition::ALL_BASE_TYPES_COUNT = std::extent<decltype(ALL_BASE_TYPES)>::value;
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "DataDefinition.h"
|
||||
|
||||
#include "Utils/NamespaceBuilder.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
#include "Utils/NamespaceBuilder.h"
|
||||
|
||||
DataDefinition::DataDefinition(std::string _namespace, std::string name)
|
||||
: m_namespace(std::move(_namespace)),
|
||||
m_name(std::move(name))
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
enum class DataDefinitionType
|
||||
{
|
||||
STRUCT,
|
||||
@ -27,7 +27,7 @@ public:
|
||||
|
||||
std::string m_namespace;
|
||||
std::string m_name;
|
||||
|
||||
|
||||
_NODISCARD virtual DataDefinitionType GetType() const = 0;
|
||||
_NODISCARD virtual unsigned GetAlignment() const = 0;
|
||||
_NODISCARD virtual bool GetForceAlignment() const = 0;
|
||||
|
@ -19,4 +19,4 @@ public:
|
||||
DeclarationModifier& operator=(DeclarationModifier&& other) noexcept = default;
|
||||
|
||||
_NODISCARD virtual DeclarationModifierType GetType() const = 0;
|
||||
};
|
||||
};
|
||||
|
@ -14,25 +14,25 @@ DefinitionWithMembers::DefinitionWithMembers(std::string _namespace, std::string
|
||||
{
|
||||
}
|
||||
|
||||
//void DefinitionWithMembers::CalculateAlignment()
|
||||
// void DefinitionWithMembers::CalculateAlignment()
|
||||
//{
|
||||
// if (m_has_alignment_override)
|
||||
// {
|
||||
// m_flags |= FLAG_ALIGNMENT_FORCED;
|
||||
// m_alignment = m_alignment_override;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_alignment = 0;
|
||||
// for (const auto& member : m_members)
|
||||
// {
|
||||
// const auto memberAlignment = member->GetAlignment();
|
||||
// if (memberAlignment > m_alignment)
|
||||
// m_alignment = memberAlignment;
|
||||
// }
|
||||
// }
|
||||
// m_flags |= FLAG_ALIGNMENT_CALCULATED;
|
||||
//}
|
||||
// if (m_has_alignment_override)
|
||||
// {
|
||||
// m_flags |= FLAG_ALIGNMENT_FORCED;
|
||||
// m_alignment = m_alignment_override;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_alignment = 0;
|
||||
// for (const auto& member : m_members)
|
||||
// {
|
||||
// const auto memberAlignment = member->GetAlignment();
|
||||
// if (memberAlignment > m_alignment)
|
||||
// m_alignment = memberAlignment;
|
||||
// }
|
||||
// }
|
||||
// m_flags |= FLAG_ALIGNMENT_CALCULATED;
|
||||
// }
|
||||
|
||||
unsigned DefinitionWithMembers::GetAlignment() const
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "DataDefinition.h"
|
||||
#include "Variable.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class DefinitionWithMembers : public DataDefinition
|
||||
{
|
||||
public:
|
||||
@ -30,4 +30,4 @@ public:
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
};
|
||||
};
|
||||
|
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "BaseTypeDefinition.h"
|
||||
#include "DataDefinition.h"
|
||||
#include "EnumMember.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class EnumDefinition final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
|
@ -10,4 +10,4 @@ public:
|
||||
|
||||
EnumMember();
|
||||
EnumMember(std::string name, int value);
|
||||
};
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ bool PointerDeclarationModifier::CountEvaluationIsArray() const
|
||||
|
||||
bool PointerDeclarationModifier::CountEvaluationIsArray(const int index) const
|
||||
{
|
||||
if(index >= 0 && m_count_evaluation_by_array_index.size() > static_cast<unsigned>(index))
|
||||
if (index >= 0 && m_count_evaluation_by_array_index.size() > static_cast<unsigned>(index))
|
||||
{
|
||||
return EvaluationIsArray(m_count_evaluation_by_array_index[index].get());
|
||||
}
|
||||
@ -62,7 +62,7 @@ bool PointerDeclarationModifier::AnyCountEvaluationIsArray() const
|
||||
if (m_count_evaluation && EvaluationIsArray(m_count_evaluation.get()))
|
||||
return true;
|
||||
|
||||
for(const auto& arrayCountEvaluation : m_count_evaluation_by_array_index)
|
||||
for (const auto& arrayCountEvaluation : m_count_evaluation_by_array_index)
|
||||
{
|
||||
if (EvaluationIsArray(arrayCountEvaluation.get()))
|
||||
return true;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "DeclarationModifier.h"
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class PointerDeclarationModifier final : public DeclarationModifier
|
||||
{
|
||||
static const IEvaluation* const DEFAULT_COUNT;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "TypeDeclaration.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "ArrayDeclarationModifier.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
TypeDeclaration::TypeDeclaration(const DataDefinition* type)
|
||||
: m_flags(0),
|
||||
m_size(0),
|
||||
|
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "DataDefinition.h"
|
||||
#include "DeclarationModifier.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "DataDefinition.h"
|
||||
#include "DeclarationModifier.h"
|
||||
|
||||
class TypeDeclaration
|
||||
{
|
||||
public:
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
class UnionDefinition final : public DefinitionWithMembers
|
||||
{
|
||||
//protected:
|
||||
// void CalculateSize() override;
|
||||
// protected:
|
||||
// void CalculateSize() override;
|
||||
|
||||
public:
|
||||
UnionDefinition(std::string _namespace, std::string name, int pack);
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "TypeDeclaration.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "TypeDeclaration.h"
|
||||
|
||||
class Variable
|
||||
{
|
||||
public:
|
||||
|
@ -5,4 +5,4 @@ enum class Architecture
|
||||
UNKNOWN,
|
||||
X86,
|
||||
X64
|
||||
};
|
||||
};
|
||||
|
@ -23,4 +23,4 @@ public:
|
||||
_NODISCARD virtual EvaluationType GetType() const = 0;
|
||||
_NODISCARD virtual bool IsStatic() const = 0;
|
||||
_NODISCARD virtual int EvaluateNumeric() const = 0;
|
||||
};
|
||||
};
|
||||
|
@ -7,7 +7,9 @@ OperandDynamic::OperandDynamic(StructureInformation* structure)
|
||||
{
|
||||
}
|
||||
|
||||
OperandDynamic::OperandDynamic(StructureInformation* structure, std::vector<MemberInformation*> referencedMemberChain, std::vector<std::unique_ptr<IEvaluation>> arrayIndices)
|
||||
OperandDynamic::OperandDynamic(StructureInformation* structure,
|
||||
std::vector<MemberInformation*> referencedMemberChain,
|
||||
std::vector<std::unique_ptr<IEvaluation>> arrayIndices)
|
||||
: m_structure(structure),
|
||||
m_referenced_member_chain(std::move(referencedMemberChain)),
|
||||
m_array_indices(std::move(arrayIndices))
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "IEvaluation.h"
|
||||
#include "Domain/Information/MemberInformation.h"
|
||||
#include "Domain/Information/StructureInformation.h"
|
||||
#include "IEvaluation.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class OperandDynamic final : public IEvaluation
|
||||
{
|
||||
@ -14,7 +14,9 @@ public:
|
||||
std::vector<std::unique_ptr<IEvaluation>> m_array_indices;
|
||||
|
||||
explicit OperandDynamic(StructureInformation* structure);
|
||||
OperandDynamic(StructureInformation* structure, std::vector<MemberInformation*> referencedMemberChain, std::vector<std::unique_ptr<IEvaluation>> arrayIndices);
|
||||
OperandDynamic(StructureInformation* structure,
|
||||
std::vector<MemberInformation*> referencedMemberChain,
|
||||
std::vector<std::unique_ptr<IEvaluation>> arrayIndices);
|
||||
|
||||
_NODISCARD EvaluationType GetType() const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "IEvaluation.h"
|
||||
#include "Domain/Definition/EnumMember.h"
|
||||
#include "IEvaluation.h"
|
||||
|
||||
class OperandStatic final : public IEvaluation
|
||||
{
|
||||
|
@ -30,11 +30,11 @@ int Operation::EvaluateNumeric() const
|
||||
bool Operation::Operand1NeedsParenthesis() const
|
||||
{
|
||||
return m_operand1->GetType() == EvaluationType::OPERATION
|
||||
&& dynamic_cast<Operation*>(m_operand1.get())->m_operation_type->m_precedence > m_operation_type->m_precedence;
|
||||
&& dynamic_cast<Operation*>(m_operand1.get())->m_operation_type->m_precedence > m_operation_type->m_precedence;
|
||||
}
|
||||
|
||||
bool Operation::Operand2NeedsParenthesis() const
|
||||
{
|
||||
return m_operand2->GetType() == EvaluationType::OPERATION
|
||||
&& dynamic_cast<Operation*>(m_operand2.get())->m_operation_type->m_precedence >= m_operation_type->m_precedence;
|
||||
&& dynamic_cast<Operation*>(m_operand2.get())->m_operation_type->m_precedence >= m_operation_type->m_precedence;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "IEvaluation.h"
|
||||
#include "OperationType.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Operation final : public IEvaluation
|
||||
{
|
||||
|
@ -7,133 +7,147 @@ OperationType::OperationType(std::string syntax, const OperationPrecedence prece
|
||||
{
|
||||
}
|
||||
|
||||
const OperationType* const OperationType::OPERATION_ADD
|
||||
= new OperationType("+", OperationPrecedence::ADDITION_SUBTRACTION, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 + op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_ADD = new OperationType("+",
|
||||
OperationPrecedence::ADDITION_SUBTRACTION,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 + op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_SUBTRACT
|
||||
= new OperationType("-", OperationPrecedence::ADDITION_SUBTRACTION, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 - op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_SUBTRACT = new OperationType("-",
|
||||
OperationPrecedence::ADDITION_SUBTRACTION,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 - op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_MULTIPLY
|
||||
= new OperationType("*", OperationPrecedence::MULTIPLICATION_DIVISION_REMAINDER, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 * op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_MULTIPLY = new OperationType("*",
|
||||
OperationPrecedence::MULTIPLICATION_DIVISION_REMAINDER,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 * op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_DIVIDE
|
||||
= new OperationType("/", OperationPrecedence::MULTIPLICATION_DIVISION_REMAINDER, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 / op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_DIVIDE = new OperationType("/",
|
||||
OperationPrecedence::MULTIPLICATION_DIVISION_REMAINDER,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 / op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_REMAINDER
|
||||
= new OperationType("%", OperationPrecedence::MULTIPLICATION_DIVISION_REMAINDER, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 % op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_REMAINDER = new OperationType("%",
|
||||
OperationPrecedence::MULTIPLICATION_DIVISION_REMAINDER,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 % op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_BITWISE_AND
|
||||
= new OperationType("&", OperationPrecedence::BITWISE_AND, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 & op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_BITWISE_AND = new OperationType("&",
|
||||
OperationPrecedence::BITWISE_AND,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 & op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_BITWISE_XOR
|
||||
= new OperationType("^", OperationPrecedence::BITWISE_XOR, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 ^ op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_BITWISE_XOR = new OperationType("^",
|
||||
OperationPrecedence::BITWISE_XOR,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 ^ op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_BITWISE_OR
|
||||
= new OperationType("|", OperationPrecedence::BITWISE_OR, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 | op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_BITWISE_OR = new OperationType("|",
|
||||
OperationPrecedence::BITWISE_OR,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 | op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_SHIFT_LEFT
|
||||
= new OperationType("<<", OperationPrecedence::BITWISE_SHIFT, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 << op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_SHIFT_LEFT = new OperationType("<<",
|
||||
OperationPrecedence::BITWISE_SHIFT,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 << op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_SHIFT_RIGHT
|
||||
= new OperationType(">>", OperationPrecedence::BITWISE_SHIFT, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 >> op2;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_SHIFT_RIGHT = new OperationType(">>",
|
||||
OperationPrecedence::BITWISE_SHIFT,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 >> op2;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_GREATER_THAN
|
||||
= new OperationType(">", OperationPrecedence::RELATIONAL_GREATER_LESS_THAN, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 > op2 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_GREATER_THAN = new OperationType(">",
|
||||
OperationPrecedence::RELATIONAL_GREATER_LESS_THAN,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 > op2 ? 1 : 0;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_GREATER_EQUAL_THAN
|
||||
= new OperationType(">=", OperationPrecedence::RELATIONAL_GREATER_LESS_THAN, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 >= op2 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_GREATER_EQUAL_THAN = new OperationType(">=",
|
||||
OperationPrecedence::RELATIONAL_GREATER_LESS_THAN,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 >= op2 ? 1 : 0;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_LESS_THAN
|
||||
= new OperationType("<", OperationPrecedence::RELATIONAL_GREATER_LESS_THAN, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 < op2 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_LESS_THAN = new OperationType("<",
|
||||
OperationPrecedence::RELATIONAL_GREATER_LESS_THAN,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 < op2 ? 1 : 0;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_LESS_EQUAL_THAN
|
||||
= new OperationType("<=", OperationPrecedence::RELATIONAL_GREATER_LESS_THAN, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 <= op2 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_LESS_EQUAL_THAN = new OperationType("<=",
|
||||
OperationPrecedence::RELATIONAL_GREATER_LESS_THAN,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 <= op2 ? 1 : 0;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_EQUALS
|
||||
= new OperationType("==", OperationPrecedence::RELATIONAL_EQUALS, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 == op2 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_EQUALS = new OperationType("==",
|
||||
OperationPrecedence::RELATIONAL_EQUALS,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 == op2 ? 1 : 0;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_NOT_EQUAL
|
||||
= new OperationType("!=", OperationPrecedence::RELATIONAL_EQUALS, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 != op2 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_NOT_EQUAL = new OperationType("!=",
|
||||
OperationPrecedence::RELATIONAL_EQUALS,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 != op2 ? 1 : 0;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_AND
|
||||
= new OperationType("&&", OperationPrecedence::LOGICAL_AND, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 > 0 && op2 > 0 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_AND = new OperationType("&&",
|
||||
OperationPrecedence::LOGICAL_AND,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 > 0 && op2 > 0 ? 1 : 0;
|
||||
});
|
||||
|
||||
const OperationType* const OperationType::OPERATION_OR
|
||||
= new OperationType("||", OperationPrecedence::LOGICAL_OR, [](auto op1, auto op2)
|
||||
{
|
||||
return op1 > 0 || op2 > 0 ? 1 : 0;
|
||||
});
|
||||
const OperationType* const OperationType::OPERATION_OR = new OperationType("||",
|
||||
OperationPrecedence::LOGICAL_OR,
|
||||
[](auto op1, auto op2)
|
||||
{
|
||||
return op1 > 0 || op2 > 0 ? 1 : 0;
|
||||
});
|
||||
|
||||
|
||||
const OperationType* const OperationType::ALL_OPERATION_TYPES[]
|
||||
{
|
||||
OPERATION_ADD,
|
||||
OPERATION_SUBTRACT,
|
||||
OPERATION_MULTIPLY,
|
||||
OPERATION_DIVIDE,
|
||||
OPERATION_REMAINDER,
|
||||
OPERATION_BITWISE_AND,
|
||||
OPERATION_BITWISE_XOR,
|
||||
OPERATION_BITWISE_OR,
|
||||
OPERATION_SHIFT_LEFT,
|
||||
OPERATION_SHIFT_RIGHT,
|
||||
OPERATION_GREATER_THAN,
|
||||
OPERATION_GREATER_EQUAL_THAN,
|
||||
OPERATION_LESS_THAN,
|
||||
OPERATION_LESS_EQUAL_THAN,
|
||||
OPERATION_EQUALS,
|
||||
OPERATION_NOT_EQUAL,
|
||||
OPERATION_AND,
|
||||
OPERATION_OR
|
||||
};
|
||||
const OperationType* const OperationType::ALL_OPERATION_TYPES[]{OPERATION_ADD,
|
||||
OPERATION_SUBTRACT,
|
||||
OPERATION_MULTIPLY,
|
||||
OPERATION_DIVIDE,
|
||||
OPERATION_REMAINDER,
|
||||
OPERATION_BITWISE_AND,
|
||||
OPERATION_BITWISE_XOR,
|
||||
OPERATION_BITWISE_OR,
|
||||
OPERATION_SHIFT_LEFT,
|
||||
OPERATION_SHIFT_RIGHT,
|
||||
OPERATION_GREATER_THAN,
|
||||
OPERATION_GREATER_EQUAL_THAN,
|
||||
OPERATION_LESS_THAN,
|
||||
OPERATION_LESS_EQUAL_THAN,
|
||||
OPERATION_EQUALS,
|
||||
OPERATION_NOT_EQUAL,
|
||||
OPERATION_AND,
|
||||
OPERATION_OR};
|
||||
|
@ -49,4 +49,4 @@ public:
|
||||
static const OperationType* const OPERATION_OR;
|
||||
|
||||
static const OperationType* const ALL_OPERATION_TYPES[];
|
||||
};
|
||||
};
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Domain/Definition/DataDefinition.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Domain/Definition/DataDefinition.h"
|
||||
|
||||
class CustomAction
|
||||
{
|
||||
public:
|
||||
|
@ -19,4 +19,4 @@ public:
|
||||
bool m_is_default;
|
||||
|
||||
FastFileBlock(std::string name, unsigned index, FastFileBlockType type, bool isDefault);
|
||||
};
|
||||
};
|
||||
|
@ -1,14 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Domain/Definition/Variable.h"
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
#include "Domain/FastFile/FastFileBlock.h"
|
||||
#include "StructureInformation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "StructureInformation.h"
|
||||
#include "Domain/Definition/Variable.h"
|
||||
#include "Domain/FastFile/FastFileBlock.h"
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
|
||||
class StructureInformation;
|
||||
|
||||
class MemberInformation
|
||||
{
|
||||
public:
|
||||
|
@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "MemberInformation.h"
|
||||
#include "Domain/Definition/DefinitionWithMembers.h"
|
||||
#include "Domain/Definition/EnumMember.h"
|
||||
#include "Domain/Extension/CustomAction.h"
|
||||
#include "Domain/FastFile/FastFileBlock.h"
|
||||
#include "MemberInformation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
class MemberInformation;
|
||||
|
||||
class StructureInformation
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user