Changeset 183
- Timestamp:
- 07/03/09 03:32:24 (4 years ago)
- Files:
-
- trunk/src/access.c (modified) (1 diff)
- trunk/src/aggregate.h (modified) (4 diffs)
- trunk/src/arrayop.c (modified) (1 diff)
- trunk/src/attrib.c (modified) (1 diff)
- trunk/src/backend (added)
- trunk/src/backend/aa.c (added)
- trunk/src/backend/aa.h (added)
- trunk/src/backend/bcomplex.c (added)
- trunk/src/backend/bcomplex.h (added)
- trunk/src/backend/blockopt.c (added)
- trunk/src/backend/cc.h (added)
- trunk/src/backend/cdef.h (added)
- trunk/src/backend/cdeflnx.h (added)
- trunk/src/backend/cg.c (added)
- trunk/src/backend/cg87.c (added)
- trunk/src/backend/cgcod.c (added)
- trunk/src/backend/cgcs.c (added)
- trunk/src/backend/cgcv.c (added)
- trunk/src/backend/cgcv.h (added)
- trunk/src/backend/cgelem.c (added)
- trunk/src/backend/cgen.c (added)
- trunk/src/backend/cgobj.c (added)
- trunk/src/backend/cgreg.c (added)
- trunk/src/backend/cgsched.c (added)
- trunk/src/backend/cod1.c (added)
- trunk/src/backend/cod2.c (added)
- trunk/src/backend/cod3.c (added)
- trunk/src/backend/cod4.c (added)
- trunk/src/backend/cod5.c (added)
- trunk/src/backend/code.c (added)
- trunk/src/backend/code.h (added)
- trunk/src/backend/cpp.h (added)
- trunk/src/backend/cppman.c (added)
- trunk/src/backend/cv4.h (added)
- trunk/src/backend/debug.c (added)
- trunk/src/backend/dt.c (added)
- trunk/src/backend/dt.h (added)
- trunk/src/backend/dwarf.c (added)
- trunk/src/backend/dwarf.h (added)
- trunk/src/backend/dwarf2.h (added)
- trunk/src/backend/ee.c (added)
- trunk/src/backend/el.c (added)
- trunk/src/backend/el.h (added)
- trunk/src/backend/elfobj.c (moved) (moved from trunk/src/elfobj.c) (4 diffs)
- trunk/src/backend/evalu8.c (added)
- trunk/src/backend/exh.h (added)
- trunk/src/backend/gdag.c (added)
- trunk/src/backend/gflow.c (added)
- trunk/src/backend/global.h (added)
- trunk/src/backend/glocal.c (added)
- trunk/src/backend/gloop.c (added)
- trunk/src/backend/go.c (added)
- trunk/src/backend/go.h (added)
- trunk/src/backend/gother.c (added)
- trunk/src/backend/html.c (moved) (moved from trunk/src/html.c) (10 diffs)
- trunk/src/backend/html.h (moved) (moved from trunk/src/html.h) (4 diffs)
- trunk/src/backend/iasm.h (added)
- trunk/src/backend/mach.h (added)
- trunk/src/backend/machobj.c (moved) (moved from trunk/src/machobj.c) (3 diffs)
- trunk/src/backend/md5.c (moved) (moved from trunk/src/md5.c)
- trunk/src/backend/md5.h (moved) (moved from trunk/src/md5.h)
- trunk/src/backend/melf.h (added)
- trunk/src/backend/newman.c (added)
- trunk/src/backend/nteh.c (added)
- trunk/src/backend/oper.h (added)
- trunk/src/backend/optabgen.c (added)
- trunk/src/backend/os.c (added)
- trunk/src/backend/out.c (added)
- trunk/src/backend/outbuf.c (added)
- trunk/src/backend/outbuf.h (added)
- trunk/src/backend/parser.h (added)
- trunk/src/backend/ptrntab.c (added)
- trunk/src/backend/rtlsym.c (added)
- trunk/src/backend/rtlsym.h (added)
- trunk/src/backend/strtold.c (added)
- trunk/src/backend/symbol.c (added)
- trunk/src/backend/tassert.h (added)
- trunk/src/backend/ti_achar.c (added)
- trunk/src/backend/tinfo.h (added)
- trunk/src/backend/token.h (added)
- trunk/src/backend/ty.h (added)
- trunk/src/backend/type.c (added)
- trunk/src/backend/type.h (added)
- trunk/src/backend/var.c (added)
- trunk/src/backendlicense.txt (added)
- trunk/src/builtin.c (modified) (6 diffs)
- trunk/src/cast.c (modified) (3 diffs)
- trunk/src/class.c (modified) (6 diffs)
- trunk/src/clone.c (modified) (3 diffs)
- trunk/src/constfold.c (modified) (1 diff)
- trunk/src/cppmangle.c (added)
- trunk/src/declaration.c (modified) (4 diffs)
- trunk/src/declaration.h (modified) (1 diff)
- trunk/src/doc.c (modified) (1 diff)
- trunk/src/dsymbol.c (modified) (7 diffs)
- trunk/src/dsymbol.h (modified) (2 diffs)
- trunk/src/e2ir.c (modified) (14 diffs)
- trunk/src/eh.c (added)
- trunk/src/expression.c (modified) (16 diffs)
- trunk/src/expression.h (modified) (1 diff)
- trunk/src/func.c (modified) (3 diffs)
- trunk/src/glue.c (added)
- trunk/src/hdrgen.c (modified) (1 diff)
- trunk/src/iasm.c (added)
- trunk/src/inifile.c (modified) (2 diffs)
- trunk/src/interpret.c (modified) (1 diff)
- trunk/src/lexer.c (modified) (3 diffs)
- trunk/src/libelf.c (modified) (1 diff)
- trunk/src/libmach.c (modified) (1 diff)
- trunk/src/libomf.c (added)
- trunk/src/link.c (modified) (1 diff)
- trunk/src/linux.mak (added)
- trunk/src/macro.c (modified) (1 diff)
- trunk/src/mars.c (modified) (7 diffs)
- trunk/src/mars.h (modified) (1 diff)
- trunk/src/module.c (modified) (4 diffs)
- trunk/src/module.h (modified) (1 diff)
- trunk/src/msc.c (added)
- trunk/src/mtype.c (modified) (8 diffs)
- trunk/src/mtype.h (modified) (2 diffs)
- trunk/src/objfile.h (added)
- trunk/src/opover.c (modified) (1 diff)
- trunk/src/osx.mak (added)
- trunk/src/parse.c (modified) (6 diffs)
- trunk/src/ph.c (added)
- trunk/src/readme.txt (modified) (3 diffs)
- trunk/src/root (added)
- trunk/src/root/array.c (moved) (moved from trunk/src/array.c) (1 diff)
- trunk/src/root/dchar.c (moved) (moved from trunk/src/dchar.c) (1 diff)
- trunk/src/root/dchar.h (moved) (moved from trunk/src/dchar.h)
- trunk/src/root/gnuc.c (moved) (moved from trunk/src/gnuc.c)
- trunk/src/root/gnuc.h (moved) (moved from trunk/src/gnuc.h)
- trunk/src/root/lstring.c (moved) (moved from trunk/src/lstring.c) (1 diff)
- trunk/src/root/lstring.h (moved) (moved from trunk/src/lstring.h)
- trunk/src/root/man.c (moved) (moved from trunk/src/man.c)
- trunk/src/root/port.c (added)
- trunk/src/root/port.h (moved) (moved from trunk/src/port.h)
- trunk/src/root/rmem.c (moved) (moved from trunk/src/mem.c) (1 diff)
- trunk/src/root/rmem.h (moved) (moved from trunk/src/mem.h)
- trunk/src/root/root.c (moved) (moved from trunk/src/root.c) (1 diff)
- trunk/src/root/root.h (moved) (moved from trunk/src/root.h)
- trunk/src/root/stringtable.c (moved) (moved from trunk/src/stringtable.c) (1 diff)
- trunk/src/root/stringtable.h (moved) (moved from trunk/src/stringtable.h)
- trunk/src/s2ir.c (added)
- trunk/src/scope.c (modified) (1 diff)
- trunk/src/statement.c (modified) (8 diffs)
- trunk/src/statement.h (modified) (2 diffs)
- trunk/src/struct.c (modified) (8 diffs)
- trunk/src/template.c (modified) (21 diffs)
- trunk/src/template.h (modified) (4 diffs)
- trunk/src/tk (added)
- trunk/src/tk.c (added)
- trunk/src/tk/filespec.c (added)
- trunk/src/tk/filespec.h (added)
- trunk/src/tk/list.c (added)
- trunk/src/tk/list.h (added)
- trunk/src/tk/mem.c (added)
- trunk/src/tk/mem.h (added)
- trunk/src/tk/vec.c (added)
- trunk/src/tk/vec.h (added)
- trunk/src/tocsym.c (modified) (1 diff)
- trunk/src/toctype.c (added)
- trunk/src/tocvdebug.c (added)
- trunk/src/todt.c (modified) (2 diffs)
- trunk/src/toelfdebug.c (added)
- trunk/src/toir.c (modified) (8 diffs)
- trunk/src/toir.h (modified) (2 diffs)
- trunk/src/toobj.c (modified) (4 diffs)
- trunk/src/traits.c (modified) (5 diffs)
- trunk/src/typinf.c (modified) (1 diff)
- trunk/src/util.c (added)
- trunk/src/win32.mak (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/access.c
r169 r183 14 14 15 15 #include "root.h" 16 #include " mem.h"16 #include "rmem.h" 17 17 18 18 #include "enum.h" trunk/src/aggregate.h
r177 r183 53 53 Scope *scope; // !=NULL means context to use 54 54 55 int isnested; // !=0 if is nested 56 VarDeclaration *vthis; // 'this' parameter if this aggregate is nested 57 55 58 // Special member functions 56 59 InvariantDeclaration *inv; // invariant … … 80 83 int isDeprecated(); // is aggregate deprecated? 81 84 FuncDeclaration *buildDtor(Scope *sc); 85 int isNested(); 82 86 83 87 void emitComment(Scope *sc); … … 205 209 int isabstract; // !=0 if abstract class 206 210 207 int isnested; // !=0 if is nested208 VarDeclaration *vthis; // 'this' parameter if this class is nested209 210 211 int inuse; // to prevent recursive attempts 211 212 … … 225 226 FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf); 226 227 void interfaceSemantic(Scope *sc); 227 int isNested();228 228 int isCOMclass(); 229 229 virtual int isCOMinterface(); trunk/src/arrayop.c
r177 r183 12 12 #include <assert.h> 13 13 14 #if _WIN32 || IN_GCC 15 #include "mem.h" 16 #else 17 #include "../root/mem.h" 18 #endif 14 #include "rmem.h" 19 15 20 16 #include "stringtable.h" trunk/src/attrib.c
r182 r183 13 13 #include <assert.h> 14 14 15 #if _WIN32 || IN_GCC 16 #include "mem.h" 17 #elif linux || __APPLE__ 18 #include "../root/mem.h" 19 #endif 15 #include "rmem.h" 20 16 21 17 #include "init.h" trunk/src/backend/elfobj.c
r182 r183 1 2 //_ elfobj.c Modified by: Walter Bright 3 // Copyright (c) 1984-2009 by Digital Mars, http://www.digitalmars.com 1 // Copyright (C) ?-1998 by Symantec 2 // Copyright (C) 2000-2009 by Digital Mars 4 3 // All Rights Reserved 5 // Written by Walter Bright 4 // http://www.digitalmars.com 5 /* 6 * This source file is made available for personal use 7 * only. The license is in /dmd/src/dmd/backendlicense.txt 8 * For any other uses, please contact Digital Mars. 9 */ 10 11 6 12 // Output to ELF object files 7 13 … … 1482 1488 int elf_getsegment2(IDXSEC shtidx, IDXSYM symidx, IDXSEC relidx) 1483 1489 { 1490 //printf("SegData = %p\n", SegData); 1484 1491 int seg = ++seg_count; 1485 1492 if (seg_count >= seg_max) … … 1487 1494 seg_max += OB_SEG_INC; 1488 1495 SegData = (seg_data **)mem_realloc(SegData,seg_max * sizeof(seg_data *)); 1489 memset(&SegData[seg_count], 0, OB_SEG_INC* sizeof(seg_data *));1496 memset(&SegData[seg_count], 0, (seg_max - seg_count) * sizeof(seg_data *)); 1490 1497 } 1491 1498 assert(seg_count < seg_max); 1492 1499 if (!SegData[seg]) 1493 1500 { SegData[seg] = (seg_data *)mem_calloc(sizeof(seg_data)); 1501 //printf("test2: SegData[%d] = %p\n", seg, SegData[seg]); 1494 1502 } 1495 1503 … … 1737 1745 case mTYman_cpp: 1738 1746 case mTYman_c: 1739 case mTYman_ java:1747 case mTYman_d: 1740 1748 case mTYman_sys: 1741 1749 case 0: trunk/src/backend/html.c
r125 r183 1 1 2 // Copyright (c) 1999-200 6by Digital Mars2 // Copyright (c) 1999-2009 by Digital Mars 3 3 // All Rights Reserved 4 4 // written by Walter Bright … … 19 19 #include <wchar.h> 20 20 21 #include "mars.h"22 21 #include "html.h" 23 22 23 #if MARS 24 24 #include <assert.h> 25 25 #include "root.h" 26 #include "../mars/mars.h" 26 //#include "../mars/mars.h" 27 #else 28 #include "outbuf.h" 29 #include "msgs2.h" 30 31 extern void html_err(const char *, unsigned, unsigned, ...); 32 33 static char __file__[] = __FILE__; /* for tassert.h */ 34 #include "tassert.h" 35 #endif 36 37 #if __GNUC__ 38 int memicmp(const char *s1, const char *s2, int n); 39 #if 0 40 { 41 int result = 0; 42 43 for (int i = 0; i < n; i++) 44 { char c1 = s1[i]; 45 char c2 = s2[i]; 46 47 result = c1 - c2; 48 if (result) 49 { 50 if ('A' <= c1 && c1 <= 'Z') 51 c1 += 'a' - 'A'; 52 if ('A' <= c2 && c2 <= 'Z') 53 c2 += 'a' - 'A'; 54 result = c1 - c2; 55 if (result) 56 break; 57 } 58 } 59 return result; 60 } 61 #endif 62 #endif 27 63 28 64 extern int HtmlNamedEntity(unsigned char *p, int length); … … 66 102 void Html::error(const char *format, ...) 67 103 { 68 if (!global.gag) 69 { 70 printf("%s(%d) : HTML Error: ", sourcename, linnum); 71 72 va_list ap; 73 va_start(ap, format); 74 vprintf(format, ap); 75 va_end(ap); 76 77 printf("\n"); 78 fflush(stdout); 79 } 80 81 global.errors++; 104 printf("%s(%d) : HTML Error: ", sourcename, linnum); 105 106 va_list ap; 107 va_start(ap, format); 108 vprintf(format, ap); 109 va_end(ap); 110 111 printf("\n"); 112 fflush(stdout); 113 114 //#if MARS 115 // global.errors++; 116 //#else 117 exit(EXIT_FAILURE); 118 //#endif 82 119 } 83 120 … … 87 124 */ 88 125 126 #if MARS 89 127 void Html::extractCode(OutBuffer *buf) 128 #else 129 void Html::extractCode(Outbuffer *buf) 130 #endif 90 131 { 91 132 //printf("Html::extractCode()\n"); … … 109 150 scanComment(); 110 151 } 111 else if(p[1] == '!' && isCDATAStart())112 {113 scanCDATA();114 }152 else if(p[1] == '!' && isCDATAStart()) 153 { 154 scanCDATA(); 155 } 115 156 else if (p[1] == '/' && istagstart(*skipWhite(p + 2))) 116 157 skipTag(); … … 131 172 132 173 c = charEntity(); 174 #if MARS 133 175 buf->writeUTF8(c); 176 #else 177 buf->writeByte(c); 178 #endif 134 179 } 135 180 else … … 158 203 } 159 204 buf->writeByte(0); // ending sentinel 205 #if SCPP 206 //printf("Code is: '%s'\n", buf->toString() + 3); 207 #endif 208 #if MARS 160 209 //printf("D code is: '%s'\n", (char *)buf->data); 210 #endif 161 211 } 162 212 … … 532 582 */ 533 583 linnum++; 534 dbuf->write UTF8('\n');584 dbuf->writeByte('\n'); 535 585 p += lineSepLength; 536 586 continue; … … 551 601 } 552 602 } 603 553 604 554 605 /******************************************** … … 718 769 } 719 770 771 trunk/src/backend/html.h
r125 r183 1 1 2 // Compiler implementation of the D programming language3 2 // Copyright (c) 1999-2006 by Digital Mars 4 3 // All Rights Reserved 5 4 // written by Walter Bright 6 // http://www.digitalmars.com5 // www.digitalmars.com 7 6 // License for redistribution is by either the Artistic License 8 7 // in artistic.txt, or the GNU General Public License in gnu.txt. 9 8 // See the included readme.txt for details. 10 9 11 #ifndef DMD_HTML_H12 #define DMD_HTML_H 113 10 11 #if MARS 14 12 struct OutBuffer; 13 #else 14 struct Outbuffer; 15 #endif 15 16 16 17 struct Html … … 22 23 unsigned char *p; // current character 23 24 unsigned linnum; // current line number 25 #if MARS 24 26 OutBuffer *dbuf; // code source buffer 27 #else 28 Outbuffer *dbuf; // code source buffer 29 #endif 25 30 int inCode; // !=0 if in code 26 31 … … 29 34 30 35 void error(const char *format, ...); 36 #if MARS 31 37 void extractCode(OutBuffer *buf); 38 #else 39 void extractCode(Outbuffer *buf); 40 #endif 32 41 void skipTag(); 33 42 void skipString(); … … 40 49 static int namedEntity(unsigned char *p, int length); 41 50 }; 42 43 #endiftrunk/src/backend/machobj.c
r182 r183 1 1 2 //_ machobj.c Modified by: Walter Bright 3 // Copyright (c) 2009 by Digital Mars, http://www.digitalmars.com 2 // Copyright (c) 2009 by Digital Mars 4 3 // All Rights Reserved 5 // Written by Walter Bright 6 // Output to Mach-O object files 4 // written by Walter Bright 5 // http://www.digitalmars.com 6 // License for redistribution is by either the Artistic License 7 // in artistic.txt, or the GNU General Public License in gnu.txt. 8 // See the included readme.txt for details. 9 7 10 8 11 #if SCPP || MARS … … 1425 1428 seg_max += 10; 1426 1429 SegData = (seg_data **)mem_realloc(SegData,seg_max * sizeof(seg_data *)); 1427 memset(&SegData[seg_count], 0, 10* sizeof(seg_data *));1430 memset(&SegData[seg_count], 0, (seg_max - seg_count) * sizeof(seg_data *)); 1428 1431 } 1429 1432 assert(seg_count < seg_max); … … 1626 1629 } 1627 1630 case mTYman_cpp: 1628 case mTYman_ java:1631 case mTYman_d: 1629 1632 case mTYman_sys: 1630 1633 case 0: trunk/src/builtin.c
r163 r183 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 24 24 #include "module.h" 25 25 26 #if V2 27 26 28 /********************************** 27 29 * Determine if function is a builtin one. … … 29 31 enum BUILTIN FuncDeclaration::isBuiltin() 30 32 { 31 static const char FeZe[] = "F eZe"; //real function(real)33 static const char FeZe[] = "FNaNbeZe"; // pure nothrow real function(real) 32 34 33 35 //printf("FuncDeclaration::isBuiltin() %s\n", toChars()); … … 41 43 !parent->parent->parent) 42 44 { 45 //printf("deco = %s\n", type->deco); 43 46 if (strcmp(type->deco, FeZe) == 0) 44 47 { … … 55 58 //printf("builtin = %d\n", builtin); 56 59 } 60 else if (strcmp(type->deco, "FNaNbdZd") == 0 || 61 strcmp(type->deco, "FNaNbfZf") == 0) 62 builtin = BUILTINsqrt; 57 63 } 58 64 } … … 101 107 return e; 102 108 } 109 110 #endif trunk/src/cast.c
r181 r183 11 11 #include <assert.h> 12 12 13 #if _WIN32 || IN_GCC 14 #include "mem.h" 15 #else 16 #include "../root/mem.h" 17 #endif 13 #include "rmem.h" 18 14 19 15 #include "expression.h" … … 62 58 else 63 59 { 64 fprintf(stdmsg, "warning - "); 65 error("implicit conversion of expression (%s) of type %s to %s can cause loss of data", 60 warning("implicit conversion of expression (%s) of type %s to %s can cause loss of data", 66 61 toChars(), type->toChars(), t->toChars()); 67 62 } … … 1726 1721 } 1727 1722 1723 /*********************************** 1724 * See if both types are arrays that can be compared 1725 * for equality. Return !=0 if so. 1726 * If they are arrays, but incompatible, issue error. 1727 * This is to enable comparing things like an immutable 1728 * array with a mutable one. 1729 */ 1730 1731 int arrayTypeCompatible(Loc loc, Type *t1, Type *t2) 1732 { 1733 t1 = t1->toBasetype(); 1734 t2 = t2->toBasetype(); 1735 1736 if ((t1->ty == Tarray || t1->ty == Tsarray || t1->ty == Tpointer) && 1737 (t2->ty == Tarray || t2->ty == Tsarray || t2->ty == Tpointer)) 1738 { 1739 if (t1->nextOf()->implicitConvTo(t2->nextOf()) < MATCHconst && 1740 t2->nextOf()->implicitConvTo(t1->nextOf()) < MATCHconst && 1741 (t1->nextOf()->ty != Tvoid && t2->nextOf()->ty != Tvoid)) 1742 { 1743 error("array equality comparison type mismatch, %s vs %s", t1->toChars(), t2->toChars()); 1744 } 1745 return 1; 1746 } 1747 return 0; 1748 } trunk/src/class.c
r180 r183 14 14 15 15 #include "root.h" 16 #include " mem.h"16 #include "rmem.h" 17 17 18 18 #include "enum.h" … … 189 189 isauto = 0; 190 190 isabstract = 0; 191 isnested = 0;192 vthis = NULL;193 191 inuse = 0; 194 192 } … … 507 505 if (s) 508 506 { 509 ClassDeclaration *cd = s->isClassDeclaration();507 AggregateDeclaration *ad = s->isClassDeclaration(); 510 508 FuncDeclaration *fd = s->isFuncDeclaration(); 511 509 512 510 513 if ( cd || fd)511 if (ad || fd) 514 512 { isnested = 1; 515 513 Type *t; 516 if ( cd)517 t = cd->type;514 if (ad) 515 t = ad->handle; 518 516 else if (fd) 519 517 { AggregateDeclaration *ad = fd->isMember2(); … … 522 520 else 523 521 { 524 t = new TypePointer(Type::tvoid); 525 t = t->semantic(0, sc); 522 t = Type::tvoidptr; 526 523 } 527 524 } 528 525 else 529 526 assert(0); 527 if (t->ty == Tstruct) // ref to struct 528 t = Type::tvoidptr; 530 529 assert(!vthis); 531 530 vthis = new ThisDeclaration(t); … … 886 885 for (size_t i = 0; i < vtbl->dim; i++) 887 886 { 888 FuncDeclaration *fd = (FuncDeclaration *)vtbl->data[i]; 887 FuncDeclaration *fd = ((Dsymbol*)vtbl->data[i])->isFuncDeclaration(); 888 if (!fd) 889 continue; // the first entry might be a ClassInfo 889 890 890 891 //printf("\t[%d] = %s\n", i, fd->toChars()); … … 971 972 } 972 973 973 974 /****************************************975 * Returns !=0 if there's an extra member which is the 'this'976 * pointer to the enclosing context (enclosing class or function)977 */978 979 int ClassDeclaration::isNested()980 {981 return isnested;982 }983 974 984 975 /**************************************** trunk/src/clone.c
r179 r183 48 48 VarDeclaration *v = s->isVarDeclaration(); 49 49 assert(v && v->storage_class & STCfield); 50 if (v->storage_class & STCref) 51 continue; 50 52 Type *tv = v->type->toBasetype(); 51 53 while (tv->ty == Tsarray) … … 265 267 VarDeclaration *v = s->isVarDeclaration(); 266 268 assert(v && v->storage_class & STCfield); 269 if (v->storage_class & STCref) 270 continue; 267 271 Type *tv = v->type->toBasetype(); 268 272 size_t dim = 1; … … 360 364 VarDeclaration *v = s->isVarDeclaration(); 361 365 assert(v && v->storage_class & STCfield); 366 if (v->storage_class & STCref) 367 continue; 362 368 Type *tv = v->type->toBasetype(); 363 369 size_t dim = 1; trunk/src/constfold.c
r178 r183 18 18 #endif 19 19 20 #include " mem.h"20 #include "rmem.h" 21 21 #include "root.h" 22 22 trunk/src/declaration.c
r181 r183 457 457 goto L2; // it's a symbolic alias 458 458 459 //printf("alias type is %s\n", type->toChars()); 460 type->resolve(loc, sc, &e, &t, &s); 459 if (storage_class & STCref) 460 { // For 'ref' to be attached to function types, and picked 461 // up by Type::resolve(), it has to go into sc. 462 sc = sc->push(); 463 sc->stc |= STCref; 464 type->resolve(loc, sc, &e, &t, &s); 465 sc = sc->pop(); 466 } 467 else 468 type->resolve(loc, sc, &e, &t, &s); 461 469 if (s) 462 470 { … … 858 866 } 859 867 860 if ((storage_class & (STCref | STCparameter | STCforeach)) == STCref) 868 if ((storage_class & (STCref | STCparameter | STCforeach)) == STCref && 869 ident != Id::This) 870 { 861 871 error("only parameters or foreach declarations can be ref"); 872 } 862 873 863 874 if (type->isauto() && !noauto) … … 904 915 e1 = new VarExp(loc, this); 905 916 e = new AssignExp(loc, e1, e); 917 e->op = TOKconstruct; 906 918 e->type = e1->type; // don't type check this, it would fail 907 919 init = new ExpInitializer(loc, e); … … 1656 1668 } 1657 1669 1658 trunk/src/declaration.h
r180 r183 438 438 ThisDeclaration(Type *t); 439 439 Dsymbol *syntaxCopy(Dsymbol *); 440 ThisDeclaration *isThisDeclaration() { return this; } 440 441 }; 441 442 trunk/src/doc.c
r182 r183 17 17 #include <assert.h> 18 18 19 #ifdef IN_GCC 20 #include "mem.h" 21 #else 22 #if _WIN32 23 #include "..\root\mem.h" 24 #elif linux || __APPLE__ 25 #include "../root/mem.h" 26 #else 27 #error "fix this" 28 #endif 29 #endif 30 19 #include "rmem.h" 31 20 #include "root.h" 32 21 trunk/src/dsymbol.c
r180 r183 13 13 #include <assert.h> 14 14 15 #include " mem.h"15 #include "rmem.h" 16 16 17 17 #include "mars.h" … … 1007 1007 1008 1008 if (td) 1009 { 1009 { /* $ gives the number of elements in the tuple 1010 */ 1010 1011 VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, NULL); 1011 1012 Expression *e = new IntegerExp(0, td->objects->dim, Type::tsize_t); … … 1017 1018 1018 1019 if (type) 1019 { 1020 { /* $ gives the number of type entries in the type tuple 1021 */ 1020 1022 VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, NULL); 1021 1023 Expression *e = new IntegerExp(0, type->arguments->dim, Type::tsize_t); … … 1027 1029 1028 1030 if (exp->op == TOKindex) 1029 { 1031 { /* array[index] where index is some function of $ 1032 */ 1030 1033 IndexExp *ie = (IndexExp *)exp; 1031 1034 … … 1034 1037 } 1035 1038 else if (exp->op == TOKslice) 1036 { 1039 { /* array[lwr .. upr] where lwr or upr is some function of $ 1040 */ 1037 1041 SliceExp *se = (SliceExp *)exp; 1038 1042 … … 1041 1045 } 1042 1046 else 1047 /* Didn't find $, look in enclosing scope(s). 1048 */ 1043 1049 return NULL; 1044 1050 1051 /* If we are indexing into an array that is really a type 1052 * tuple, rewrite this as an index into a type tuple and 1053 * try again. 1054 */ 1045 1055 if (ce->op == TOKtype) 1046 1056 { … … 1052 1062 } 1053 1063 1054 if (!*pvar) 1055 { 1064 /* *pvar is lazily initialized, so if we refer to $ 1065 * multiple times, it gets set only once. 1066 */ 1067 if (!*pvar) // if not already initialized 1068 { /* Create variable v and set it to the value of $, 1069 * which will be a constant. 1070 */ 1056 1071 VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, NULL); 1057 1072 trunk/src/dsymbol.h
r179 r183 26 26 struct DsymbolTable; 27 27 struct Declaration; 28 struct ThisDeclaration; 28 29 struct TupleDeclaration; 29 30 struct TypedefDeclaration; … … 182 183 virtual TemplateMixin *isTemplateMixin() { return NULL; } 183 184 virtual Declaration *isDeclaration() { return NULL; } 185 virtual ThisDeclaration *isThisDeclaration() { return NULL; } 184 186 virtual TupleDeclaration *isTupleDeclaration() { return NULL; } 185 187 virtual TypedefDeclaration *isTypedefDeclaration() { return NULL; } trunk/src/e2ir.c
r182 r183 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 26 26 #include "template.h" 27 27 28 #if _WIN32 29 #include "..\tk\mem.h" // for mem_malloc 30 #elif linux || __APPLE__ 31 #include "../tk/mem.h" // for mem_malloc 32 #endif 28 #include "mem.h" // for tk/mem_malloc 33 29 34 30 #include "cc.h" … … 248 244 249 245 tyret = tret->totym(); 246 250 247 251 248 // Look for intrinsic functions … … 1533 1530 * *(ey + cd.vthis.offset) = this; 1534 1531 */ 1535 elem *ethis; 1536 FuncDeclaration *thisfd = irs->getFunc(); 1537 int offset = 0; 1538 Dsymbol *cdp = cd->toParent2(); // class/func we're nested in 1539 1540 if (cdp == thisfd) 1541 { /* Class we're new'ing is a local class in this function: 1542 * void thisfd() { class cd { } } 1543 */ 1544 if (irs->sclosure) 1545 ethis = el_var(irs->sclosure); 1546 else if (irs->sthis) 1547 { 1548 #if V2 1549 if (thisfd->closureVars.dim) 1550 #else 1551 if (thisfd->nestedFrameRef) 1552 #endif 1553 { 1554 ethis = el_ptr(irs->sthis); 1555 } 1556 else 1557 ethis = el_var(irs->sthis); 1558 } 1559 else 1560 { 1561 ethis = el_long(TYnptr, 0); 1562 #if V2 1563 if (thisfd->closureVars.dim) 1564 #else 1565 if (thisfd->nestedFrameRef) 1566 #endif 1567 { 1568 ethis->Eoper = OPframeptr; 1569 } 1570 } 1571 } 1572 else if (thisfd->vthis && 1573 (cdp == thisfd->toParent2() || 1574 (cdp->isClassDeclaration() && 1575 cdp->isClassDeclaration()->isBaseOf(thisfd->toParent2()->isClassDeclaration(), &offset) 1576 ) 1577 ) 1578 ) 1579 { /* Class we're new'ing is at the same level as thisfd 1580 */ 1581 assert(offset == 0); // BUG: should handle this case 1582 ethis = el_var(irs->sthis); 1583 } 1584 else 1585 { 1586 ethis = getEthis(loc, irs, cd->toParent2()); 1587 ethis = el_una(OPaddr, TYnptr, ethis); 1588 } 1589 1590 ey = el_bin(OPadd, TYnptr, ey, el_long(TYint, cd->vthis->offset)); 1591 ey = el_una(OPind, TYnptr, ey); 1592 ey = el_bin(OPeq, TYnptr, ey, ethis); 1593 1532 ey = setEthis(loc, irs, ey, cd); 1594 1533 } 1595 1534 … … 1631 1570 ei = el_var(si); 1632 1571 1633 if (member) 1572 if (cd->isNested()) 1573 { 1574 ey = el_same(&ex); 1575 ez = el_copytree(ey); 1576 } 1577 else if (member) 1634 1578 ez = el_same(&ex); 1635 else 1579 1580 if (!member) 1636 1581 { /* Statically intialize with default initializer 1637 1582 */ … … 1661 1606 ectype = NULL; 1662 1607 1663 if (member) 1608 if (cd->isNested()) 1609 { 1610 ey = el_same(&ex); 1611 ez = el_copytree(ey); 1612 } 1613 else if (member) 1664 1614 ez = el_same(&ex); 1665 1615 //elem_print(ex); 1666 1616 //elem_print(ey); 1667 1617 //elem_print(ez); 1618 } 1619 1620 if (cd->isNested()) 1621 { /* Initialize cd->vthis: 1622 * *(ey + cd.vthis.offset) = this; 1623 */ 1624 ey = setEthis(loc, irs, ey, cd); 1668 1625 } 1669 1626 … … 2754 2711 if (s->storage_class & STCref) 2755 2712 { 2713 #if 0 2756 2714 Expression *ae = e2->addressOf(NULL); 2757 2715 e = ae->toElem(irs); 2716 #else 2717 e = e2->toElem(irs); 2718 e = addressElem(e, e2->type); 2719 #endif 2758 2720 elem *es = el_var(s->toSymbol()); 2759 2721 es->Ety = TYnptr; 2760 2722 e = el_bin(OPeq, TYnptr, es, e); 2723 // BUG: type is struct, and e2 is TOKint64 2761 2724 goto Lret; 2762 2725 } … … 2785 2748 } 2786 2749 #endif 2750 //printf("test1 %d\n", op); 2751 //if (op == TOKconstruct) printf("construct\n"); 2787 2752 if (t1b->ty == Tstruct) 2788 { 2753 { elem *eleft = e1->toElem(irs); 2754 2789 2755 if (e2->op == TOKint64) 2790 2756 { /* Implement: … … 2793 2759 * memset(&struct, 0, struct.sizeof) 2794 2760 */ 2795 elem *el = e1->toElem(irs); 2796 elem *enbytes = el_long(TYint, e1->type->size()); 2761 elem *ey = NULL; 2762 int sz = e1->type->size(); 2763 StructDeclaration *sd = ((TypeStruct *)t1b)->sym; 2764 if (sd->isnested && op == TOKconstruct) 2765 { 2766 ey = el_una(OPaddr, TYnptr, eleft); 2767 eleft = el_same(&ey); 2768 ey = setEthis(loc, irs, ey, sd); 2769 sz = sd->vthis->offset; 2770 } 2771 2772 elem *el = eleft; 2773 elem *enbytes = el_long(TYint, sz); 2797 2774 elem *evalue = el_long(TYint, 0); 2798 2775 2799 el = el_una(OPaddr, TYnptr, el); 2776 if (!(sd->isnested && op == TOKconstruct)) 2777 el = el_una(OPaddr, TYnptr, el); 2800 2778 e = el_param(enbytes, evalue); 2801 2779 e = el_bin(OPmemset,TYnptr,el,e); 2780 e = el_combine(ey, e); 2802 2781 el_setLoc(e, loc); 2803 2782 //e = el_una(OPind, TYstruct, e); … … 2805 2784 else 2806 2785 { 2807 elem *e1;2808 elem *e2;2809 tym_t tym;2810 2811 2786 //printf("toElemBin() '%s'\n", toChars()); 2812 2787 2813 tym = type->totym();2814 2815 e 1 = this->e1->toElem(irs);2788 tym_t tym = type->totym(); 2789 2790 elem *e1 = eleft; 2816 2791 elem *ex = e1; 2817 2792 if (e1->Eoper == OPind) … … 2838 2813 else 2839 2814 { 2840 e 2 = this->e2->toElem(irs);2815 elem *e2 = this->e2->toElem(irs); 2841 2816 e = el_bin(OPstreq,tym,e1,e2); 2842 2817 e->Enumbytes = this->e1->type->size(); … … 3985 3960 case X(Tfloat80,Tuns32): 3986 3961 case X(Tfloat80,Tint64): 3987 case X(Tfloat80,Tuns64):3988 3962 case X(Tfloat80,Tfloat32): e = el_una(OPld_d, TYdouble, e); 3989 3963 fty = Tfloat64; 3990 3964 goto Lagain; 3965 case X(Tfloat80,Tuns64): 3966 eop = OPld_u64; goto Leop; 3991 3967 case X(Tfloat80,Tfloat64): eop = OPld_d; goto Leop; 3992 3968 case X(Tfloat80,Timaginary32): goto Lzero; … … 4638 4614 VarDeclaration *v = s->isVarDeclaration(); 4639 4615 assert(v); 4616 assert(!v->isThisDeclaration()); 4640 4617 4641 4618 elem *e1; … … 4731 4708 } 4732 4709 4710 if (sd->isnested) 4711 { // Initialize the hidden 'this' pointer 4712 assert(sd->fields.dim); 4713 Dsymbol *s = (Dsymbol *)sd->fields.data[sd->fields.dim - 1]; 4714 ThisDeclaration *v = s->isThisDeclaration(); 4715 assert(v); 4716 4717 elem *e1; 4718 if (tybasic(stmp->Stype->Tty) == TYnptr) 4719 { e1 = el_var(stmp); 4720 e1->EV.sp.Voffset = soffset; 4721 } 4722 else 4723 { e1 = el_ptr(stmp); 4724 if (soffset) 4725 e1 = el_bin(OPadd, TYnptr, e1, el_long(TYsize_t, soffset)); 4726 } 4727 e1 = el_bin(OPadd, TYnptr, e1, el_long(TYsize_t, v->offset)); 4728 e1 = setEthis(loc, irs, e1, sd); 4729 4730 e = el_combine(e, e1); 4731 } 4732 4733 4733 elem *ev = el_var(stmp); 4734 4734 ev->Enumbytes = sd->structsize; trunk/src/expression.c
r182 r183 33 33 #endif 34 34 35 #if IN_GCC 36 #include "mem.h" 37 #elif _WIN32 38 #include "..\root\mem.h" 39 #elif linux || __APPLE__ 40 #include "../root/mem.h" 41 #endif 35 #include "rmem.h" 42 36 43 37 //#include "port.h" … … 951 945 } 952 946 947 void Expression::warning(const char *format, ...) 948 { 949 if (global.params.warnings && !global.gag) 950 { 951 fprintf(stdmsg, "warning - "); 952 va_list ap; 953 va_start(ap, format); 954 ::verror(loc, format, ap); 955 va_end( ap ); 956 } 957 } 958 953 959 void Expression::rvalue() 954 960 { … … 3073 3079 Expression *StructLiteralExp::semantic(Scope *sc) 3074 3080 { Expression *e; 3081 int nfields = sd->fields.dim - sd->isnested; 3075 3082 3076 3083 #if LOGSEMANTIC … … 3098 3105 error("%s has no value", e->toChars()); 3099 3106 e = resolveProperties(sc, e); 3100 if (i >= sd->fields.dim)3107 if (i >= nfields) 3101 3108 { error("more initializers than fields of %s", sd->toChars()); 3102 3109 break; … … 3124 3131 /* Fill out remainder of elements[] with default initializers for fields[] 3125 3132 */ 3126 for (size_t i = elements->dim; i < sd->fields.dim; i++)3133 for (size_t i = elements->dim; i < nfields; i++) 3127 3134 { Dsymbol *s = (Dsymbol *)sd->fields.data[i]; 3128 3135 VarDeclaration *v = s->isVarDeclaration(); 3129 3136 assert(v); 3137 assert(!v->isThisDeclaration()); 3130 3138 3131 3139 if (v->offset < offset) … … 4699 4707 if (m == MATCHnomatch || 4700 4708 (m != MATCHexact && tok == TOKequal)) 4709 { 4701 4710 goto Lno; 4711 } 4702 4712 else 4703 4713 { … … 4741 4751 { 4742 4752 /* Evaluate to TRUE if targ matches tspec 4753 * is(targ == tspec) 4754 * is(targ : tspec) 4743 4755 */ 4744 4756 tspec = tspec->semantic(loc, sc); … … 5970 5982 int istemp; 5971 5983 Objects *targsi = NULL; // initial list of template arguments 5984 TemplateInstance *tierror = NULL; 5972 5985 5973 5986 #if LOGSEMANTIC … … 6059 6072 global.errors = errors; 6060 6073 targsi = ti->tiargs; 6074 tierror = ti; // for error reporting 6061 6075 e1 = new IdentifierExp(loc, ti->name); 6062 6076 } … … 6085 6099 global.errors = errors; 6086 6100 targsi = ti->tiargs; 6101 tierror = ti; // for error reporting 6087 6102 e1 = new DotIdExp(loc, se->e1, ti->name); 6088 6103 } … … 6484 6499 f = te->td->deduceFunctionTemplate(sc, loc, targsi, NULL, arguments); 6485 6500 if (!f) 6486 { type = Type::terror; 6501 { if (tierror) 6502 tierror->error("errors instantiating template"); // give better error message 6503 type = Type::terror; 6487 6504 return this; 6488 6505 } … … 6627 6644 int CallExp::isLvalue() 6628 6645 { 6629 if (type->toBasetype()->ty == Tstruct)6630 return 1;6646 // if (type->toBasetype()->ty == Tstruct) 6647 // return 1; 6631 6648 Type *tb = e1->type->toBasetype(); 6632 6649 if (tb->ty == Tfunction && ((TypeFunction *)tb)->isref) … … 7437 7454 } 7438 7455 7439 type = t->nextOf()->arrayOf(); 7456 if (t->ty == Tarray) 7457 { 7458 type = e1->type; 7459 } 7460 else 7461 type = t->nextOf()->arrayOf(); 7440 7462 return e; 7441 7463 … … 7774 7796 case Taarray: 7775 7797 { TypeAArray *taa = (TypeAArray *)t1; 7776 7777 e2 = e2->implicitCastTo(sc, taa->index); // type checking 7798 if (!arrayTypeCompatible(e2->loc, e2->type, taa->index)) 7799 { 7800 e2 = e2->implicitCastTo(sc, taa->index); // type checking 7801 } 7778 7802 type = taa->next; 7779 7803 break; … … 9466 9490 TypeAArray *ta = (TypeAArray *)t2b; 9467 9491 9468 // Convert key to type of key 9469 e1 = e1->implicitCastTo(sc, ta->index); 9492 // Special handling for array keys 9493 if (!arrayTypeCompatible(e1->loc, e1->type, ta->index)) 9494 { 9495 // Convert key to type of key 9496 e1 = e1->implicitCastTo(sc, ta->index); 9497 } 9470 9498 9471 9499 // Return type is pointer to value … … 9635 9663 9636 9664 // Special handling for array comparisons 9637 t1 = e1->type->toBasetype(); 9638 t2 = e2->type->toBasetype(); 9639 9640 if ((t1->ty == Tarray || t1->ty == Tsarray || t1->ty == Tpointer) && 9641 (t2->ty == Tarray || t2->ty == Tsarray || t2->ty == Tpointer)) 9642 { 9643 if (t1->nextOf()->implicitConvTo(t2->nextOf()) < MATCHconst && 9644 t2->nextOf()->implicitConvTo(t1->nextOf()) < MATCHconst && 9645 (t1->nextOf()->ty != Tvoid && t2->nextOf()->ty != Tvoid)) 9646 error("array equality comparison type mismatch, %s vs %s", t1->toChars(), t2->toChars()); 9647 } 9648 else 9665 if (!arrayTypeCompatible(loc, e1->type, e2->type)) 9649 9666 { 9650 9667 if (e1->type != e2->type && e1->type->isfloating() && e2->type->isfloating()) trunk/src/expression.h
r181 r183 90 90 virtual void dump(int indent); 91 91 void error(const char *format, ...); 92 void warning(const char *format, ...); 92 93 virtual void rvalue(); 93 94 trunk/src/func.c
r182 r183 374 374 375 375 #if V2 376 if (!isOverride() && global.params.warnings)377 error("overrides base class function %s, but is not marked with 'override'", fdv->toPrettyChars());376 if (!isOverride()) 377 warning(loc, "overrides base class function %s, but is not marked with 'override'", fdv->toPrettyChars()); 378 378 #endif 379 379 … … 1109 1109 { Expression *e; 1110 1110 1111 if (global.params.warnings) 1112 { fprintf(stdmsg, "warning - "); 1113 error("no return at end of function"); 1114 } 1111 warning(loc, "no return at end of function"); 1115 1112 1116 1113 if (global.params.useAssert && … … 1942 1939 else 1943 1940 { 1944 ClassDeclaration *thiscd = s->isClassDeclaration();1941 AggregateDeclaration *thiscd = s->isAggregateDeclaration(); 1945 1942 if (thiscd) 1946 1943 { if (!thiscd->isNested()) trunk/src/hdrgen.c
r182 r183 25 25 #endif 26 26 27 #ifdef IN_GCC 28 #include "mem.h" 29 #else 30 #if _WIN32 31 #include "..\root\mem.h" 32 #elif linux || __APPLE__ 33 #include "../root/mem.h" 34 #else 35 #error "fix this" 36 #endif 37 #endif 27 #include "rmem.h" 38 28 39 29 #include "id.h" trunk/src/inifile.c
r182 r183 1 2 // Copyright (c) 1999-2009 by Digital Mars 3 // All Rights Reserved 4 // written by Walter Bright 5 // http://www.digitalmars.com 6 1 /* 2 * Some portions copyright (c) 1994-1995 by Symantec 3 * Copyright (c) 1999-2009 by Digital Mars 4 * All Rights Reserved 5 * http://www.digitalmars.com 6 * Written by Walter Bright 7 * 8 * This source file is made available for personal use 9 * only. The license is in /dmd/src/dmd/backendlicense.txt 10 * For any other uses, please contact Digital Mars. 11 */ 7 12 8 13 #include <stdio.h> … … 16 21 17 22 #include "root.h" 18 #include " mem.h"23 #include "rmem.h" 19 24 20 25 #define LOG 0 trunk/src/interpret.c
r180 r183 13 13 #include <assert.h> 14 14 15 #include " mem.h"15 #include "rmem.h" 16 16 17 17 #include "statement.h" trunk/src/lexer.c
r182 r183 25 25 #endif 26 26 #ifdef IN_GCC 27 28 27 #include <time.h> 29 #include "mem.h"30 31 28 #else 32 33 29 #if __GNUC__ 34 30 #include <time.h> 35 31 #endif 36 37 #if _WIN32 38 #include "..\root\mem.h" 39 #else 40 #include "../root/mem.h" 41 #endif 42 #endif 32 #endif 33 34 #include "rmem.h" 43 35 44 36 #include "stringtable.h" … … 617 609 case '\\': // escaped string literal 618 610 { unsigned c; 611 unsigned char *pstart = p; 619 612 620 613 stringbuffer.reset(); … … 643 636 t->postfix = 0; 644 637 t->value = TOKstring; 638 if (!global.params.useDeprecated) 639 error("Escape String literal %.*s is deprecated, use double quoted string literal \"%.*s\" instead", p - pstart, pstart, p - pstart, pstart); 645 640 return; 646 641 } trunk/src/libelf.c
r181 r183 17 17 #include <sys/stat.h> 18 18 19 #include " mem.h"19 #include "rmem.h" 20 20 #include "root.h" 21 21 #include "stringtable.h" trunk/src/libmach.c
r182 r183 30 30 #include "mach.h" 31 31 32 #include " mem.h"32 #include "rmem.h" 33 33 #include "root.h" 34 34 #include "stringtable.h" trunk/src/link.c
r182 r183 30 30 #include "mars.h" 31 31 32 #include " mem.h"32 #include "rmem.h" 33 33 34 34 int executecmd(char *cmd, char *args, int useenv); trunk/src/macro.c
r182 r183 17 17 #include <assert.h> 18 18 19 #ifdef IN_GCC 20 #include "mem.h" 21 #else 22 #if _WIN32 23 #include "..\root\mem.h" 24 #elif linux || __APPLE__ 25 #include "../root/mem.h" 26 #else 27 #error "fix this" 28 #endif 29 #endif 30 19 #include "rmem.h" 31 20 #include "root.h" 21 32 22 #include "macro.h" 33 23 trunk/src/mars.c
r182 r183 23 23 #endif 24 24 25 #include " mem.h"25 #include "rmem.h" 26 26 #include "root.h" 27 27 … … 75 75 copyright = "Copyright (c) 1999-2009 by Digital Mars"; 76 76 written = "written by Walter Bright"; 77 version = "v2.02 5";77 version = "v2.026"; 78 78 global.structalign = 8; 79 79 … … 113 113 verror(loc, format, ap); 114 114 va_end( ap ); 115 } 116 117 void warning(Loc loc, const char *format, ...) 118 { 119 if (global.params.warnings && !global.gag) 120 { 121 fprintf(stdmsg, "warning - "); 122 va_list ap; 123 va_start(ap, format); 124 verror(loc, format, ap); 125 va_end( ap ); 126 } 115 127 } 116 128 … … 236 248 int status = EXIT_SUCCESS; 237 249 int argcstart = argc; 250 int setdebuglib = 0; 238 251 239 252 // Check for malformed input … … 281 294 global.params.defaultlibname = "phobos2"; 282 295 #endif 283 global.params.debuglibname = global.params.defaultlibname;284 296 285 297 // Predefine version identifiers … … 556 568 else if (memcmp(p + 1, "debuglib=", 9) == 0) 557 569 { 570 setdebuglib = 1; 558 571 global.params.debuglibname = p + 1 + 9; 559 572 } … … 631 644 } 632 645 646 if (!setdebuglib) 647 global.params.debuglibname = global.params.defaultlibname; 648 633 649 #if TARGET_OSX 634 650 global.params.pic = 1; trunk/src/mars.h
r182 r183 347 347 }; 348 348 349 void warning(Loc loc, const char *format, ...); 349 350 void error(Loc loc, const char *format, ...); 350 351 void verror(Loc loc, const char *format, va_list); trunk/src/module.c
r180 r183 21 21 #endif 22 22 23 #include " mem.h"23 #include "rmem.h" 24 24 25 25 #include "mars.h" … … 76 76 strictlyneedmoduleinfo = 0; 77 77 #endif 78 selfimports = 0; 78 79 insearch = 0; 79 80 searchCacheIdent = NULL; … … 916 917 mi->insearch = 1; 917 918 int r = mi->imports(m); 918 mi->insearch = 0;919 919 if (r) 920 920 return r; … … 923 923 return FALSE; 924 924 } 925 926 /************************************* 927 * Return !=0 if module imports itself. 928 */ 929 930 int Module::selfImports() 931 { 932 //printf("Module::selfImports() %s\n", toChars()); 933 if (!selfimports) 934 { 935 for (int i = 0; i < amodules.dim; i++) 936 { Module *mi = (Module *)amodules.data[i]; 937 //printf("\t[%d] %s\n", i, mi->toChars()); 938 mi->insearch = 0; 939 } 940 941 selfimports = imports(this) + 1; 942 943 for (int i = 0; i < amodules.dim; i++) 944 { Module *mi = (Module *)amodules.data[i]; 945 //printf("\t[%d] %s\n", i, mi->toChars()); 946 mi->insearch = 0; 947 } 948 } 949 return selfimports - 1; 950 } 951 925 952 926 953 /* =========================== ModuleDeclaration ===================== */ trunk/src/module.h
r180 r183 73 73 int strictlyneedmoduleinfo; 74 74 #endif 75 76 int selfimports; // 0: don't know, 1: does not, 2: does 77 int selfImports(); // returns !=0 if module imports itself 75 78 76 79 int insearch; trunk/src/mtype.c
r182 r183 40 40 #endif 41 41 42 #include " mem.h"42 #include "rmem.h" 43 43 44 44 #include "dsymbol.h" … … 1383 1383 ::verror(loc, format, ap); 1384 1384 va_end( ap ); 1385 } 1386 1387 void Type::warning(Loc loc, const char *format, ...) 1388 { 1389 if (global.params.warnings && !global.gag) 1390 { 1391 fprintf(stdmsg, "warning - "); 1392 va_list ap; 1393 va_start(ap, format); 1394 ::verror(loc, format, ap); 1395 va_end( ap ); 1396 } 1385 1397 } 1386 1398 … … 2642 2654 return arg->type; 2643 2655 } 2656 case Tstruct: 2657 { TypeStruct *ts = (TypeStruct *)tbn; 2658 if (ts->sym->isnested) 2659 error(loc, "cannot have array of inner structs %s", ts->toChars()); 2660 break; 2661 } 2644 2662 case Tfunction: 2645 2663 case Tnone: … … 2853 2871 tn = next = tint32; 2854 2872 break; 2873 case Tstruct: 2874 { TypeStruct *ts = (TypeStruct *)tbn; 2875 if (ts->sym->isnested) 2876 error(loc, "cannot have array of inner structs %s", ts->toChars()); 2877 break; 2878 } 2855 2879 } 2856 2880 if (tn->isauto()) … … 3669 3693 void TypeFunction::toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs) 3670 3694 { 3671 //printf("TypeFunction::toCBuffer() this = %p %s\n", this, toChars());3695 //printf("TypeFunction::toCBuffer() this = %p\n", this); 3672 3696 const char *p = NULL; 3673 3697 … … 3722 3746 void TypeFunction::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod) 3723 3747 { 3724 //printf("TypeFunction::toCBuffer2() this = %p %s\n", this, toChars());3748 //printf("TypeFunction::toCBuffer2() this = %p, ref = %d\n", this, isref); 3725 3749 const char *p = NULL; 3726 3750 … … 5001 5025 if (!s) 5002 5026 { 5003 return getProperty(e->loc, ident); 5027 if (ident == Id::max || 5028 ident == Id::min || 5029 ident == Id::init || 5030 ident == Id::stringof || 5031 !sym->memtype 5032 ) 5033 { 5034 return getProperty(e->loc, ident); 5035 } 5036 return sym->memtype->dotExp(sc, e, ident); 5004 5037 } 5005 5038 EnumMember *m = s->isEnumMember(); … … 5702 5735 { 5703 5736 Dsymbol *sm = (Dsymbol *)s->fields.data[i]; 5704 if (sm->hasPointers()) 5737 Declaration *d = sm->isDeclaration(); 5738 if (d->storage_class & STCref || d->hasPointers()) 5705 5739 return TRUE; 5706 5740 } trunk/src/mtype.h
r182 r183 284 284 285 285 static void error(Loc loc, const char *format, ...); 286 static void warning(Loc loc, const char *format, ...); 286 287 287 288 // For backend … … 812 813 extern int Tptrdiff_t; 813 814 815 int arrayTypeCompatible(Loc loc, Type *t1, Type *t2); 816 814 817 #endif /* DMD_MTYPE_H */ trunk/src/opover.c
r182 r183 23 23 #endif 24 24 25 #if IN_GCC 26 #include "mem.h" 27 #elif linux || __APPLE__ 28 #include "../root/mem.h" 29 #elif _WIN32 30 #include "..\root\mem.h" 31 #endif 25 #include "rmem.h" 32 26 33 27 //#include "port.h" trunk/src/parse.c
r181 r183 14 14 #include <assert.h> 15 15 16 #include " mem.h"16 #include "rmem.h" 17 17 #include "lexer.h" 18 18 #include "parse.h" … … 388 388 (tk = peek(&token))->value == TOKlparen && 389 389 skipParens(tk, &tk) && 390 peek(tk)->value == TOKlparen) 390 (peek(tk)->value == TOKlparen || 391 peek(tk)->value == TOKlcurly) 392 ) 391 393 { 392 394 a = parseDeclarations(storageClass); … … 1749 1751 Objects *Parser::parseTemplateArgumentList2() 1750 1752 { 1753 //printf("Parser::parseTemplateArgumentList2()\n"); 1751 1754 Objects *tiargs = new Objects(); 1752 1755 enum TOK endtok = TOKrparen; … … 3907 3910 3908 3911 #if V2 3909 if ((t->value == TOKconst || t->value == TOKinvariant || token.value == TOKimmutable || token.value == TOKshared) && 3912 if ((t->value == TOKconst || 3913 t->value == TOKinvariant || 3914 t->value == TOKimmutable || 3915 t->value == TOKshared) && 3910 3916 peek(t)->value != TOKlparen) 3911 3917 { /* const type … … 3918 3924 3919 3925 if (!isBasicType(&t)) 3926 { 3920 3927 goto Lisnot; 3928 } 3921 3929 if (!isDeclarator(&t, &haveId, endtok)) 3922 3930 goto Lisnot; … … 4042 4050 t = peek(t); 4043 4051 if (!isDeclaration(t, 0, TOKrparen, &t)) 4052 { 4044 4053 goto Lfalse; 4054 } 4045 4055 t = peek(t); 4046 4056 break; trunk/src/readme.txt
r5 r183 2 2 The D Programming Language 3 3 Compiler Front End Source 4 Copyright (c) 1999-200 2, by Digital Mars5 www.digitalmars.com4 Copyright (c) 1999-2009, by Digital Mars 5 http://www.digitalmars.com 6 6 All Rights Reserved 7 7 … … 10 10 It covers the lexical analysis, parsing, and semantic analysis 11 11 of the D Programming Language defined in the documents at 12 www.digitalmars.com/d/ 13 14 The optimizer, code generator, and object file generator are not part 15 of this source, hence the source does not currently constitute a complete, 16 compilable program. However, many people have expressed a strong interested 17 in producing a D compiler with the GNU compiler sources. This release should 18 enable that. 12 http://www.digitalmars.com/d/ 19 13 20 14 These sources are free, they are redistributable and modifiable … … 22 16 or the Artistic License (attached as artistic.txt). 23 17 18 The optimizer and code generator sources are 19 covered under a separate license, backendlicense.txt. 20 24 21 It does not apply to anything else distributed by Digital Mars, 25 22 including D compiler executables. trunk/src/root/array.c
r103 r183 38 38 #include "root.h" 39 39 #include "dchar.h" 40 #include " mem.h"40 #include "rmem.h" 41 41 42 42 trunk/src/root/dchar.c
r111 r183 15 15 16 16 #include "dchar.h" 17 #include " mem.h"17 #include "rmem.h" 18 18 19 19 #if M_UNICODE trunk/src/root/lstring.c
r179 r183 12 12 13 13 #include "dchar.h" 14 #include " mem.h"14 #include "rmem.h" 15 15 #include "lstring.h" 16 16 trunk/src/root/rmem.c
r182 r183 8 8 9 9 #if linux || __APPLE__ || __FreeBSD__ 10 #include "../root/ mem.h"10 #include "../root/rmem.h" 11 11 #else 12 #include " mem.h"12 #include "rmem.h" 13 13 #endif 14 14 trunk/src/root/root.c
r182 r183 37 37 #include "root.h" 38 38 #include "dchar.h" 39 #include " mem.h"39 #include "rmem.h" 40 40 41 41 #if 0 //__SC__ //def DEBUG trunk/src/root/stringtable.c
r172 r183 14 14 15 15 #include "root.h" 16 #include " mem.h"16 #include "rmem.h" 17 17 #include "dchar.h" 18 18 #include "lstring.h" trunk/src/scope.c
r169 r183 254 254 sc->enclosing->search(loc, ident, NULL)) 255 255 { 256 if (global.params.warnings) 257 fprintf(stdmsg, "warning - "); 258 error(s->loc, "array 'length' hides other 'length' name in outer scope"); 256 warning(s->loc, "array 'length' hides other 'length' name in outer scope"); 259 257 } 260 258 trunk/src/statement.c
r182 r183 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 13 13 #include <assert.h> 14 14 15 #include " mem.h"15 #include "rmem.h" 16 16 17 17 #include "statement.h" … … 95 95 ::verror(loc, format, ap); 96 96 va_end( ap ); 97 } 98 99 void Statement::warning(const char *format, ...) 100 { 101 if (global.params.warnings && !global.gag) 102 { 103 fprintf(stdmsg, "warning - "); 104 va_list ap; 105 va_start(ap, format); 106 ::verror(loc, format, ap); 107 va_end( ap ); 108 } 97 109 } 98 110 … … 544 556 if (!(result & BEfallthru) && !s->comeFrom()) 545 557 { 546 if (global.params.warnings) 547 { fprintf(stdmsg, "warning - "); 548 s->error("statement is not reachable"); 549 } 558 s->warning("statement is not reachable"); 550 559 } 551 560 … … 1091 1100 if (body) 1092 1101 { int r = body->blockExit(); 1093 if (r & BEbreak)1102 if (r & (BEbreak | BEgoto)) 1094 1103 result |= BEfallthru; 1095 result |= r & ~(BE break | BEcontinue);1104 result |= r & ~(BEfallthru | BEbreak | BEcontinue); 1096 1105 } 1097 1106 if (increment && increment->canThrow()) … … 1453 1462 Identifier *id = Identifier::generateId("__r"); 1454 1463 VarDeclaration *r = new VarDeclaration(loc, NULL, id, new ExpInitializer(loc, aggr)); 1455 r->semantic(sc); 1464 // r->semantic(sc); 1465 //printf("r: %s, init: %s\n", r->toChars(), r->init->toChars()); 1456 1466 Statement *init = new DeclarationStatement(loc, r); 1467 //printf("init: %s\n", init->toChars()); 1457 1468 1458 1469 // !__r.empty … … 1470 1481 e = new VarExp(loc, r); 1471 1482 Expression *einit = new DotIdExp(loc, e, idhead); 1472 einit = einit->semantic(sc);1483 // einit = einit->semantic(sc); 1473 1484 Argument *arg = (Argument *)arguments->data[0]; 1474 1485 VarDeclaration *ve = new VarDeclaration(loc, arg->type, arg->ident, new ExpInitializer(loc, einit)); … … 2456 2467 { hasNoDefault = 1; 2457 2468 2458 if (global.params.warnings) 2459 { fprintf(stdmsg, "warning - "); 2460 error("switch statement has no default"); 2461 } 2469 warning("switch statement has no default"); 2462 2470 2463 2471 // Generate runtime error if the default is hit trunk/src/statement.h
r180 r183 20 20 #include "arraytypes.h" 21 21 #include "dsymbol.h" 22 #include "lexer.h" 22 23 23 24 struct OutBuffer; … … 88 89 89 90 void error(const char *format, ...); 91 void warning(const char *format, ...); 90 92 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 91 93 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } trunk/src/struct.c
r182 r183 20 20 #include "id.h" 21 21 #include "statement.h" 22 #include "template.h" 22 23 23 24 /********************************* AggregateDeclaration ****************************/ … … 45 46 sinit = NULL; 46 47 scope = NULL; 48 isnested = 0; 49 vthis = NULL; 50 47 51 #if V2 48 dtor = NULL;49 50 52 ctor = NULL; 51 53 defaultCtor = NULL; 52 54 #endif 55 dtor = NULL; 53 56 } 54 57 … … 164 167 // Check for forward referenced types which will fail the size() call 165 168 Type *t = v->type->toBasetype(); 169 if (v->storage_class & STCref) 170 { // References are the size of a pointer 171 t = Type::tvoidptr; 172 } 166 173 if (t->ty == Tstruct /*&& isStructDeclaration()*/) 167 174 { TypeStruct *ts = (TypeStruct *)t; … … 185 192 } 186 193 187 memsize = v->type->size(loc);188 memalignsize = v->type->alignsize();189 xalign = v->type->memalign(sc->structalign);194 memsize = t->size(loc); 195 memalignsize = t->alignsize(); 196 xalign = t->memalign(sc->structalign); 190 197 alignmember(xalign, memalignsize, &sc->offset); 191 198 v->offset = sc->offset; … … 202 209 //printf(" addField '%s' to '%s' at offset %d, size = %d\n", v->toChars(), toChars(), v->offset, memsize); 203 210 fields.push(v); 211 } 212 213 214 /**************************************** 215 * Returns !=0 if there's an extra member which is the 'this' 216 * pointer to the enclosing context (enclosing aggregate or function) 217 */ 218 219 int AggregateDeclaration::isNested() 220 { 221 return isnested; 204 222 } 205 223 … … 282 300 if (sizeok == 0) // if not already done the addMember step 283 301 { 302 int hasfunctions = 0; 284 303 for (i = 0; i < members->dim; i++) 285 304 { … … 287 306 //printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars()); 288 307 s->addMember(sc, this, 1); 289 } 308 if (s->isFuncDeclaration()) 309 hasfunctions = 1; 310 } 311 312 // If nested struct, add in hidden 'this' pointer to outer scope 313 if (hasfunctions && !(storage_class & STCstatic)) 314 { Dsymbol *s = toParent2(); 315 if (s) 316 { 317 AggregateDeclaration *ad = s->isAggregateDeclaration(); 318 FuncDeclaration *fd = s->isFuncDeclaration(); 319 320 TemplateInstance *ti; 321 if (ad && (ti = ad->parent->isTemplateInstance()) != NULL && ti->isnested || fd) 322 { isnested = 1; 323 Type *t; 324 if (ad) 325 t = ad->handle; 326 else if (fd) 327 { AggregateDeclaration *ad = fd->isMember2(); 328 if (ad) 329 t = ad->handle; 330 else 331 t = Type::tvoidptr; 332 } 333 else 334 assert(0); 335 if (t->ty == Tstruct) 336 t = Type::tvoidptr; // t should not be a ref type 337 assert(!vthis); 338 vthis = new ThisDeclaration(t); 339 //vthis->storage_class |= STCref; 340 members->push(vthis); 341 } 342 } 343 } 290 344 } 291 345 … … 312 366 } 313 367 #endif 368 Type *t; 369 if (s->isDeclaration() && 370 (t = s->isDeclaration()->type) != NULL && 371 t->toBasetype()->ty == Tstruct) 372 { StructDeclaration *sd = (StructDeclaration *)t->toDsymbol(sc); 373 if (sd->isnested) 374 error("inner struct %s cannot be a field", sd->toChars()); 375 } 314 376 } 315 377 trunk/src/template.c
r181 r183 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 15 15 16 16 #include "root.h" 17 #include " mem.h"17 #include "rmem.h" 18 18 #include "stringtable.h" 19 19 … … 187 187 goto Lnomatch; 188 188 } 189 #if V2 189 190 VarDeclaration *v1 = s1->isVarDeclaration(); 190 191 VarDeclaration *v2 = s2->isVarDeclaration(); … … 195 196 goto Lnomatch; 196 197 } 198 #endif 197 199 } 198 200 else if (v1) … … 262 264 } 263 265 266 #if V2 264 267 Object *objectSyntaxCopy(Object *o) 265 268 { … … 274 277 return o; 275 278 } 279 #endif 276 280 277 281 … … 301 305 this->parameters = parameters; 302 306 this->origParameters = parameters; 307 #if V2 303 308 this->constraint = constraint; 309 #endif 304 310 this->members = decldefs; 305 311 this->overnext = NULL; … … 326 332 } 327 333 } 334 #if V2 328 335 Expression *e = NULL; 329 336 if (constraint) 330 337 e = constraint->syntaxCopy(); 338 #endif 331 339 d = Dsymbol::arraySyntaxCopy(members); 332 340 td = new TemplateDeclaration(loc, ident, p, e, d); … … 374 382 Scope *paramscope = sc->push(paramsym); 375 383 paramscope->parameterSpecialization = 1; 384 paramscope->stc = 0; 376 385 377 386 if (global.params.doDocComments) … … 534 543 paramsym->parent = scope->parent; 535 544 Scope *paramscope = scope->push(paramsym); 545 paramscope->stc = 0; 536 546 537 547 // Attempt type deduction … … 823 833 //printf("t = %p\n", t); 824 834 dedargs->data[parameters->dim - 1] = (void *)t; 835 declareParameter(paramscope, tp, t); 825 836 goto L2; 826 837 } … … 858 869 t->objects.data[i] = (void *)farg->type; 859 870 } 871 declareParameter(paramscope, tp, t); 860 872 goto L2; 861 873 } … … 1886 1898 Expression *e2 = isExpression(o2); 1887 1899 1900 Dsymbol *s1 = isDsymbol(o1); 1901 Dsymbol *s2 = isDsymbol(o2); 1902 1903 Tuple *v1 = isTuple(o1); 1904 Tuple *v2 = isTuple(o2); 1888 1905 #if 0 1889 1906 if (t1) printf("t1 = %s\n", t1->toChars()); … … 1891 1908 if (e1) printf("e1 = %s\n", e1->toChars()); 1892 1909 if (e2) printf("e2 = %s\n", e2->toChars()); 1910 if (s1) printf("s1 = %s\n", s1->toChars()); 1911 if (s2) printf("s2 = %s\n", s2->toChars()); 1912 if (v1) printf("v1 = %s\n", v1->toChars()); 1913 if (v2) printf("v2 = %s\n", v2->toChars()); 1893 1914 #endif 1894 1915 … … 1937 1958 } 1938 1959 } 1939 // BUG: Need to handle alias and tuple parameters 1960 else if (s1 && t2 && t2->ty == Tident) 1961 { 1962 j = templateParameterLookup(t2, parameters); 1963 if (j == -1) 1964 goto Lnomatch; 1965 TemplateParameter *tp = (TemplateParameter *)parameters->data[j]; 1966 // BUG: use tp->matchArg() instead of the following 1967 TemplateAliasParameter *ta = tp->isTemplateAliasParameter(); 1968 if (!ta) 1969 goto Lnomatch; 1970 Dsymbol *s = (Dsymbol *)dedtypes->data[j]; 1971 if (s) 1972 { 1973 if (!s1->equals(s)) 1974 goto Lnomatch; 1975 } 1976 else 1977 { 1978 dedtypes->data[j] = s1; 1979 } 1980 } 1981 else if (s1 && s2) 1982 { 1983 if (!s1->equals(s2)) 1984 goto Lnomatch; 1985 } 1986 // BUG: Need to handle tuple parameters 1940 1987 else 1941 1988 goto Lnomatch; … … 2571 2618 Lnomatch: 2572 2619 *psparam = NULL; 2620 //printf("\tm = %d\n", MATCHnomatch); 2573 2621 return MATCHnomatch; 2574 2622 } … … 3173 3221 } 3174 3222 3175 isNested(tiargs);3223 hasNestedArgs(tiargs); 3176 3224 3177 3225 /* See if there is an existing TemplateInstantiation that already … … 3256 3304 * see bugzilla 2500. 3257 3305 */ 3258 && !scx->module-> imports(scx->module)3306 && !scx->module->selfImports() 3259 3307 #endif 3260 3308 ) … … 3300 3348 argsym->parent = scope->parent; 3301 3349 scope = scope->push(argsym); 3350 // scope->stc = 0; 3302 3351 3303 3352 // Declare each template parameter as an alias for the argument type 3304 declareParameters(scope); 3353 Scope *paramscope = scope->push(); 3354 paramscope->stc = 0; 3355 declareParameters(paramscope); 3356 paramscope->pop(); 3305 3357 3306 3358 // Add members of template instance to template instance symbol table … … 3772 3824 */ 3773 3825 3774 int TemplateInstance:: isNested(Objects *args)3826 int TemplateInstance::hasNestedArgs(Objects *args) 3775 3827 { int nested = 0; 3776 //printf("TemplateInstance:: isNested('%s')\n", tempdecl->ident->toChars());3828 //printf("TemplateInstance::hasNestedArgs('%s')\n", tempdecl->ident->toChars()); 3777 3829 3778 3830 /* A nested instance happens when an argument references a local … … 3843 3895 else if (va) 3844 3896 { 3845 nested |= isNested(&va->objects);3897 nested |= hasNestedArgs(&va->objects); 3846 3898 } 3847 3899 } trunk/src/template.h
r174 r183 52 52 53 53 TemplateParameters *origParameters; // originals for Ddoc 54 54 #if V2 55 55 Expression *constraint; 56 56 #endif 57 57 Array instances; // array of TemplateInstance's 58 58 … … 64 64 65 65 TemplateDeclaration(Loc loc, Identifier *id, TemplateParameters *parameters, 66 Expression *constraint, Array *decldefs); 66 #if V2 67 Expression *constraint, 68 #endif 69 Array *decldefs); 67 70 Dsymbol *syntaxCopy(Dsymbol *); 68 71 void semantic(Scope *sc); … … 112 115 virtual TemplateValueParameter *isTemplateValueParameter(); 113 116 virtual TemplateAliasParameter *isTemplateAliasParameter(); 117 #if V2 114 118 virtual TemplateThisParameter *isTemplateThisParameter(); 119 #endif 115 120 virtual TemplateTupleParameter *isTemplateTupleParameter(); 116 121 … … 309 314 TemplateDeclaration *findBestMatch(Scope *sc); 310 315 void declareParameters(Scope *sc); 311 int isNested(Objects *tiargs);316 int hasNestedArgs(Objects *tiargs); 312 317 Identifier *genIdent(); 313 318 trunk/src/tocsym.c
r182 r183 27 27 #include "id.h" 28 28 29 #include <mem.h>29 #include "rmem.h" 30 30 31 31 // Back end trunk/src/todt.c
r182 r183 893 893 { 894 894 VarDeclaration *v = (VarDeclaration *)fields.data[i]; 895 Initializer *init;896 897 895 //printf("\tfield '%s' voffset %d, offset = %d\n", v->toChars(), v->offset, offset); 898 896 dt = NULL; 899 init = v->init; 900 if (init) 901 { //printf("\t\thas initializer %s\n", init->toChars()); 902 ExpInitializer *ei = init->isExpInitializer(); 903 Type *tb = v->type->toBasetype(); 904 if (ei && tb->ty == Tsarray) 905 ((TypeSArray *)tb)->toDtElem(&dt, ei->exp); 906 else 907 dt = init->toDt(); 908 } 909 else if (v->offset >= offset) 910 v->type->toDt(&dt); 897 int sz; 898 899 if (v->storage_class & STCref) 900 { 901 sz = PTRSIZE; 902 if (v->offset >= offset) 903 dtnzeros(&dt, sz); 904 } 905 else 906 { 907 sz = v->type->size(); 908 Initializer *init = v->init; 909 if (init) 910 { //printf("\t\thas initializer %s\n", init->toChars()); 911 ExpInitializer *ei = init->isExpInitializer(); 912 Type *tb = v->type->toBasetype(); 913 if (ei && tb->ty == Tsarray) 914 ((TypeSArray *)tb)->toDtElem(&dt, ei->exp); 915 else 916 dt = init->toDt(); 917 } 918 else if (v->offset >= offset) 919 v->type->toDt(&dt); 920 } 911 921 if (dt) 912 922 { … … 918 928 dtnzeros(pdt, v->offset - offset); 919 929 dtcat(pdt, dt); 920 offset = v->offset + v->type->size();930 offset = v->offset + sz; 921 931 } 922 932 } trunk/src/toir.c
r182 r183 32 32 #if _WIN32 33 33 #include "..\tk\mem.h" // for mem_malloc 34 #el if linux || __APPLE__34 #else 35 35 #include "../tk/mem.h" // for mem_malloc 36 36 #endif … … 188 188 } 189 189 else 190 { /* Enclosed by a class. That means the current191 * function must be a member function of that class.190 { /* Enclosed by an aggregate. That means the current 191 * function must be a member function of that aggregate. 192 192 */ 193 ClassDeclaration *cd = s->isClassDeclaration(); 194 if (!cd) 193 ClassDeclaration *cd; 194 StructDeclaration *sd; 195 AggregateDeclaration *ad = s->isAggregateDeclaration(); 196 if (!ad) 195 197 goto Lnoframe; 196 if (//cd->baseClass == fd ||197 fd->isClassDeclaration() &&198 cd = s->isClassDeclaration(); 199 if (cd && fd->isClassDeclaration() && 198 200 fd->isClassDeclaration()->isBaseOf(cd, NULL)) 199 201 break; 200 if (!cd->isNested() || !cd->vthis) 202 sd = s->isStructDeclaration(); 203 if (fd == sd) 204 break; 205 if (!ad->isNested() || !ad->vthis) 201 206 { 202 207 Lnoframe: … … 204 209 return el_long(TYnptr, 0); // error recovery 205 210 } 206 ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYint, cd->vthis->offset));211 ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYint, ad->vthis->offset)); 207 212 ethis = el_una(OPind, TYnptr, ethis); 208 213 if (fdparent == s->toParent2()) … … 250 255 251 256 257 /************************* 258 * Initialize the hidden aggregate member, vthis, with 259 * the context pointer. 260 * Returns: 261 * *(ey + ad.vthis.offset) = this; 262 */ 263 elem *setEthis(Loc loc, IRState *irs, elem *ey, AggregateDeclaration *ad) 264 { 265 elem *ethis; 266 FuncDeclaration *thisfd = irs->getFunc(); 267 int offset = 0; 268 Dsymbol *cdp = ad->toParent2(); // class/func we're nested in 269 270 //printf("setEthis(ad = %s, cdp = %s, thisfd = %s)\n", ad->toChars(), cdp->toChars(), thisfd->toChars()); 271 272 if (cdp == thisfd) 273 { /* Class we're new'ing is a local class in this function: 274 * void thisfd() { class ad { } } 275 */ 276 if (irs->sclosure) 277 ethis = el_var(irs->sclosure); 278 else if (irs->sthis) 279 { 280 #if V2 281 if (thisfd->closureVars.dim) 282 #else 283 if (thisfd->nestedFrameRef) 284 #endif 285 { 286 ethis = el_ptr(irs->sthis); 287 } 288 else 289 ethis = el_var(irs->sthis); 290 } 291 else 292 { 293 ethis = el_long(TYnptr, 0); 294 #if V2 295 if (thisfd->closureVars.dim) 296 #else 297 if (thisfd->nestedFrameRef) 298 #endif 299 { 300 ethis->Eoper = OPframeptr; 301 } 302 } 303 } 304 else if (thisfd->vthis && 305 (cdp == thisfd->toParent2() || 306 (cdp->isClassDeclaration() && 307 cdp->isClassDeclaration()->isBaseOf(thisfd->toParent2()->isClassDeclaration(), &offset) 308 ) 309 ) 310 ) 311 { /* Class we're new'ing is at the same level as thisfd 312 */ 313 assert(offset == 0); // BUG: should handle this case 314 ethis = el_var(irs->sthis); 315 } 316 else 317 { 318 ethis = getEthis(loc, irs, ad->toParent2()); 319 ethis = el_una(OPaddr, TYnptr, ethis); 320 } 321 322 ey = el_bin(OPadd, TYnptr, ey, el_long(TYint, ad->vthis->offset)); 323 ey = el_una(OPind, TYnptr, ey); 324 ey = el_bin(OPeq, TYnptr, ey, ethis); 325 return ey; 326 } 327 252 328 /******************************************* 253 329 * Convert intrinsic function to operator. … … 257 333 int intrinsic_op(char *name) 258 334 { 335 //printf("intrinsic_op(%s)\n", name); 259 336 static const char *namearray[] = 260 337 { 338 #if V1 261 339 "4math3cosFeZe", 262 340 "4math3sinFeZe", … … 269 347 "4math6rndtolFeZl", 270 348 271 #if V1272 349 "9intrinsic2btFPkkZi", 273 #else274 "9intrinsic2btFxPkkZi",275 #endif276 350 "9intrinsic3bsfFkZi", 277 351 "9intrinsic3bsrFkZi", … … 286 360 "9intrinsic5outplFkkZk", 287 361 "9intrinsic5outpwFktZt", 362 #elif V2 363 /* The names are mangled differently because of the pure and 364 * nothrow attributes. 365 */ 366 "4math3cosFNaNbeZe", 367 "4math3sinFNaNbeZe", 368 "4math4fabsFNaNbeZe", 369 "4math4rintFNaNbeZe", 370 "4math4sqrtFNaNbdZd", 371 "4math4sqrtFNaNbeZe", 372 "4math4sqrtFNaNbfZf", 373 "4math5ldexpFNaNbeiZe", 374 "4math6rndtolFNaNbeZl", 375 376 "9intrinsic2btFNaNbxPkkZi", 377 "9intrinsic3bsfFNaNbkZi", 378 "9intrinsic3bsrFNaNbkZi", 379 "9intrinsic3btcFNbPkkZi", 380 "9intrinsic3btrFNbPkkZi", 381 "9intrinsic3btsFNbPkkZi", 382 "9intrinsic3inpFNbkZh", 383 "9intrinsic4inplFNbkZk", 384 "9intrinsic4inpwFNbkZt", 385 "9intrinsic4outpFNbkhZh", 386 "9intrinsic5bswapFNaNbkZk", 387 "9intrinsic5outplFNbkkZk", 388 "9intrinsic5outpwFNbktZt", 389 #endif 288 390 }; 289 391 static unsigned char ioptab[] = … … 330 432 331 433 length = strlen(name); 332 if (length < 11 || memcmp(name, "_D3std", 6) != 0) 434 if (length < 11 || 435 !(name[7] == 'm' || name[7] == 'i') || 436 memcmp(name, "_D3std", 6) != 0) 333 437 return -1; 334 438 trunk/src/toir.h
r125 r183 1 1 2 // Copyright (c) 1999-200 6by Digital Mars2 // Copyright (c) 1999-2009 by Digital Mars 3 3 // All Rights Reserved 4 4 // written by Walter Bright … … 16 16 elem *incUsageElem(IRState *irs, Loc loc); 17 17 elem *getEthis(Loc loc, IRState *irs, Dsymbol *fd); 18 elem *setEthis(Loc loc, IRState *irs, elem *ey, AggregateDeclaration *ad); 18 19 int intrinsic_op(char *name); 19 20 elem *resolveLengthVar(VarDeclaration *lengthVar, elem **pe, Type *t1); trunk/src/toobj.c
r182 r183 26 26 #include "template.h" 27 27 28 #include <mem.h>28 #include "rmem.h" 29 29 #include "cc.h" 30 30 #include "global.h" … … 157 157 if (m->needModuleInfo()) 158 158 { Symbol *s = m->toSymbol(); 159 160 /* Weak references don't pull objects in from the library, 161 * they resolve to 0 if not pulled in by something else. 162 * Don't pull in a module just because it was imported. 163 */ 164 #if !OMFOBJ // Optlink crashes with weak symbols at EIP 41AFE7, 402000 159 165 s->Sflags |= SFLweak; 166 #endif 160 167 dtxoff(&dt, s, 0, TYnptr); 161 168 } … … 643 650 { 644 651 if (global.params.warnings) 645 { fprintf(stdmsg, "warning - ");652 { 646 653 TypeFunction *tf = (TypeFunction *)fd->type; 647 654 if (tf->ty == Tfunction) 648 error("%s%s is hidden by %s\n", fd->toPrettyChars(), Argument::argsTypesToChars(tf->parameters, tf->varargs), toChars());655 warning("%s%s is hidden by %s\n", fd->toPrettyChars(), Argument::argsTypesToChars(tf->parameters, tf->varargs), toChars()); 649 656 else 650 error("%s is hidden by %s\n", fd->toPrettyChars(), toChars());657 warning("%s is hidden by %s\n", fd->toPrettyChars(), toChars()); 651 658 } 652 659 s = rtlsym[RTLSYM_DHIDDENFUNC]; … … 927 934 sinit->Sclass = SCcomdat; 928 935 #else 929 if (parent && parent->isTemplateInstance()) 936 if (inTemplateInstance()) 937 { 930 938 sinit->Sclass = SCcomdat; 939 } 931 940 else 941 { 932 942 sinit->Sclass = SCglobal; 943 } 933 944 #endif 934 945 sinit->Sfl = FLdata; trunk/src/traits.c
r171 r183 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 13 13 #include <ctype.h> 14 14 #include <assert.h> 15 #if _MSC_VER 16 #include <complex> 17 #else 15 18 #include <complex.h> 19 #endif 16 20 #include <math.h> 17 21 … … 25 29 #endif 26 30 27 #if IN_GCC 28 #include "mem.h" 29 #elif _WIN32 30 #include "..\root\mem.h" 31 #elif linux 32 #include "../root/mem.h" 33 #endif 31 #include "rmem.h" 34 32 35 33 //#include "port.h" … … 54 52 #define LOGSEMANTIC 0 55 53 54 #if V2 55 56 56 /************************************************ 57 57 * Delegate to be passed to overloadApply() that looks … … 439 439 440 440 441 #endif trunk/src/typinf.c
r182 r183 28 28 #include "aggregate.h" 29 29 30 #include <mem.h>30 #include "rmem.h" 31 31 #include "cc.h" 32 32 #include "global.h"
