comparison dmd/attrib.c @ 1602:a413ae7329bf

Merge DMD r243: some harmonization with D2 dmd --- dmd/aggregate.h | 24 ++++- dmd/attrib.c | 63 ++++++---- dmd/attrib.h | 10 +- dmd/declaration.h | 5 +- dmd/func.c | 337 ++++++++++++++++++++++------------------------------- dmd/mars.c | 2 +- dmd/mars.h | 7 + dmd/mtype.h | 13 ++- dmd/parse.c | 32 ++++- dmd/parse.h | 14 ++- dmd/scope.h | 2 +- 11 files changed, 263 insertions(+), 246 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:19 -0300
parents def7a1d494fd
children 44b145be2ef5
comparison
equal deleted inserted replaced
1601:49722e6e6e05 1602:a413ae7329bf
76 } 76 }
77 return m; 77 return m;
78 } 78 }
79 79
80 void AttribDeclaration::setScopeNewSc(Scope *sc, 80 void AttribDeclaration::setScopeNewSc(Scope *sc,
81 unsigned stc, enum LINK linkage, enum PROT protection, int explicitProtection, 81 StorageClass stc, enum LINK linkage, enum PROT protection, int explicitProtection,
82 unsigned structalign) 82 unsigned structalign)
83 { 83 {
84 if (decl) 84 if (decl)
85 { 85 {
86 Scope *newsc = sc; 86 Scope *newsc = sc;
111 } 111 }
112 } 112 }
113 } 113 }
114 114
115 void AttribDeclaration::semanticNewSc(Scope *sc, 115 void AttribDeclaration::semanticNewSc(Scope *sc,
116 unsigned stc, enum LINK linkage, enum PROT protection, int explicitProtection, 116 StorageClass stc, enum LINK linkage, enum PROT protection, int explicitProtection,
117 unsigned structalign) 117 unsigned structalign)
118 { 118 {
119 if (decl) 119 if (decl)
120 { 120 {
121 Scope *newsc = sc; 121 Scope *newsc = sc;
358 buf->writenl(); 358 buf->writenl();
359 } 359 }
360 360
361 /************************* StorageClassDeclaration ****************************/ 361 /************************* StorageClassDeclaration ****************************/
362 362
363 StorageClassDeclaration::StorageClassDeclaration(unsigned stc, Array *decl) 363 StorageClassDeclaration::StorageClassDeclaration(StorageClass stc, Array *decl)
364 : AttribDeclaration(decl) 364 : AttribDeclaration(decl)
365 { 365 {
366 this->stc = stc; 366 this->stc = stc;
367 } 367 }
368 368
377 377
378 void StorageClassDeclaration::setScope(Scope *sc) 378 void StorageClassDeclaration::setScope(Scope *sc)
379 { 379 {
380 if (decl) 380 if (decl)
381 { 381 {
382 unsigned scstc = sc->stc; 382 StorageClass scstc = sc->stc;
383 383
384 /* These sets of storage classes are mutually exclusive, 384 /* These sets of storage classes are mutually exclusive,
385 * so choose the innermost or most recent one. 385 * so choose the innermost or most recent one.
386 */ 386 */
387 if (stc & (STCauto | STCscope | STCstatic | STCextern | STCmanifest)) 387 if (stc & (STCauto | STCscope | STCstatic | STCextern | STCmanifest))
400 400
401 void StorageClassDeclaration::semantic(Scope *sc) 401 void StorageClassDeclaration::semantic(Scope *sc)
402 { 402 {
403 if (decl) 403 if (decl)
404 { 404 {
405 unsigned scstc = sc->stc; 405 StorageClass scstc = sc->stc;
406 406
407 /* These sets of storage classes are mutually exclusive, 407 /* These sets of storage classes are mutually exclusive,
408 * so choose the innermost or most recent one. 408 * so choose the innermost or most recent one.
409 */ 409 */
410 if (stc & (STCauto | STCscope | STCstatic | STCextern | STCmanifest)) 410 if (stc & (STCauto | STCscope | STCstatic | STCextern | STCmanifest))
419 419
420 semanticNewSc(sc, scstc, sc->linkage, sc->protection, sc->explicitProtection, sc->structalign); 420 semanticNewSc(sc, scstc, sc->linkage, sc->protection, sc->explicitProtection, sc->structalign);
421 } 421 }
422 } 422 }
423 423
424 void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, int stc) 424 void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, StorageClass stc)
425 { 425 {
426 struct SCstring 426 struct SCstring
427 { 427 {
428 int stc; 428 StorageClass stc;
429 enum TOK tok; 429 enum TOK tok;
430 }; 430 };
431 431
432 static SCstring table[] = 432 static SCstring table[] =
433 { 433 {
439 { STCfinal, TOKfinal }, 439 { STCfinal, TOKfinal },
440 { STCabstract, TOKabstract }, 440 { STCabstract, TOKabstract },
441 { STCsynchronized, TOKsynchronized }, 441 { STCsynchronized, TOKsynchronized },
442 { STCdeprecated, TOKdeprecated }, 442 { STCdeprecated, TOKdeprecated },
443 { STCoverride, TOKoverride }, 443 { STCoverride, TOKoverride },
444 { STClazy, TOKlazy },
445 { STCalias, TOKalias },
446 { STCout, TOKout },
447 { STCin, TOKin },
448 #if DMDV2
449 { STCimmutable, TOKimmutable },
450 { STCshared, TOKshared },
451 { STCnothrow, TOKnothrow },
452 { STCpure, TOKpure },
453 { STCref, TOKref },
454 { STCtls, TOKtls },
455 { STCgshared, TOKgshared },
456 #endif
444 }; 457 };
445 458
446 for (int i = 0; i < sizeof(table)/sizeof(table[0]); i++) 459 for (int i = 0; i < sizeof(table)/sizeof(table[0]); i++)
447 { 460 {
448 if (stc & table[i].stc) 461 if (stc & table[i].stc)
1004 d->c_ident = Lexer::idPool((char*) s->string); 1017 d->c_ident = Lexer::idPool((char*) s->string);
1005 } 1018 }
1006 goto Lnodecl; 1019 goto Lnodecl;
1007 } 1020 }
1008 #endif 1021 #endif
1022 #if DMDV2
1023 else if (ident == Id::startaddress)
1024 {
1025 if (!args || args->dim != 1)
1026 error("function name expected for start address");
1027 else
1028 {
1029 Expression *e = (Expression *)args->data[0];
1030 e = e->semantic(sc);
1031 e = e->optimize(WANTvalue | WANTinterpret);
1032 args->data[0] = (void *)e;
1033 Dsymbol *sa = getDsymbol(e);
1034 if (!sa || !sa->isFuncDeclaration())
1035 error("function name expected for start address, not '%s'", e->toChars());
1036 }
1037 goto Lnodecl;
1038 }
1039 #endif
1009 #if TARGET_NET 1040 #if TARGET_NET
1010 else if (ident == Lexer::idPool("assembly")) 1041 else if (ident == Lexer::idPool("assembly"))
1011 { 1042 {
1012 if (!args || args->dim != 1)
1013 error("pragma has invalid number of arguments");
1014 else
1015 {
1016 Expression *e = (Expression *)args->data[0];
1017 e = e->semantic(sc);
1018 e = e->optimize(WANTvalue | WANTinterpret);
1019 args->data[0] = (void *)e;
1020 if (e->op != TOKstring)
1021 {
1022 error("string expected, not '%s'", e->toChars());
1023 }
1024 PragmaScope* pragma = new PragmaScope(this, sc->parent, static_cast<StringExp*>(e));
1025 decl = new Array;
1026 decl->push(pragma);
1027 }
1028 } 1043 }
1029 #endif // TARGET_NET 1044 #endif // TARGET_NET
1030 1045
1031 // LDC 1046 // LDC
1032 #if IN_LLVM 1047 #if IN_LLVM
1383 1398
1384 buf->writestring(", "); 1399 buf->writestring(", ");
1385 e->toCBuffer(buf, hgs); 1400 e->toCBuffer(buf, hgs);
1386 } 1401 }
1387 } 1402 }
1388 buf->writestring(")"); 1403 buf->writeByte(')');
1389 AttribDeclaration::toCBuffer(buf, hgs); 1404 AttribDeclaration::toCBuffer(buf, hgs);
1390 } 1405 }
1391 1406
1392 1407
1393 /********************************* ConditionalDeclaration ****************************/ 1408 /********************************* ConditionalDeclaration ****************************/