Changeset 580:7824c21a58e3
- Timestamp:
- 09/06/08 06:27:27 (4 months ago)
- Files:
-
- dmd/mars.c (modified) (5 diffs)
- dmd/mars.h (modified) (1 diff)
- dmd/module.c (modified) (7 diffs)
- dmd/module.h (modified) (4 diffs)
- gen/toobj.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dmd/mars.c
r572 r580 456 456 break; 457 457 458 case 'q':459 if (p[3])460 goto Lerror;461 global.params.fqnPaths = 1;462 break;458 case 'q': 459 if (p[3]) 460 goto Lerror; 461 global.params.fqnNames = 1; 462 break; 463 463 464 464 case 0: … … 983 983 m = new Module((char *) files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration); 984 984 modules.push(m); 985 986 global.params.objfiles->push(m->objfile->name->str);987 985 } 988 986 … … 996 994 Module::rootModule = m; 997 995 m->importedFrom = m; 998 m->deleteObjFile();999 996 m->read(0); 1000 997 m->parse(); 998 m->buildTargetFiles(); 999 m->deleteObjFile(); 1001 1000 if (m->isDocFile) 1002 1001 { … … 1006 1005 modules.remove(i); 1007 1006 i--; 1008 1009 // Remove m's object file from list of object files1010 for (int j = 0; j < global.params.objfiles->dim; j++)1011 {1012 if (m->objfile->name->str == global.params.objfiles->data[j])1013 {1014 global.params.objfiles->remove(j);1015 break;1016 }1017 }1018 1019 if (global.params.objfiles->dim == 0)1020 global.params.link = 0;1021 1007 } 1022 1008 } … … 1121 1107 printf("code %s\n", m->toChars()); 1122 1108 if (global.params.obj) 1109 { 1123 1110 m->genobjfile(0); 1111 global.params.objfiles->push(m->objfile->name->str); 1112 } 1124 1113 if (global.errors) 1125 1114 m->deleteObjFile(); dmd/mars.h
r568 r580 149 149 char llvmAnnotate; 150 150 char useInlineAsm; 151 char fqn Paths; // use fully qualified object names151 char fqnNames; // use fully qualified object names 152 152 }; 153 153 dmd/module.c
r550 r580 59 59 { 60 60 FileName *srcfilename; 61 FileName *cfilename;62 FileName *hfilename;63 FileName *objfilename;64 FileName *llfilename;65 FileName *bcfilename;66 FileName *symfilename;67 61 68 62 // printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars()); … … 96 90 importedFrom = NULL; 97 91 srcfile = NULL; 92 objfile = NULL; 98 93 docfile = NULL; 94 hdrfile = NULL; 99 95 100 96 debuglevel = 0; … … 125 121 } 126 122 } 127 128 char *argobj;129 if (global.params.objname)130 argobj = global.params.objname;131 else if (global.params.preservePaths)132 argobj = filename;133 else134 argobj = FileName::name(filename);135 if (!FileName::absolute(argobj))136 {137 argobj = FileName::combine(global.params.objdir, argobj);138 }139 140 if (global.params.objname)141 objfilename = new FileName(argobj, 0);142 else143 objfilename = FileName::forceExt(argobj, global.obj_ext);144 145 llfilename = FileName::forceExt(argobj, global.ll_ext);146 bcfilename = FileName::forceExt(argobj, global.bc_ext);147 148 symfilename = FileName::forceExt(filename, global.sym_ext);149 150 123 srcfile = new File(srcfilename); 151 124 152 if (doDocComment)153 {154 setDocfile();155 }156 157 if (doHdrGen)158 {159 setHdrfile();160 }161 162 objfile = new File(objfilename);163 bcfile = new File(bcfilename);164 llfile = new File(llfilename);165 symfile = new File(symfilename);166 167 125 // LLVMDC 168 126 llvmForceLogging = false; 169 127 } 170 128 171 void Module::setDocfile() 172 { 173 FileName *docfilename; 174 char *argdoc; 175 176 if (global.params.docname) 177 argdoc = global.params.docname; 178 else if (global.params.preservePaths) 179 argdoc = (char *)arg; 129 File* Module::buildFilePath(char* forcename, char* path, char* ext) 130 { 131 char *argobj; 132 if (forcename) 133 argobj = forcename; 180 134 else 181 argdoc = FileName::name((char *)arg); 182 if (!FileName::absolute(argdoc)) 183 { //FileName::ensurePathExists(global.params.docdir); 184 argdoc = FileName::combine(global.params.docdir, argdoc); 185 } 186 if (global.params.docname) 187 docfilename = new FileName(argdoc, 0); 135 { 136 if (global.params.preservePaths) 137 argobj = (char*)this->arg; 138 else 139 argobj = FileName::name((char*)this->arg); 140 141 if (global.params.fqnNames) 142 if(md) 143 argobj = FileName::replaceName(argobj, md->toChars()); 144 else 145 argobj = FileName::replaceName(argobj, toChars()); 146 147 int clen = strlen(argobj); 148 char* tmp = (char *)alloca(clen + 2); 149 memcpy(tmp, argobj, clen); 150 tmp[clen] = '.'; 151 tmp[clen+1] = 0; 152 argobj = tmp; 153 } 154 155 if (!FileName::absolute(argobj)) 156 { 157 argobj = FileName::combine(path, argobj); 158 } 159 160 FileName::ensurePathExists(FileName::path(argobj)); 161 162 if (global.params.objname) 163 return new File(argobj); 188 164 else 189 docfilename = FileName::forceExt(argdoc, global.doc_ext); 190 191 if (docfilename->equals(srcfile->name)) 192 { error("Source file and documentation file have same name '%s'", srcfile->name->str); 193 fatal(); 194 } 195 196 docfile = new File(docfilename); 197 } 198 199 void Module::setHdrfile() 200 { 201 FileName *hdrfilename; 202 char *arghdr; 203 204 if (global.params.hdrname) 205 arghdr = global.params.hdrname; 206 else if (global.params.preservePaths) 207 arghdr = (char *)arg; 208 else 209 arghdr = FileName::name((char *)arg); 210 if (!FileName::absolute(arghdr)) 211 { //FileName::ensurePathExists(global.params.hdrdir); 212 arghdr = FileName::combine(global.params.hdrdir, arghdr); 213 } 214 if (global.params.hdrname) 215 hdrfilename = new FileName(arghdr, 0); 216 else 217 hdrfilename = FileName::forceExt(arghdr, global.hdr_ext); 218 219 if (hdrfilename->equals(srcfile->name)) 220 { error("Source file and 'header' file have same name '%s'", srcfile->name->str); 221 fatal(); 222 } 223 224 hdrfile = new File(hdrfilename); 165 return new File(FileName::forceExt(argobj, ext)); 166 } 167 168 void Module::buildTargetFiles() 169 { 170 if(objfile && docfile && hdrfile) 171 return; 172 173 objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext); 174 docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext); 175 hdrfile = Module::buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext); 225 176 } 226 177 … … 230 181 objfile->remove(); 231 182 //if (global.params.llvmBC) 232 bcfile->remove();183 //bcfile->remove(); 233 184 if (docfile) 234 185 docfile->remove(); … … 576 527 comment = buf + 4; 577 528 isDocFile = 1; 578 if (!docfile)579 setDocfile();580 529 return; 581 530 } … … 773 722 */ 774 723 724 // is this used anywhere? 725 /* 775 726 void Module::gensymfile() 776 727 { … … 794 745 795 746 symfile->writev(); 796 } 747 }*/ 797 748 798 749 /********************************** dmd/module.h
r486 r580 66 66 ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration 67 67 File *srcfile; // input source file 68 File *objfile; // output .obj file 68 69 File *objfile; // output object file 70 File *docfile; // output doc file 71 File *hdrfile; // output hdr file 69 72 70 // LLVMDC71 File *bcfile; // output .bc file72 File *llfile; // output .ll file73 74 File *hdrfile; // 'header' file75 File *symfile; // output symbol file76 File *docfile; // output documentation file77 73 unsigned errors; // if any errors in file 78 74 unsigned numlines; // number of lines in source file … … 122 118 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 123 119 const char *kind(); 124 void setDocfile(); // set docfile member125 120 void read(Loc loc); // read file 126 121 #if IN_GCC … … 133 128 void semantic3(); // pass 3 semantic analysis 134 129 void inlineScan(); // scan for functions to inline 135 void setHdrfile(); // set hdrfile member136 130 #ifdef _DH 137 131 void genhdrfile(); // generate D import file 138 132 #endif 139 133 void genobjfile(int multiobj); 140 void gensymfile();134 // void gensymfile(); 141 135 void gendocfile(); 142 136 int needModuleInfo(); … … 174 168 175 169 // LLVMDC 170 void buildTargetFiles(); 171 File* buildFilePath(char* forcename, char* path, char* ext); 176 172 Module *isModule() { return this; } 177 173 gen/toobj.cpp
r565 r580 165 165 // eventually do our own path stuff, dmd's is a bit strange. 166 166 typedef llvm::sys::Path LLPath; 167 LLPath bcpath; 168 LLPath llpath; 169 170 if (global.params.fqnPaths) 171 { 172 bcpath = LLPath(mname); 173 bcpath.appendSuffix("bc"); 174 175 llpath = LLPath(mname); 176 llpath.appendSuffix("ll"); 177 } 178 else 179 { 180 bcpath = LLPath(bcfile->name->toChars()); 181 llpath = LLPath(llfile->name->toChars()); 182 } 167 LLPath bcpath = LLPath(objfile->name->toChars()); 168 LLPath llpath = bcpath; 169 llpath.eraseSuffix(); 170 llpath.appendSuffix(std::string(global.ll_ext)); 183 171 184 172 // write bytecode … … 191 179 // disassemble ? 192 180 if (global.params.disassemble) { 193 Logger::println("Writing LLVM asm to: %s\n", ll file->name->toChars());181 Logger::println("Writing LLVM asm to: %s\n", llpath.c_str()); 194 182 std::ofstream aos(llpath.c_str()); 195 183 ir.module->print(aos, NULL);

