Fix #27
This commit is contained in:
parent
dc7c529716
commit
ed2bf996b3
17
src/dfmt.d
17
src/dfmt.d
|
@ -173,22 +173,26 @@ private:
|
||||||
assert(index < tokens.length);
|
assert(index < tokens.length);
|
||||||
if (currentIs(tok!"comment"))
|
if (currentIs(tok!"comment"))
|
||||||
{
|
{
|
||||||
|
immutable bool currIsSlashSlash = tokens[index].text[0 .. 2] == "//";
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
{
|
{
|
||||||
immutable t = tokens[index - 1].type;
|
immutable t = tokens[index - 1].type;
|
||||||
if (t != tok!";" && t != tok!"}" && tokens[index - 1].line + 1 < tokens[index]
|
immutable bool prevWasSlashSlash = t == tok!"comment"
|
||||||
.line)
|
&& tokens[index - 1].text[0 .. 2] == "//";
|
||||||
|
immutable bool shouldSkipNewline = prevWasSlashSlash && !currIsSlashSlash
|
||||||
|
&& tokens[index - 1].line + 2 <= tokens[index].line;
|
||||||
|
if (!shouldSkipNewline && t != tok!";" && t != tok!"}"
|
||||||
|
&& tokens[index - 1].line + 1 < tokens[index].line)
|
||||||
{
|
{
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
else if (tokens[index - 1].line == tokens[index].line)
|
else if (tokens[index - 1].line == tokens[index].line
|
||||||
|
|| (t == tok!")" && tokens[index + 1].type == tok!"{"))
|
||||||
write(" ");
|
write(" ");
|
||||||
else if (isWrapIndent(t))
|
|
||||||
pushWrapIndent(t);
|
|
||||||
}
|
}
|
||||||
writeToken();
|
writeToken();
|
||||||
immutable j = justAddedExtraNewline;
|
immutable j = justAddedExtraNewline;
|
||||||
if (tokens[index - 1].text[0 .. 2] == "//")
|
if (currIsSlashSlash)
|
||||||
{
|
{
|
||||||
newline();
|
newline();
|
||||||
justAddedExtraNewline = j;
|
justAddedExtraNewline = j;
|
||||||
|
@ -1019,6 +1023,7 @@ private:
|
||||||
{
|
{
|
||||||
output.put("\n");
|
output.put("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
justAddedExtraNewline = false;
|
justAddedExtraNewline = false;
|
||||||
currentLineLength = 0;
|
currentLineLength = 0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
SignExtendedNumber opMul(const SignExtendedNumber a) const
|
||||||
|
{
|
||||||
|
// like 0x10 * 0x10 == 0x100 == 0.
|
||||||
|
|
||||||
|
/* Special handling for zeros:
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
if (Port.isNan(r1) || Port.isNan(r2)) // if unordered
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cur && cur.ty == Tsarray) // sizes of dimensions
|
||||||
|
{
|
||||||
|
TypeSArray sa = cast(TypeSArray) cur;
|
||||||
|
mangleNumber(sa.dim ? sa.dim.toInteger() : 0);
|
||||||
|
cur = cur.nextOf();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
SignExtendedNumber opMul(const SignExtendedNumber a) const
|
||||||
|
{
|
||||||
|
// like 0x10 * 0x10 == 0x100 == 0.
|
||||||
|
|
||||||
|
/* Special handling for zeros:
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
if (Port.isNan(r1) || Port.isNan(r2)) // if unordered
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cur && cur.ty == Tsarray)
|
||||||
|
// sizes of dimensions
|
||||||
|
{
|
||||||
|
TypeSArray sa = cast(TypeSArray) cur;
|
||||||
|
mangleNumber(sa.dim ? sa.dim.toInteger() : 0);
|
||||||
|
cur = cur.nextOf();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
SignExtendedNumber opMul(const SignExtendedNumber a) const {
|
||||||
|
// like 0x10 * 0x10 == 0x100 == 0.
|
||||||
|
|
||||||
|
/* Special handling for zeros:
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest {
|
||||||
|
if (Port.isNan(r1) || Port.isNan(r2)) // if unordered
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cur && cur.ty == Tsarray) // sizes of dimensions
|
||||||
|
{
|
||||||
|
TypeSArray sa = cast(TypeSArray) cur;
|
||||||
|
mangleNumber(sa.dim ? sa.dim.toInteger() : 0);
|
||||||
|
cur = cur.nextOf();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue