Changeset 408
- Timestamp:
- 03/04/10 21:50:26 (2 years ago)
- Files:
-
- branches/dmd-1.x/src/dsymbol.c (modified) (3 diffs)
- branches/dmd-1.x/src/dsymbol.h (modified) (2 diffs)
- branches/dmd-1.x/src/expression.c (modified) (1 diff)
- branches/dmd-1.x/src/module.c (modified) (2 diffs)
- branches/dmd-1.x/src/module.h (modified) (1 diff)
- branches/dmd-1.x/src/mtype.c (modified) (2 diffs)
- branches/dmd-1.x/src/root/speller.c (added)
- branches/dmd-1.x/src/root/speller.h (added)
- branches/dmd-1.x/src/scope.c (modified) (3 diffs)
- branches/dmd-1.x/src/scope.h (modified) (1 diff)
- branches/dmd-1.x/src/template.c (modified) (1 diff)
- branches/dmd-1.x/src/win32.mak (modified) (3 diffs)
- trunk/src/dsymbol.c (modified) (4 diffs)
- trunk/src/dsymbol.h (modified) (1 diff)
- trunk/src/expression.c (modified) (3 diffs)
- trunk/src/module.c (modified) (1 diff)
- trunk/src/module.h (modified) (1 diff)
- trunk/src/mtype.c (modified) (1 diff)
- trunk/src/root/speller.c (added)
- trunk/src/root/speller.h (added)
- trunk/src/scope.c (modified) (3 diffs)
- trunk/src/scope.h (modified) (1 diff)
- trunk/src/template.c (modified) (1 diff)
- trunk/src/win32.mak (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/dsymbol.c
r253 r408 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-20 09by Digital Mars3 // Copyright (c) 1999-2010 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 14 14 15 15 #include "rmem.h" 16 #include "speller.h" 16 17 17 18 #include "mars.h" … … 331 332 //printf("Dsymbol::search(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars()); 332 333 return NULL; 334 } 335 336 /*************************************************** 337 * Search for symbol with correct spelling. 338 */ 339 340 void *symbol_search_fp(void *arg, const char *seed) 341 { 342 Dsymbol *s = (Dsymbol *)arg; 343 Identifier id(seed, 0); 344 Module::clearCache(); 345 s = s->search(0, &id, 4|2); 346 return s; 347 } 348 349 Dsymbol *Dsymbol::search_correct(Identifier *ident) 350 { 351 if (global.gag) 352 return NULL; // don't do it for speculative compiles; too time consuming 353 354 return (Dsymbol *)speller(ident->toChars(), &symbol_search_fp, this, idchars); 333 355 } 334 356 branches/dmd-1.x/src/dsymbol.h
r342 r408 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-20 09by Digital Mars3 // Copyright (c) 1999-2010 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 148 148 virtual void inlineScan(); 149 149 virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); 150 Dsymbol *search_correct(Identifier *id); 150 151 Dsymbol *searchX(Loc loc, Scope *sc, Identifier *id); 151 152 virtual int overloadInsert(Dsymbol *s); branches/dmd-1.x/src/expression.c
r405 r408 2092 2092 return e->semantic(sc); 2093 2093 } 2094 error("undefined identifier %s", ident->toChars()); 2094 #if DMDV2 2095 if (ident == Id::ctfe) 2096 { // Create the magic __ctfe bool variable 2097 VarDeclaration *vd = new VarDeclaration(loc, Type::tbool, Id::ctfe, NULL); 2098 Expression *e = new VarExp(loc, vd); 2099 e = e->semantic(sc); 2100 return e; 2101 } 2102 #endif 2103 2104 s = sc->search_correct(ident); 2105 if (s) 2106 error("undefined identifier %s, did you mean %s %s?", ident->toChars(), s->kind(), s->toChars()); 2107 else 2108 error("undefined identifier %s", ident->toChars()); 2095 2109 type = Type::terror; 2096 2110 return this; branches/dmd-1.x/src/module.c
r342 r408 865 865 int Module::needModuleInfo() 866 866 { 867 //printf("needModuleInfo() %s, %d, %d\n", toChars(), needmoduleinfo, global.params.cov); 867 868 return needmoduleinfo || global.params.cov; 868 869 } … … 903 904 } 904 905 906 void Module::clearCache() 907 { 908 for (int i = 0; i < amodules.dim; i++) 909 { Module *m = (Module *)amodules.data[i]; 910 m->searchCacheIdent = NULL; 911 } 912 } 905 913 906 914 /******************************************* branches/dmd-1.x/src/module.h
r342 r408 142 142 void addDeferredSemantic(Dsymbol *s); 143 143 static void runDeferredSemantic(); 144 static void clearCache(); 144 145 int imports(Module *m); 145 146 branches/dmd-1.x/src/mtype.c
r382 r408 593 593 { 594 594 error(loc, ".size property should be replaced with .sizeof"); 595 e = new IntegerExp(loc, size(loc), Type::tsize_t);595 e = new ErrorExp(); 596 596 } 597 597 else if (ident == Id::alignof) … … 631 631 else 632 632 { 633 error(loc, "no property '%s' for type '%s'", ident->toChars(), toChars()); 634 e = new IntegerExp(loc, 1, Type::tint32); 633 Dsymbol *s = NULL; 634 if (ty == Tstruct || ty == Tclass || ty == Tenum || ty == Ttypedef) 635 s = toDsymbol(NULL); 636 if (s) 637 s = s->search_correct(ident); 638 if (s) 639 error(loc, "no property '%s' for type '%s', did you mean '%s'?", ident->toChars(), toChars(), s->toChars()); 640 else 641 error(loc, "no property '%s' for type '%s'", ident->toChars(), toChars()); 642 e = new ErrorExp(); 635 643 } 636 644 return e; branches/dmd-1.x/src/scope.c
r294 r408 1 1 2 // Copyright (c) 1999-20 05by Digital Mars2 // Copyright (c) 1999-2010 by Digital Mars 3 3 // All Rights Reserved 4 4 // written by Walter Bright … … 12 12 13 13 #include "root.h" 14 #include "speller.h" 14 15 15 16 #include "mars.h" … … 360 361 } 361 362 } 363 364 365 /************************************************ 366 * Given the failed search attempt, try to find 367 * one with a close spelling. 368 */ 369 370 void *scope_search_fp(void *arg, const char *seed) 371 { 372 //printf("scope_search_fp('%s')\n", seed); 373 Scope *sc = (Scope *)arg; 374 Identifier id(seed, 0); 375 Module::clearCache(); 376 Dsymbol *s = sc->search(0, &id, NULL); 377 return s; 378 } 379 380 Dsymbol *Scope::search_correct(Identifier *ident) 381 { 382 if (global.gag) 383 return NULL; // don't do it for speculative compiles; too time consuming 384 385 return (Dsymbol *)speller(ident->toChars(), &scope_search_fp, this, idchars); 386 } branches/dmd-1.x/src/scope.h
r243 r408 111 111 112 112 Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym); 113 Dsymbol *search_correct(Identifier *ident); 113 114 Dsymbol *insert(Dsymbol *s); 114 115 branches/dmd-1.x/src/template.c
r351 r408 3660 3660 s = sc->search(loc, id, &scopesym); 3661 3661 if (!s) 3662 { error("template '%s' is not defined", id->toChars()); 3662 { 3663 s = sc->search_correct(id); 3664 if (s) 3665 error("template '%s' is not defined, did you mean %s?", id->toChars(), s->toChars()); 3666 else 3667 error("template '%s' is not defined", id->toChars()); 3663 3668 return NULL; 3664 3669 } branches/dmd-1.x/src/win32.mak
r262 r408 97 97 98 98 ROOTOBJS= lstring.obj array.obj gnuc.obj man.obj rmem.obj port.obj root.obj \ 99 stringtable.obj dchar.obj response.obj async.obj 99 stringtable.obj dchar.obj response.obj async.obj speller.obj 100 100 101 101 OBJS= $(OBJ1) $(OBJ8) $(ROOTOBJS) … … 150 150 $(ROOT)\stringtable.h $(ROOT)\stringtable.c \ 151 151 $(ROOT)\gnuc.h $(ROOT)\gnuc.c $(ROOT)\man.c $(ROOT)\port.c \ 152 $(ROOT)\response.c $(ROOT)\async.h $(ROOT)\async.c 152 $(ROOT)\response.c $(ROOT)\async.h $(ROOT)\async.c \ 153 $(ROOT)\speller.h $(ROOT)\speller.c 153 154 154 155 MAKEFILES=win32.mak linux.mak osx.mak freebsd.mak solaris.mak … … 420 421 response.obj : $(ROOT)\response.c 421 422 $(CC) -c $(CFLAGS) $(ROOT)\response.c 423 424 speller.obj : $(ROOT)\speller.h $(ROOT)\speller.c 425 $(CC) -c $(CFLAGS) $(ROOT)\speller.c 422 426 423 427 stringtable.obj : $(ROOT)\stringtable.c trunk/src/dsymbol.c
r402 r408 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-20 09by Digital Mars3 // Copyright (c) 1999-2010 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 14 14 15 15 #include "rmem.h" 16 #include "speller.h" 16 17 17 18 #include "mars.h" … … 331 332 //printf("Dsymbol::search(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars()); 332 333 return NULL; 334 } 335 336 /*************************************************** 337 * Search for symbol with correct spelling. 338 */ 339 340 void *symbol_search_fp(void *arg, const char *seed) 341 { 342 Dsymbol *s = (Dsymbol *)arg; 343 Identifier id(seed, 0); 344 Module::clearCache(); 345 s = s->search(0, &id, 4|2); 346 return s; 347 } 348 349 Dsymbol *Dsymbol::search_correct(Identifier *ident) 350 { 351 if (global.gag) 352 return NULL; // don't do it for speculative compiles; too time consuming 353 354 return (Dsymbol *)speller(ident->toChars(), &symbol_search_fp, this, idchars); 333 355 } 334 356 … … 1203 1225 assert(tab); 1204 1226 #endif 1227 //printf("DsymbolTable::lookup(%s)\n", (char*)ident->string); 1205 1228 StringValue *sv = tab->lookup((char*)ident->string, ident->len); 1206 1229 return (Dsymbol *)(sv ? sv->ptrvalue : NULL); trunk/src/dsymbol.h
r402 r408 150 150 virtual void inlineScan(); 151 151 virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); 152 Dsymbol *search_correct(Identifier *id); 152 153 Dsymbol *searchX(Loc loc, Scope *sc, Identifier *id); 153 154 virtual int overloadInsert(Dsymbol *s); trunk/src/expression.c
r406 r408 2258 2258 return e; 2259 2259 } 2260 error("undefined identifier %s", ident->toChars()); 2260 2261 s = sc->search_correct(ident); 2262 if (s) 2263 error("undefined identifier %s, did you mean %s %s?", ident->toChars(), s->kind(), s->toChars()); 2264 else 2265 error("undefined identifier %s", ident->toChars()); 2261 2266 type = Type::terror; 2262 2267 return this; … … 5861 5866 * the current module should have access to its own imports. 5862 5867 */ 5863 Dsymbol *s = ie->sds->search(loc, ident, //0);5868 Dsymbol *s = ie->sds->search(loc, ident, 5864 5869 (ie->sds->isModule() && ie->sds != sc->module) ? 1 : 0); 5865 5870 if (s) … … 10652 10657 if (t1n->constOf() != t2n->constOf() && 10653 10658 !((t1n->ty == Tchar || t1n->ty == Twchar || t1n->ty == Tdchar) && 10654 (t2n->ty == Tchar || t2n->ty == Twchar || t2n->ty == Tdchar)) 10659 (t2n->ty == Tchar || t2n->ty == Twchar || t2n->ty == Tdchar)) && 10660 !(t1n->ty == Tvoid || t2n->ty == Tvoid) 10655 10661 ) 10656 10662 { /* Rewrite as: trunk/src/module.c
r393 r408 913 913 } 914 914 915 void Module::clearCache() 916 { 917 for (int i = 0; i < amodules.dim; i++) 918 { Module *m = (Module *)amodules.data[i]; 919 m->searchCacheIdent = NULL; 920 } 921 } 915 922 916 923 /******************************************* trunk/src/module.h
r395 r408 145 145 void addDeferredSemantic(Dsymbol *s); 146 146 static void runDeferredSemantic(); 147 static void clearCache(); 147 148 int imports(Module *m); 148 149 trunk/src/mtype.c
r407 r408 1647 1647 else 1648 1648 { 1649 error(loc, "no property '%s' for type '%s'", ident->toChars(), toChars()); 1649 Dsymbol *s = NULL; 1650 if (ty == Tstruct || ty == Tclass || ty == Tenum || ty == Ttypedef) 1651 s = toDsymbol(NULL); 1652 if (s) 1653 s = s->search_correct(ident); 1654 if (s) 1655 error(loc, "no property '%s' for type '%s', did you mean '%s'?", ident->toChars(), toChars(), s->toChars()); 1656 else 1657 error(loc, "no property '%s' for type '%s'", ident->toChars(), toChars()); 1650 1658 e = new ErrorExp(); 1651 1659 } trunk/src/scope.c
r294 r408 1 1 2 // Copyright (c) 1999-20 05by Digital Mars2 // Copyright (c) 1999-2010 by Digital Mars 3 3 // All Rights Reserved 4 4 // written by Walter Bright … … 12 12 13 13 #include "root.h" 14 #include "speller.h" 14 15 15 16 #include "mars.h" … … 360 361 } 361 362 } 363 364 365 /************************************************ 366 * Given the failed search attempt, try to find 367 * one with a close spelling. 368 */ 369 370 void *scope_search_fp(void *arg, const char *seed) 371 { 372 //printf("scope_search_fp('%s')\n", seed); 373 Scope *sc = (Scope *)arg; 374 Identifier id(seed, 0); 375 Module::clearCache(); 376 Dsymbol *s = sc->search(0, &id, NULL); 377 return s; 378 } 379 380 Dsymbol *Scope::search_correct(Identifier *ident) 381 { 382 if (global.gag) 383 return NULL; // don't do it for speculative compiles; too time consuming 384 385 return (Dsymbol *)speller(ident->toChars(), &scope_search_fp, this, idchars); 386 } trunk/src/scope.h
r242 r408 111 111 112 112 Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym); 113 Dsymbol *search_correct(Identifier *ident); 113 114 Dsymbol *insert(Dsymbol *s); 114 115 trunk/src/template.c
r402 r408 4044 4044 s = sc->search(loc, id, &scopesym); 4045 4045 if (!s) 4046 { error("template '%s' is not defined", id->toChars()); 4046 { 4047 s = sc->search_correct(id); 4048 if (s) 4049 error("template '%s' is not defined, did you mean %s?", id->toChars(), s->toChars()); 4050 else 4051 error("template '%s' is not defined", id->toChars()); 4047 4052 return NULL; 4048 4053 } trunk/src/win32.mak
r258 r408 7 7 D= 8 8 DMDSVN=\svnproj\dmd\trunk\src 9 #DMDSVN=\svnproj\dmd\branches\dmd-1.x\src 9 10 SCROOT=$D\dm 10 11 INCLUDE=$(SCROOT)\include … … 96 97 97 98 ROOTOBJS= lstring.obj array.obj gnuc.obj man.obj rmem.obj port.obj root.obj \ 98 stringtable.obj dchar.obj response.obj async.obj 99 stringtable.obj dchar.obj response.obj async.obj speller.obj 99 100 100 101 OBJS= $(OBJ1) $(OBJ8) $(ROOTOBJS) … … 149 150 $(ROOT)\stringtable.h $(ROOT)\stringtable.c \ 150 151 $(ROOT)\gnuc.h $(ROOT)\gnuc.c $(ROOT)\man.c $(ROOT)\port.c \ 151 $(ROOT)\response.c $(ROOT)\async.h $(ROOT)\async.c 152 $(ROOT)\response.c $(ROOT)\async.h $(ROOT)\async.c \ 153 $(ROOT)\speller.h $(ROOT)\speller.c 152 154 153 155 MAKEFILES=win32.mak linux.mak osx.mak freebsd.mak solaris.mak … … 419 421 response.obj : $(ROOT)\response.c 420 422 $(CC) -c $(CFLAGS) $(ROOT)\response.c 423 424 speller.obj : $(ROOT)\speller.h $(ROOT)\speller.c 425 $(CC) -c $(CFLAGS) $(ROOT)\speller.c 421 426 422 427 stringtable.obj : $(ROOT)\stringtable.c
