comparison gen/toir.c @ 37:77cdca8c210f trunk

[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer. initial label/goto support.
author lindquist
date Wed, 10 Oct 2007 03:38:24 +0200
parents c0967c4b2a74
children 8b0e809563df
comparison
equal deleted inserted replaced
36:c0967c4b2a74 37:77cdca8c210f
1835 else { 1835 else {
1836 if (newtype->ty == Tclass) { 1836 if (newtype->ty == Tclass) {
1837 e->mem = new llvm::MallocInst(t->getContainedType(0),"tmp",p->scopebb()); 1837 e->mem = new llvm::MallocInst(t->getContainedType(0),"tmp",p->scopebb());
1838 } 1838 }
1839 else if (newtype->ty == Tarray) { 1839 else if (newtype->ty == Tarray) {
1840 t = LLVM_DtoType(newtype->next);
1841 assert(arguments); 1840 assert(arguments);
1842 if (arguments->dim == 1) { 1841 if (arguments->dim == 1) {
1843 elem* sz = ((Expression*)arguments->data[0])->toElem(p); 1842 elem* sz = ((Expression*)arguments->data[0])->toElem(p);
1844 llvm::Value* dimval = sz->getValue(); 1843 llvm::Value* dimval = sz->getValue();
1845 /*llvm::Value* usedimval = dimval; 1844 LLVM_DtoNewDynArray(p->toplval(), dimval, newtype->next);
1846 if (dimval->getType() != llvm::Type::Int32Ty)
1847 usedimval = new llvm::TruncInst(dimval, llvm::Type::Int32Ty,"tmp",p->scopebb());*/
1848
1849 //e->mem = LLVM_DtoRealloc(0,t);
1850 //new llvm::MallocInst(t,usedimval,"tmp",p->scopebb());
1851
1852 //LLVM_DtoSetArray(p->toplval(), dimval, e->mem);
1853
1854 LLVM_DtoNewDynArray(p->toplval(), dimval, t);
1855 delete sz; 1845 delete sz;
1856 } 1846 }
1857 else { 1847 else {
1858 assert(0); 1848 assert(0);
1859 } 1849 }
2431 STUB(AssocArrayLiteralExp); 2421 STUB(AssocArrayLiteralExp);
2432 //STUB(StructLiteralExp); 2422 //STUB(StructLiteralExp);
2433 2423
2434 unsigned Type::totym() { return 0; } 2424 unsigned Type::totym() { return 0; }
2435 2425
2436 type * 2426 type * Type::toCtype()
2437 Type::toCtype() { 2427 {
2428 assert(0);
2438 return 0; 2429 return 0;
2439 } 2430 }
2440 2431
2441 type * Type::toCParamtype() 2432 type * Type::toCParamtype()
2442 { 2433 {
2434 assert(0);
2443 return 0; 2435 return 0;
2444 } 2436 }
2445 Symbol * Type::toSymbol() 2437 Symbol * Type::toSymbol()
2446 { 2438 {
2439 assert(0);
2447 return 0; 2440 return 0;
2448 } 2441 }
2449 2442
2450 type * 2443 type *
2451 TypeTypedef::toCtype() 2444 TypeTypedef::toCtype()
2452 { 2445 {
2446 assert(0);
2453 return 0; 2447 return 0;
2454 } 2448 }
2455 2449
2456 type * 2450 type *
2457 TypeTypedef::toCParamtype() 2451 TypeTypedef::toCParamtype()
2458 { 2452 {
2453 assert(0);
2459 return 0; 2454 return 0;
2460 } 2455 }
2461 2456
2462 void 2457 void
2463 TypedefDeclaration::toDebug() 2458 TypedefDeclaration::toDebug()
2464 { 2459 {
2460 assert(0);
2465 } 2461 }
2466 2462
2467 2463
2468 type * 2464 type *
2469 TypeEnum::toCtype() 2465 TypeEnum::toCtype()
2470 { 2466 {
2467 assert(0);
2471 return 0; 2468 return 0;
2472 } 2469 }
2473 2470
2474 type * 2471 type *
2475 TypeStruct::toCtype() 2472 TypeStruct::toCtype()
2476 { 2473 {
2474 assert(0);
2477 return 0; 2475 return 0;
2478 } 2476 }
2479 2477
2480 void 2478 void
2481 StructDeclaration::toDebug() 2479 StructDeclaration::toDebug()
2482 { 2480 {
2481 assert(0);
2483 } 2482 }
2484 2483
2485 Symbol * TypeClass::toSymbol() 2484 Symbol * TypeClass::toSymbol()
2486 { 2485 {
2486 assert(0);
2487 return 0; 2487 return 0;
2488 } 2488 }
2489 2489
2490 unsigned TypeFunction::totym() 2490 unsigned TypeFunction::totym()
2491 { 2491 {
2492 assert(0);
2492 return 0; 2493 return 0;
2493 } 2494 }
2494 2495
2495 type * 2496 type * TypeFunction::toCtype()
2496 TypeFunction::toCtype() 2497 {
2497 { 2498 assert(0);
2498 return 0; 2499 return 0;
2499 } 2500 }
2500 2501
2501 type * 2502 type * TypeSArray::toCtype()
2502 TypeSArray::toCtype() 2503 {
2503 { 2504 assert(0);
2504 return 0; 2505 return 0;
2505 } 2506 }
2506 2507
2507 type *TypeSArray::toCParamtype() { return 0; } 2508 type *TypeSArray::toCParamtype()
2508 2509 {
2509 type * 2510 assert(0);
2510 TypeDArray::toCtype()
2511 {
2512 return 0; 2511 return 0;
2513 } 2512 }
2514 2513
2515 type * 2514 type * TypeDArray::toCtype()
2516 TypeAArray::toCtype() 2515 {
2517 { 2516 assert(0);
2518 return 0; 2517 return 0;
2519 } 2518 }
2520 2519
2521 type * 2520 type * TypeAArray::toCtype()
2522 TypePointer::toCtype() 2521 {
2523 { 2522 assert(0);
2524 return 0; 2523 return 0;
2525 } 2524 }
2526 2525
2527 type * 2526 type * TypePointer::toCtype()
2528 TypeDelegate::toCtype() 2527 {
2529 { 2528 assert(0);
2530 return 0; 2529 return 0;
2531 } 2530 }
2532 2531
2533 type * 2532 type * TypeDelegate::toCtype()
2534 TypeClass::toCtype() 2533 {
2535 { 2534 assert(0);
2536 return 0; 2535 return 0;
2537 } 2536 }
2538 2537
2539 void 2538 type * TypeClass::toCtype()
2540 ClassDeclaration::toDebug() 2539 {
2541 { 2540 assert(0);
2541 return 0;
2542 }
2543
2544 void ClassDeclaration::toDebug()
2545 {
2546 assert(0);
2542 } 2547 }
2543 2548
2544 ////////////////////////////////////////////////////////////////////////////// 2549 //////////////////////////////////////////////////////////////////////////////
2545 2550
2546 void 2551 void
2547 EnumDeclaration::toDebug() 2552 EnumDeclaration::toDebug()
2548 { 2553 {
2549 2554 assert(0);
2550 } 2555 }
2551 2556
2552 int 2557 int Dsymbol::cvMember(unsigned char*)
2553 Dsymbol::cvMember(unsigned char*) 2558 {
2554 { 2559 assert(0);
2555 return 0; 2560 return 0;
2556 } 2561 }
2557 int 2562 int EnumDeclaration::cvMember(unsigned char*)
2558 EnumDeclaration::cvMember(unsigned char*) 2563 {
2559 { 2564 assert(0);
2560 return 0; 2565 return 0;
2561 } 2566 }
2562 int 2567 int FuncDeclaration::cvMember(unsigned char*)
2563 FuncDeclaration::cvMember(unsigned char*) 2568 {
2564 { 2569 assert(0);
2565 return 0; 2570 return 0;
2566 } 2571 }
2567 int 2572 int VarDeclaration::cvMember(unsigned char*)
2568 VarDeclaration::cvMember(unsigned char*) 2573 {
2569 { 2574 assert(0);
2570 return 0; 2575 return 0;
2571 } 2576 }
2572 int 2577 int TypedefDeclaration::cvMember(unsigned char*)
2573 TypedefDeclaration::cvMember(unsigned char*) 2578 {
2574 { 2579 assert(0);
2575 return 0; 2580 return 0;
2576 } 2581 }
2577 2582
2578 void obj_includelib(char*){} 2583 void obj_includelib(char*){}
2579 2584
2580 AsmStatement::AsmStatement(Loc loc, Token *tokens) : 2585 AsmStatement::AsmStatement(Loc loc, Token *tokens) :
2581 Statement(loc) 2586 Statement(loc)
2582 { 2587 {
2583 } 2588 assert(0);
2584 Statement *AsmStatement::syntaxCopy() { 2589 }
2590 Statement *AsmStatement::syntaxCopy()
2591 {
2592 assert(0);
2585 return 0; 2593 return 0;
2586 } 2594 }
2587 2595
2588 Statement *AsmStatement::semantic(Scope *sc) 2596 Statement *AsmStatement::semantic(Scope *sc)
2589 { 2597 {
2596 Statement::toCBuffer(buf, hgs); 2604 Statement::toCBuffer(buf, hgs);
2597 } 2605 }
2598 2606
2599 int AsmStatement::comeFrom() 2607 int AsmStatement::comeFrom()
2600 { 2608 {
2609 assert(0);
2601 return FALSE; 2610 return FALSE;
2602 } 2611 }
2603 2612
2604 void 2613 void
2605 backend_init() 2614 backend_init()
2606 { 2615 {
2616 // now lazily loaded
2607 //LLVM_D_InitRuntime(); 2617 //LLVM_D_InitRuntime();
2608 // lazily loaded
2609 } 2618 }
2610 2619
2611 void 2620 void
2612 backend_term() 2621 backend_term()
2613 { 2622 {