Fix AST equality checks

This commit is contained in:
Hackerpilot 2014-05-19 14:44:02 -07:00
parent db84119e33
commit 88f6d8d7ac
2 changed files with 7 additions and 3 deletions

View File

@ -578,7 +578,9 @@ class XMLPrinter : ASTVisitor
override void visit(const FunctionLiteralExpression functionLiteralExpression) override void visit(const FunctionLiteralExpression functionLiteralExpression)
{ {
output.writeln("<functionLiteralExpression type=\"", output.writeln("<functionLiteralExpression type=\"",
str(functionLiteralExpression.functionOrDelegate), "\">"); functionLiteralExpression.functionOrDelegate != tok!""
? str(functionLiteralExpression.functionOrDelegate)
: "auto", "\">");
functionLiteralExpression.accept(this); functionLiteralExpression.accept(this);
output.writeln("</functionLiteralExpression>"); output.writeln("</functionLiteralExpression>");
} }

View File

@ -311,10 +311,12 @@ template visitIfNotNull(fields ...)
} }
} }
mixin template OpEquals() mixin template OpEquals(bool print = false)
{ {
override bool opEquals(Object other) const override bool opEquals(Object other) const
{ {
static if (print)
pragma(msg, generateOpEquals!(typeof(this)));
mixin (generateOpEquals!(typeof(this))); mixin (generateOpEquals!(typeof(this)));
} }
} }
@ -334,7 +336,7 @@ template generateOpEquals(T)
{ {
enum opEqualsPart = "\nif (obj." ~ p[0] ~ ".length != this." ~ p[0] ~ ".length) return false;\n" enum opEqualsPart = "\nif (obj." ~ p[0] ~ ".length != this." ~ p[0] ~ ".length) return false;\n"
~ "foreach (i; 0 .. this." ~ p[0] ~ ".length)\n" ~ "foreach (i; 0 .. this." ~ p[0] ~ ".length)\n"
~ "\tif (this." ~ p[0] ~ "[i] != obj." ~ p[0] ~ "[i]) return false;"; ~ "\tif (this." ~ p[0] ~ "[i] != obj." ~ p[0] ~ "[i]) return false;" ~ opEqualsPart!(p[1 .. $]);
} }
else else
enum opEqualsPart = "\nif (obj." ~ p[0] ~ " != this." ~ p[0] ~ ") return false;" ~ opEqualsPart!(p[1 .. $]); enum opEqualsPart = "\nif (obj." ~ p[0] ~ " != this." ~ p[0] ~ ") return false;" ~ opEqualsPart!(p[1 .. $]);