Skip to content

Commit

Permalink
feat(preprocessor): convert undefined variables to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimowiczm authored and ForNeVeR committed Aug 19, 2024
1 parent f1f78f3 commit 8bf2f13
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ internal sealed record IdentifierExpression(Location Location, string Identifier
{
public string? EvaluateExpression(IMacroContext context)
{
string? lastValue = null;
var searchValue = Identifier;
do
{
Expand All @@ -23,11 +22,11 @@ internal sealed record IdentifierExpression(Location Location, string Identifier
if (context.TryResolveMacro(searchValue, out _, out var macroReplacement))
{
searchValue = macroReplacement.SkipWhile(t => t.Kind == CPreprocessorTokenType.WhiteSpace)
.FirstOrDefault()?.Text ?? "";
.FirstOrDefault()?.Text ?? string.Empty;
continue;
}

return lastValue;
return searchValue == string.Empty ? null : "0";
}
while (true);
}
Expand Down

0 comments on commit 8bf2f13

Please sign in to comment.