Fix hex literals in foreach loops
This commit is contained in:
parent
3ddac7885f
commit
06cf70b34c
|
@ -64,24 +64,37 @@ class BackwardsRangeCheck : BaseAnalyzer
|
||||||
|
|
||||||
override void visit(const PrimaryExpression primary)
|
override void visit(const PrimaryExpression primary)
|
||||||
{
|
{
|
||||||
import std.conv;
|
|
||||||
import std.string;
|
|
||||||
if (state == State.ignore || !isNumberLiteral(primary.primary.type))
|
if (state == State.ignore || !isNumberLiteral(primary.primary.type))
|
||||||
return;
|
return;
|
||||||
if (state == State.left)
|
if (state == State.left)
|
||||||
{
|
{
|
||||||
line = primary.primary.line;
|
line = primary.primary.line;
|
||||||
this.column = primary.primary.column;
|
this.column = primary.primary.column;
|
||||||
left = to!long(primary.primary.text.removechars("_uUlL"));
|
left = parseNumber(primary.primary.text);
|
||||||
hasLeft = true;
|
hasLeft = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
right = to!long(primary.primary.text.removechars("_uUlL"));
|
right = parseNumber(primary.primary.text);
|
||||||
hasRight = true;
|
hasRight = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long parseNumber(string te)
|
||||||
|
{
|
||||||
|
import std.conv;
|
||||||
|
import std.string;
|
||||||
|
string t = te.removechars("_uUlL");
|
||||||
|
if (t.length > 2)
|
||||||
|
{
|
||||||
|
if (t[1] == 'x' || t[1] == 'X')
|
||||||
|
return to!long(t[2..$], 16);
|
||||||
|
if (t[1] == 'b' || t[1] == 'B')
|
||||||
|
return to!long(t[2..$], 2);
|
||||||
|
}
|
||||||
|
return to!long(t);
|
||||||
|
}
|
||||||
|
|
||||||
override void visit(const SliceExpression sliceExpression)
|
override void visit(const SliceExpression sliceExpression)
|
||||||
{
|
{
|
||||||
if (sliceExpression.lower !is null && sliceExpression.upper !is null)
|
if (sliceExpression.lower !is null && sliceExpression.upper !is null)
|
||||||
|
|
Loading…
Reference in New Issue