Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 648:8d850fa25713

Show
Ignore:
Timestamp:
10/05/08 05:47:47 (3 months ago)
Author:
Christian Kamm <kamm incasoftware de>
branch:
default
Message:

Fix VarDecls? for tuples. Closes #99.

I've implemented it this way since it doesn't require any changes in the
frontend. However, I think having TypeTuple? expressed as LLVM struct types
would make much more sense and open the door to tuple lvalues.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gen/llvmhelpers.cpp

    r639 r648  
    11291129    { 
    11301130        Logger::println("VarDeclaration"); 
     1131 
     1132        // if aliassym is set, this VarDecl is redone as an alias to another symbol 
     1133        // this seems to be done to rewrite Tuple!(...) v; 
     1134        // as a TupleDecl that contains a bunch of individual VarDecls 
     1135        if (vd->aliassym) 
     1136            return DtoDeclarationExp(vd->aliassym); 
    11311137 
    11321138        // static 
     
    12501256        } 
    12511257    } 
     1258    // tuple declaration 
     1259    else if (TupleDeclaration* tupled = declaration->isTupleDeclaration()) 
     1260    { 
     1261        Logger::println("TupleDeclaration"); 
     1262        if(!tupled->isexp) { 
     1263            error(declaration->loc, "don't know how to handle non-expression tuple decls yet"); 
     1264            assert(0); 
     1265        } 
     1266 
     1267        assert(tupled->objects); 
     1268        for (int i=0; i < tupled->objects->dim; ++i) 
     1269        { 
     1270            DsymbolExp* exp = (DsymbolExp*)tupled->objects->data[i]; 
     1271            DtoDeclarationExp(exp->s); 
     1272        } 
     1273    } 
    12521274    // unsupported declaration 
    12531275    else 
  • gen/tollvm.cpp

    r637 r648  
    170170    } 
    171171 
     172/* 
     173    Not needed atm as VarDecls for tuples are rewritten as a string of  
     174    VarDecls for the fields (u -> _u_field_0, ...) 
     175 
     176    case Ttuple: 
     177    { 
     178        TypeTuple* ttupl = (TypeTuple*)t; 
     179        return DtoStructTypeFromArguments(ttupl->arguments); 
     180    } 
     181*/ 
    172182    // opaque type 
    173183    case Topaque: 
     
    180190    return 0; 
    181191} 
     192 
     193////////////////////////////////////////////////////////////////////////////////////////// 
     194 
     195/* 
     196const LLType* DtoStructTypeFromArguments(Arguments* arguments) 
     197{ 
     198    if (!arguments) 
     199        return LLType::VoidTy; 
     200 
     201    std::vector<const LLType*> types; 
     202    for (size_t i = 0; i < arguments->dim; i++) 
     203    { 
     204        Argument *arg = (Argument *)arguments->data[i]; 
     205        assert(arg && arg->type); 
     206 
     207        types.push_back(DtoType(arg->type)); 
     208    } 
     209    return LLStructType::get(types); 
     210} 
     211*/ 
    182212 
    183213////////////////////////////////////////////////////////////////////////////////////////// 
  • gen/tollvm.h

    r611 r648  
    2323 
    2424unsigned DtoShouldExtend(Type* type); 
     25 
     26// tuple helper 
     27// takes a arguments list and makes a struct type out of them 
     28//const LLType* DtoStructTypeFromArguments(Arguments* arguments); 
    2529 
    2630// delegate helpers 
Copyright © 2008, LDC Development Team.