From 4c788699aef85965273402d082ecfc9ef84ebb05 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Wed, 12 Jun 2013 18:10:17 +0200 Subject: [PATCH] Initial, incomplete ClassReferenceExp::toConstElem implementation. Allows us to get through a Phobos build without errors. --- dmd2/ctfe.h | 1 + gen/toir.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dmd2/ctfe.h b/dmd2/ctfe.h index 0244a37b..7dc157c3 100644 --- a/dmd2/ctfe.h +++ b/dmd2/ctfe.h @@ -55,6 +55,7 @@ struct ClassReferenceExp : Expression /// Same as getFieldIndex, but checks for a direct match with the VarDeclaration int findFieldIndexByName(VarDeclaration *v); #if IN_LLVM + llvm::Constant* toConstElem(IRState *irs); #else dt_t **toDt(dt_t **pdt); dt_t **toDtI(dt_t **pdt, int offset); diff --git a/gen/toir.cpp b/gen/toir.cpp index defd63f7..d66b5894 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -43,6 +43,9 @@ #include #include +// Needs other includes. +#include "ctfe.h" + llvm::cl::opt checkPrintf("check-printf-calls", llvm::cl::desc("Validate printf call format strings against arguments"), llvm::cl::ZeroOrMore); @@ -2824,7 +2827,7 @@ static LLValue* write_zeroes(LLValue* mem, unsigned start, unsigned end) { DValue* StructLiteralExp::toElem(IRState* p) { - Logger::print("StructLiteralExp::toElem: %s @ %s\n", toChars(), type->toChars()); + IF_LOG Logger::print("StructLiteralExp::toElem: %s @ %s\n", toChars(), type->toChars()); LOG_SCOPE; if (sinit) @@ -2933,7 +2936,9 @@ DValue* StructLiteralExp::toElem(IRState* p) LLConstant* StructLiteralExp::toConstElem(IRState* p) { - Logger::print("StructLiteralExp::toConstElem: %s @ %s\n", toChars(), type->toChars()); + // type can legitimately be null for ClassReferenceExp::value. + IF_LOG Logger::print("StructLiteralExp::toConstElem: %s @ %s\n", + toChars(), type ? type->toChars() : "(null)"); LOG_SCOPE; if (sinit) @@ -2965,6 +2970,16 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p) return sd->ir.irStruct->createInitializerConstant(varInits); } +llvm::Constant* ClassReferenceExp::toConstElem(IRState *p) +{ + IF_LOG Logger::print("ClassReferenceExp::toConstElem: %s @ %s\n", + toChars(), type->toChars()); + LOG_SCOPE; + + // FIXME: Handle type->sym->isInterfaceDeclaration(). + return value->toConstElem(p); +} + ////////////////////////////////////////////////////////////////////////////////////////// DValue* InExp::toElem(IRState* p)