diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-26 10:52:31 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-26 12:17:49 -0700 |
| commit | f6cb66feab3439f41ca87cb307f69b49654883ab (patch) | |
| tree | d73c230a8b2ddc06e0fa978945aa8a838b189236 /source/slang/compiler.h | |
| parent | 6e99b81c98f8c76444563d959536073befc7d8ca (diff) | |
Check for re-import at translation-unit level
Previously the code checked for a duplicate `#import` using a data structure attached to the compile request, but this would fail for nested imports.
It also wouldn't work for a combination of `#import` and `__import`.
This change makes it so that we instead track a set of already-imported modules in the semantic checking visitor, which is instantiated once per translation unit.
We also key this set on the actual module (AST) imported, rather than on path/name/whatever, so hopefully it will be robust to the same thing getting imported multiple ways.
Diffstat (limited to 'source/slang/compiler.h')
| -rw-r--r-- | source/slang/compiler.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/slang/compiler.h b/source/slang/compiler.h index 7c4a17607..a6f3eee0e 100644 --- a/source/slang/compiler.h +++ b/source/slang/compiler.h @@ -203,9 +203,16 @@ namespace Slang RefPtr<ProgramLayout> layout; // Modules that have been dynamically loaded via `import` - Dictionary<String, RefPtr<ProgramSyntaxNode>> loadedModulesMap; + // + // This is a list of unique modules loaded, in the order they were encountered. List<RefPtr<ProgramSyntaxNode> > loadedModulesList; + // Map from the logical name of a module to its definition + Dictionary<String, RefPtr<ProgramSyntaxNode>> mapPathToLoadedModule; + + // Map from the path of a module file to its definition + Dictionary<String, RefPtr<ProgramSyntaxNode>> mapNameToLoadedModules; + CompileRequest(Session* session) : mSession(session) @@ -248,7 +255,6 @@ namespace Slang CodePosition const& loc); void handlePoundImport( - String const& name, String const& path, TokenList const& tokens); |
