mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Fix error in define expression crash
This commit is contained in:
parent
b3dbf4a104
commit
bba6fd9d4e
@ -277,9 +277,9 @@ bool DefinesStreamProxy::MatchUndefDirective(const ParserLine& line, const unsig
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ISimpleExpression> DefinesStreamProxy::ParseExpression(std::string expressionString) const
|
std::unique_ptr<ISimpleExpression> DefinesStreamProxy::ParseExpression(std::shared_ptr<std::string> fileName, int lineNumber, std::string expressionString) const
|
||||||
{
|
{
|
||||||
ParserLine pseudoLine(nullptr, 1, std::move(expressionString));
|
ParserLine pseudoLine(std::move(fileName), lineNumber, std::move(expressionString));
|
||||||
ExpandDefinedExpressions(pseudoLine);
|
ExpandDefinedExpressions(pseudoLine);
|
||||||
ExpandDefines(pseudoLine);
|
ExpandDefines(pseudoLine);
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const unsigned
|
|||||||
if (expressionString.empty())
|
if (expressionString.empty())
|
||||||
throw ParsingException(CreatePos(line, currentPos), "Cannot if without an expression.");
|
throw ParsingException(CreatePos(line, currentPos), "Cannot if without an expression.");
|
||||||
|
|
||||||
const auto expression = ParseExpression(expressionString);
|
const auto expression = ParseExpression(line.m_filename, line.m_line_number, expressionString);
|
||||||
if (!expression)
|
if (!expression)
|
||||||
throw ParsingException(CreatePos(line, currentPos), "Failed to parse if expression");
|
throw ParsingException(CreatePos(line, currentPos), "Failed to parse if expression");
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const unsign
|
|||||||
if (expressionString.empty())
|
if (expressionString.empty())
|
||||||
throw ParsingException(CreatePos(line, currentPos), "Cannot elif without an expression.");
|
throw ParsingException(CreatePos(line, currentPos), "Cannot elif without an expression.");
|
||||||
|
|
||||||
const auto expression = ParseExpression(expressionString);
|
const auto expression = ParseExpression(line.m_filename, line.m_line_number, expressionString);
|
||||||
if (!expression)
|
if (!expression)
|
||||||
throw ParsingException(CreatePos(line, currentPos), "Failed to parse elif expression");
|
throw ParsingException(CreatePos(line, currentPos), "Failed to parse elif expression");
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
void ExpandDefines(ParserLine& line) const;
|
void ExpandDefines(ParserLine& line) const;
|
||||||
|
|
||||||
_NODISCARD std::unique_ptr<ISimpleExpression> ParseExpression(std::string expressionString) const;
|
_NODISCARD std::unique_ptr<ISimpleExpression> ParseExpression(std::shared_ptr<std::string> fileName, int lineNumber, std::string expressionString) const;
|
||||||
|
|
||||||
ParserLine NextLine() override;
|
ParserLine NextLine() override;
|
||||||
bool IncludeFile(const std::string& filename) override;
|
bool IncludeFile(const std::string& filename) override;
|
||||||
|
@ -41,7 +41,7 @@ bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const unsig
|
|||||||
if (expressionString.empty())
|
if (expressionString.empty())
|
||||||
throw ParsingException(CreatePos(line, currentPosition), "Cannot set without an expression.");
|
throw ParsingException(CreatePos(line, currentPosition), "Cannot set without an expression.");
|
||||||
|
|
||||||
const auto expression = m_defines_proxy->ParseExpression(expressionString);
|
const auto expression = m_defines_proxy->ParseExpression(line.m_filename, line.m_line_number, expressionString);
|
||||||
if (!expression)
|
if (!expression)
|
||||||
throw ParsingException(CreatePos(line, currentPosition), "Failed to parse set expression");
|
throw ParsingException(CreatePos(line, currentPosition), "Failed to parse set expression");
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const
|
|||||||
if (expressionString.empty())
|
if (expressionString.empty())
|
||||||
throw ParsingException(CreatePos(line, currentPosition), "Cannot pragma filename without an expression.");
|
throw ParsingException(CreatePos(line, currentPosition), "Cannot pragma filename without an expression.");
|
||||||
|
|
||||||
const auto expression = m_defines_proxy->ParseExpression(expressionString);
|
const auto expression = m_defines_proxy->ParseExpression(line.m_filename, line.m_line_number, expressionString);
|
||||||
if (!expression)
|
if (!expression)
|
||||||
throw ParsingException(CreatePos(line, currentPosition), "Failed to parse pragma filename expression");
|
throw ParsingException(CreatePos(line, currentPosition), "Failed to parse pragma filename expression");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user