Changeset 648:8d850fa25713
- 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
| r639 |
r648 |
|
| 1129 | 1129 | { |
|---|
| 1130 | 1130 | 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); |
|---|
| 1131 | 1137 | |
|---|
| 1132 | 1138 | // static |
|---|
| … | … | |
| 1250 | 1256 | } |
|---|
| 1251 | 1257 | } |
|---|
| | 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 | } |
|---|
| 1252 | 1274 | // unsupported declaration |
|---|
| 1253 | 1275 | else |
|---|
| r637 |
r648 |
|
| 170 | 170 | } |
|---|
| 171 | 171 | |
|---|
| | 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 | */ |
|---|
| 172 | 182 | // opaque type |
|---|
| 173 | 183 | case Topaque: |
|---|
| … | … | |
| 180 | 190 | return 0; |
|---|
| 181 | 191 | } |
|---|
| | 192 | |
|---|
| | 193 | ////////////////////////////////////////////////////////////////////////////////////////// |
|---|
| | 194 | |
|---|
| | 195 | /* |
|---|
| | 196 | const 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 | */ |
|---|
| 182 | 212 | |
|---|
| 183 | 213 | ////////////////////////////////////////////////////////////////////////////////////////// |
|---|
| r611 |
r648 |
|
| 23 | 23 | |
|---|
| 24 | 24 | unsigned 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); |
|---|
| 25 | 29 | |
|---|
| 26 | 30 | // delegate helpers |
|---|