diff dmd/scope.c @ 1640:9bf06e02070b

Merge DMD 1.057.
author Christian Kamm <kamm incasoftware de>
date Mon, 08 Mar 2010 21:39:20 +0100
parents def7a1d494fd
children
line wrap: on
line diff
--- a/dmd/scope.c	Mon Mar 08 20:09:18 2010 +0100
+++ b/dmd/scope.c	Mon Mar 08 21:39:20 2010 +0100
@@ -1,5 +1,5 @@
 
-// Copyright (c) 1999-2005 by Digital Mars
+// Copyright (c) 1999-2010 by Digital Mars
 // All Rights Reserved
 // written by Walter Bright
 // http://www.digitalmars.com
@@ -11,6 +11,7 @@
 #include <assert.h>
 
 #include "root.h"
+#include "speller.h"
 
 #include "mars.h"
 #include "init.h"
@@ -361,3 +362,27 @@
 	    //assert(0);
     }
 }
+
+
+/************************************************
+ * Given the failed search attempt, try to find
+ * one with a close spelling.
+ */
+
+void *scope_search_fp(void *arg, const char *seed)
+{
+    //printf("scope_search_fp('%s')\n", seed);
+    Scope *sc = (Scope *)arg;
+    Identifier id(seed, 0);
+    Module::clearCache();
+    Dsymbol *s = sc->search(0, &id, NULL);
+    return s;
+}
+
+Dsymbol *Scope::search_correct(Identifier *ident)
+{
+    if (global.gag)
+	return NULL;		// don't do it for speculative compiles; too time consuming
+
+    return (Dsymbol *)speller(ident->toChars(), &scope_search_fp, this, idchars);
+}