From dc8c5f39d73ae4e18ec0602191eac6c29d3e59b9 Mon Sep 17 00:00:00 2001 From: Daniel Murphy Date: Sun, 19 Jan 2014 04:28:04 +1100 Subject: [PATCH] Remove Expression::dump and replace usages with Expression::print --- src/cast.c | 6 +- src/declaration.c | 3 +- src/dump.c | 152 ---------------------------------------------- src/e2ir.c | 6 +- src/expression.c | 10 +-- src/expression.h | 13 ---- src/inline.c | 4 +- src/interpret.c | 2 +- src/posix.mak | 8 +-- src/statement.c | 1 - src/todt.c | 2 +- src/traits.c | 2 +- src/win32.mak | 4 +- 13 files changed, 21 insertions(+), 192 deletions(-) delete mode 100644 src/dump.c diff --git a/src/cast.c b/src/cast.c index bc4c4c7d88d4..872f0733793d 100644 --- a/src/cast.c +++ b/src/cast.c @@ -2163,7 +2163,7 @@ bool isVoidArrayLiteral(Expression *e, Type *other) int typeMerge(Scope *sc, Expression *e, Type **pt, Expression **pe1, Expression **pe2) { //printf("typeMerge() %s op %s\n", (*pe1)->toChars(), (*pe2)->toChars()); - //e->dump(0); + //e->print(); MATCH m; Expression *e1 = *pe1; @@ -2230,7 +2230,7 @@ int typeMerge(Scope *sc, Expression *e, Type **pt, Expression **pe1, Expression e1 = e1->castTo(sc, t1); e2 = e2->castTo(sc, t2); //printf("after typeCombine():\n"); - //dump(0); + //print(); //printf("ty = %d, ty1 = %d, ty2 = %d\n", ty, ty1, ty2); goto Lret; } @@ -2726,7 +2726,7 @@ int typeMerge(Scope *sc, Expression *e, Type **pt, Expression **pe1, Expression if (e2->type) printf("\tt2 = %s\n", e2->type->toChars()); printf("\ttype = %s\n", t->toChars()); #endif - //dump(0); + //print(); return 1; diff --git a/src/declaration.c b/src/declaration.c index f9fbc45e1306..80c78deafdad 100644 --- a/src/declaration.c +++ b/src/declaration.c @@ -764,7 +764,6 @@ Dsymbol *VarDeclaration::syntaxCopy(Dsymbol *s) if (this->init) { init = this->init->syntaxCopy(); //init->isExpInitializer()->exp->print(); - //init->isExpInitializer()->exp->dump(0); } sv = new VarDeclaration(loc, type ? type->syntaxCopy() : NULL, ident, init); @@ -1573,7 +1572,7 @@ void VarDeclaration::semantic2(Scope *sc) ExpInitializer *ei = init->isExpInitializer(); if (ei) { - ei->exp->dump(0); + ei->exp->print(); printf("type = %p\n", ei->exp->type); } #endif diff --git a/src/dump.c b/src/dump.c deleted file mode 100644 index e0d431863bca..000000000000 --- a/src/dump.c +++ /dev/null @@ -1,152 +0,0 @@ - -// Compiler implementation of the D programming language -// Copyright (c) 1999-2012 by Digital Mars -// All Rights Reserved -// written by Walter Bright -// http://www.digitalmars.com -// License for redistribution is by either the Artistic License -// in artistic.txt, or the GNU General Public License in gnu.txt. -// See the included readme.txt for details. - -#include -#include -#include - -#include "mars.h" -#include "mtype.h" -#include "declaration.h" -#include "expression.h" -#include "template.h" - -static void indent(int indent) -{ - int i; - - for (i = 0; i < indent; i++) - printf(" "); -} - -static char *type_print(Type *type) -{ - return type ? type->toChars() : (char *) "null"; -} - -void dumpExpressions(int i, Expressions *exps) -{ - if (exps) - { - for (size_t j = 0; j < exps->dim; j++) - { Expression *e = (*exps)[j]; - indent(i); - printf("(\n"); - e->dump(i + 2); - indent(i); - printf(")\n"); - } - } -} - -void Expression::dump(int i) -{ - indent(i); - printf("%p %s type=%s\n", this, Token::toChars(op), type_print(type)); -} - -void IntegerExp::dump(int i) -{ - indent(i); - printf("%p %lld type=%s\n", this, (ulonglong)value, type_print(type)); -} - -void IdentifierExp::dump(int i) -{ - indent(i); - printf("%p ident '%s' type=%s\n", this, ident->toChars(), type_print(type)); -} - -void DsymbolExp::dump(int i) -{ - indent(i); - printf("%p %s type=%s\n", this, s->toChars(), type_print(type)); -} - -void VarExp::dump(int i) -{ - indent(i); - printf("%p %s var=%s type=%s\n", this, Token::toChars(op), var->toChars(), type_print(type)); -} - -void UnaExp::dump(int i) -{ - indent(i); - printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1); - if (e1) - e1->dump(i + 2); -} - -void CallExp::dump(int i) -{ - UnaExp::dump(i); - dumpExpressions(i, arguments); -} - -void SliceExp::dump(int i) -{ - indent(i); - printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1); - if (e1) - e1->dump(i + 2); - if (lwr) - lwr->dump(i + 2); - if (upr) - upr->dump(i + 2); -} - -void DotIdExp::dump(int i) -{ - indent(i); - printf("%p %s type=%s ident=%s e1=%p\n", this, Token::toChars(op), type_print(type), ident->toChars(), e1); - if (e1) - e1->dump(i + 2); -} - -void DotVarExp::dump(int i) -{ - indent(i); - printf("%p %s type=%s var='%s' e1=%p\n", this, Token::toChars(op), type_print(type), var->toChars(), e1); - if (e1) - e1->dump(i + 2); -} - -void DotTemplateInstanceExp::dump(int i) -{ - indent(i); - printf("%p %s type=%s ti='%s' e1=%p\n", this, Token::toChars(op), type_print(type), ti->toChars(), e1); - if (e1) - e1->dump(i + 2); -} - -void DelegateExp::dump(int i) -{ - indent(i); - printf("%p %s func=%s type=%s e1=%p\n", this, Token::toChars(op), func->toChars(), type_print(type), e1); - if (e1) - e1->dump(i + 2); -} - -void BinExp::dump(int i) -{ - indent(i); - const char *sop = Token::toChars(op); - if (op == TOKblit) - sop = "blit"; - else if (op == TOKconstruct) - sop = "construct"; - printf("%p %s type=%s e1=%p e2=%p\n", this, sop, type_print(type), e1, e2); - if (e1) - e1->dump(i + 2); - if (e2) - e2->dump(i + 2); -} - - diff --git a/src/e2ir.c b/src/e2ir.c index 0188994e375f..60a59717e254 100644 --- a/src/e2ir.c +++ b/src/e2ir.c @@ -2267,7 +2267,7 @@ elem *CmpExp::toElem(IRState *irs) case TOKug: eop = OPug; break; case TOKue: eop = OPue; break; default: - dump(0); + print(); assert(0); } if (!t1->isfloating()) @@ -2338,7 +2338,7 @@ elem *EqualExp::toElem(IRState *irs) case TOKequal: eop = OPeqeq; break; case TOKnotequal: eop = OPne; break; default: - dump(0); + print(); assert(0); } @@ -2477,7 +2477,7 @@ elem *IdentityExp::toElem(IRState *irs) case TOKidentity: eop = OPeqeq; break; case TOKnotidentity: eop = OPne; break; default: - dump(0); + print(); assert(0); } diff --git a/src/expression.c b/src/expression.c index c1ef11d91c13..580027ec97e0 100644 --- a/src/expression.c +++ b/src/expression.c @@ -1826,7 +1826,7 @@ void expToCBuffer(OutBuffer *buf, HdrGenState *hgs, Expression *e, PREC pr) assert(precedence[e->op] != PREC_zero); assert(pr != PREC_zero); - //if (precedence[e->op] == 0) e->dump(0); + //if (precedence[e->op] == 0) e->print(); if (precedence[e->op] < pr || /* Despite precedence, we don't allow adump(0); + //e->print(); ICS2 ics2; ics2.cost = 0; ics2.ics = ics; @@ -1839,7 +1839,7 @@ Expression *FuncDeclaration::expandInline(InlineScanState *iss, inlineNest--; //eb->type->print(); //eb->print(); - //eb->dump(0); + //eb->print(); // Bugzilla 11322: if (tf->isref) diff --git a/src/interpret.c b/src/interpret.c index 268dd3f23eaf..b214d87f667f 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -2025,7 +2025,7 @@ Expression *Expression::interpret(InterState *istate, CtfeGoal goal) #if LOG printf("%s Expression::interpret() %s\n", loc.toChars(), toChars()); printf("type = %s\n", type->toChars()); - dump(0); + print(); #endif error("Cannot interpret %s at compile time", toChars()); return EXP_CANT_INTERPRET; diff --git a/src/posix.mak b/src/posix.mak index bc01cd177ce6..bbe6090c2c5d 100644 --- a/src/posix.mak +++ b/src/posix.mak @@ -58,7 +58,7 @@ DMD_OBJS = \ cast.o \ class.o \ constfold.o cond.o \ - declaration.o dsymbol.o dump.o \ + declaration.o dsymbol.o \ enum.o expression.o func.o \ id.o \ identifier.o impcnvtab.o import.o inifile.o init.o inline.o \ @@ -115,7 +115,7 @@ SRC = win32.mak posix.mak osmodel.mak \ identifier.c mtype.c expression.c optimize.c template.h \ template.c lexer.c declaration.c cast.c cond.h cond.c link.c \ aggregate.h parse.c statement.c constfold.c version.h version.c \ - inifile.c module.c scope.c dump.c init.h init.c attrib.h \ + inifile.c module.c scope.c init.h init.c attrib.h \ attrib.c opover.c class.c mangle.c func.c inline.c \ access.c complex_t.h \ identifier.h parse.h \ @@ -399,9 +399,6 @@ dsymbol.o: dsymbol.c dt.o: $C/dt.c $(CC) -c $(MFLAGS) $< -dump.o: dump.c - $(CC) -c $(CFLAGS) $< - dwarf.o: $C/dwarf.c $(CC) -c $(MFLAGS) -I. $< @@ -721,7 +718,6 @@ gcov: gcov delegatize.c gcov doc.c gcov dsymbol.c - gcov dump.c gcov e2ir.c gcov eh.c gcov entity.c diff --git a/src/statement.c b/src/statement.c index 52fd96a18b13..5324aefecfc0 100644 --- a/src/statement.c +++ b/src/statement.c @@ -3966,7 +3966,6 @@ Statement *ReturnStatement::semantic(Scope *sc) } else { - //exp->dump(0); //exp->print(); exp->checkEscape(); } diff --git a/src/todt.c b/src/todt.c index cf3fe7eca4cc..cda5e6a9f44b 100644 --- a/src/todt.c +++ b/src/todt.c @@ -178,7 +178,7 @@ dt_t **Expression::toDt(dt_t **pdt) { #if 0 printf("Expression::toDt() %d\n", op); - dump(0); + print(); #endif error("non-constant expression %s", toChars()); pdt = dtnzeros(pdt, 1); diff --git a/src/traits.c b/src/traits.c index beeaa15a3607..0974b325cc39 100644 --- a/src/traits.c +++ b/src/traits.c @@ -493,7 +493,7 @@ Expression *TraitsExp::semantic(Scope *sc) /* Create tuple of functions of e */ - //e->dump(0); + //e->print(); Expressions *exps = new Expressions(); FuncDeclaration *f; if (e->op == TOKvar) diff --git a/src/win32.mak b/src/win32.mak index 43af14a771d2..f306657946bd 100644 --- a/src/win32.mak +++ b/src/win32.mak @@ -143,7 +143,7 @@ FRONTOBJ= enum.obj struct.obj dsymbol.obj import.obj id.obj \ optimize.obj template.obj lexer.obj declaration.obj cast.obj \ init.obj func.obj utf.obj parse.obj statement.obj \ constfold.obj version.obj inifile.obj cppmangle.obj \ - module.obj scope.obj dump.obj cond.obj inline.obj opover.obj \ + module.obj scope.obj cond.obj inline.obj opover.obj \ entity.obj class.obj mangle.obj attrib.obj impcnvtab.obj \ link.obj access.obj doc.obj macro.obj hdrgen.obj delegatize.obj \ interpret.obj ctfeexpr.obj traits.obj aliasthis.obj \ @@ -187,7 +187,7 @@ SRCS= mars.c enum.c struct.c dsymbol.c import.c idgen.c impcnvgen.c utf.h \ template.h template.c lexer.c declaration.c cast.c \ cond.h cond.c link.c aggregate.h staticassert.h parse.c statement.c \ constfold.c version.h version.c inifile.c staticassert.c \ - module.c scope.c dump.c init.h init.c attrib.h attrib.c opover.c \ + module.c scope.c init.h init.c attrib.h attrib.c opover.c \ class.c mangle.c func.c inline.c access.c complex_t.h cppmangle.c \ identifier.h parse.h scope.h enum.h import.h \ mars.h module.h mtype.h dsymbol.h \