comparison gen/toir.cpp @ 469:d0dad1fe0f45

Fixed constant expression taking address of function.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 04 Aug 2008 03:38:23 +0200
parents 45a67b6f1310
children 672eb4893b55
comparison
equal deleted inserted replaced
468:45a67b6f1310 469:d0dad1fe0f45
841 841
842 LLConstant* AddrExp::toConstElem(IRState* p) 842 LLConstant* AddrExp::toConstElem(IRState* p)
843 { 843 {
844 assert(e1->op == TOKvar); 844 assert(e1->op == TOKvar);
845 VarExp* vexp = (VarExp*)e1; 845 VarExp* vexp = (VarExp*)e1;
846 VarDeclaration* vd = vexp->var->isVarDeclaration(); 846
847 assert(vd); 847 // global variable
848 LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue()); 848 if (VarDeclaration* vd = vexp->var->isVarDeclaration())
849 assert(llc); 849 {
850 return llc; 850 LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue());
851 assert(llc);
852 return llc;
853 }
854 // static function
855 else if (FuncDeclaration* fd = vexp->var->isFuncDeclaration())
856 {
857 IrFunction* irfunc = fd->ir.irFunc;
858 assert(irfunc);
859 return irfunc->func;
860 }
861 // not yet supported
862 else
863 {
864 error("constant expression '%s' not yet implemented", toChars());
865 fatal();
866 }
851 } 867 }
852 868
853 ////////////////////////////////////////////////////////////////////////////////////////// 869 //////////////////////////////////////////////////////////////////////////////////////////
854 870
855 DValue* PtrExp::toElem(IRState* p) 871 DValue* PtrExp::toElem(IRState* p)