From f6cb66feab3439f41ca87cb307f69b49654883ab Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 26 Jun 2017 10:52:31 -0700 Subject: 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. --- source/slang/compiler.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source/slang/compiler.h') 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 layout; // Modules that have been dynamically loaded via `import` - Dictionary> loadedModulesMap; + // + // This is a list of unique modules loaded, in the order they were encountered. List > loadedModulesList; + // Map from the logical name of a module to its definition + Dictionary> mapPathToLoadedModule; + + // Map from the path of a module file to its definition + Dictionary> 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); -- cgit v1.2.3