comparison gen/functions.cpp @ 1228:79758fd2f48a

Added Doxygen file. Completely seperated type and symbol generation. Should fix a lot of bugs, but is not yet 100% complete.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Wed, 15 Apr 2009 20:06:25 +0200
parents 8699c450a1a0
children 79c6c8bc866c
comparison
equal deleted inserted replaced
1215:08f87d8cd101 1228:79758fd2f48a
199 } 199 }
200 200
201 llvm::FunctionType* functype = llvm::FunctionType::get(f->fty.ret->ltype, argtypes, f->fty.c_vararg); 201 llvm::FunctionType* functype = llvm::FunctionType::get(f->fty.ret->ltype, argtypes, f->fty.c_vararg);
202 f->ir.type = new llvm::PATypeHolder(functype); 202 f->ir.type = new llvm::PATypeHolder(functype);
203 203
204 #if 0
204 Logger::cout() << "Final function type: " << *functype << "\n"; 205 Logger::cout() << "Final function type: " << *functype << "\n";
206 #endif
205 207
206 return functype; 208 return functype;
207 } 209 }
208 210
209 ////////////////////////////////////////////////////////////////////////////////////////// 211 //////////////////////////////////////////////////////////////////////////////////////////
300 void DtoResolveFunction(FuncDeclaration* fdecl) 302 void DtoResolveFunction(FuncDeclaration* fdecl)
301 { 303 {
302 if (!global.params.useUnitTests && fdecl->isUnitTestDeclaration()) { 304 if (!global.params.useUnitTests && fdecl->isUnitTestDeclaration()) {
303 Logger::println("Ignoring unittest %s", fdecl->toPrettyChars()); 305 Logger::println("Ignoring unittest %s", fdecl->toPrettyChars());
304 return; // ignore declaration completely 306 return; // ignore declaration completely
305 }
306
307 if (AggregateDeclaration* ad = fdecl->isMember())
308 {
309 ad->codegen(Type::sir);
310 if (ad->isStructDeclaration() && llvm::isa<llvm::OpaqueType>(DtoType(ad->type)))
311 {
312 ad->ir.irStruct->structFuncs.push_back(fdecl);
313 return;
314 }
315 } 307 }
316 308
317 //printf("resolve function: %s\n", fdecl->toPrettyChars()); 309 //printf("resolve function: %s\n", fdecl->toPrettyChars());
318 310
319 if (fdecl->parent) 311 if (fdecl->parent)
370 LOG_SCOPE; 362 LOG_SCOPE;
371 363
372 // queue declaration unless the function is abstract without body 364 // queue declaration unless the function is abstract without body
373 if (!fdecl->isAbstract() || fdecl->fbody) 365 if (!fdecl->isAbstract() || fdecl->fbody)
374 { 366 {
375 Logger::println("Ignoring declaration of abstract bodyless function %s", fdecl->toPrettyChars());
376 DtoDeclareFunction(fdecl); 367 DtoDeclareFunction(fdecl);
377 } 368 }
378 } 369 }
379 370
380 ////////////////////////////////////////////////////////////////////////////////////////// 371 //////////////////////////////////////////////////////////////////////////////////////////
462 } 453 }
463 454
464 // get TypeFunction* 455 // get TypeFunction*
465 Type* t = fdecl->type->toBasetype(); 456 Type* t = fdecl->type->toBasetype();
466 TypeFunction* f = (TypeFunction*)t; 457 TypeFunction* f = (TypeFunction*)t;
458
459 // sanity check
460 assert(fdecl == f->funcdecl && "the function type does not point to this function");
467 461
468 bool declareOnly = !mustDefineSymbol(fdecl); 462 bool declareOnly = !mustDefineSymbol(fdecl);
469 463
470 if (fdecl->llvmInternal == LLVMva_start) 464 if (fdecl->llvmInternal == LLVMva_start)
471 declareOnly = true; 465 declareOnly = true;