1 
2 /* Compiler implementation of the D programming language
3  * Copyright (C) 2010-2019 by The D Language Foundation, All Rights Reserved
4  * written by Walter Bright
5  * http://www.digitalmars.com
6  * Distributed under the Boost Software License, Version 1.0.
7  * http://www.boost.org/LICENSE_1_0.txt
8  * https://github.com/D-Programming-Language/dmd/blob/master/src/imphint.c
9  */
10 
11 
12 #include "root/dsystem.h"
13 
14 #include "mars.h"
15 
16 /******************************************
17  * Looks for undefined identifier s to see
18  * if it might be undefined because an import
19  * was not specified.
20  * Not meant to be a comprehensive list of names in each module,
21  * just the most common ones.
22  */
23 
importHint(const char * s)24 const char *importHint(const char *s)
25 {
26     static const char *modules[] =
27     {   "core.stdc.stdio",
28         "std.stdio",
29         "std.math",
30         NULL
31     };
32     static const char *names[] =
33     {
34         "printf", NULL,
35         "writeln", NULL,
36         "sin", "cos", "sqrt", "fabs", NULL,
37     };
38     int m = 0;
39     for (int n = 0; modules[m]; n++)
40     {
41         const char *p = names[n];
42         if (p == NULL)
43         {
44             m++;
45             continue;
46         }
47         assert(modules[m]);
48         if (strcmp(s, p) == 0)
49             return modules[m];
50     }
51     return NULL;        // didn't find it
52 }
53