diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-06-26 13:47:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-26 13:47:08 -0700 |
| commit | 0259ddb0a72d3b12278404847f6e30b63e97cfc3 (patch) | |
| tree | d73c230a8b2ddc06e0fa978945aa8a838b189236 /source/slang/check.cpp | |
| parent | 3f316dcbd9274efc74f817cf36f17a511ff2e21e (diff) | |
| parent | f6cb66feab3439f41ca87cb307f69b49654883ab (diff) | |
Merge pull request #43 from tfoleyNV/import-macros
Add support for `#import`
Diffstat (limited to 'source/slang/check.cpp')
| -rw-r--r-- | source/slang/check.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 463052bc8..582f19448 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -52,6 +52,14 @@ namespace Slang // lexical outer statements List<StatementSyntaxNode*> outerStmts; + + // We need to track what has been `import`ed, + // to avoid importing the same thing more than once + // + // TODO: a smarter approach might be to filter + // out duplicate references during lookup. + HashSet<ProgramSyntaxNode*> importedModules; + public: SemanticsVisitor( DiagnosticSink * pErr, @@ -4909,6 +4917,15 @@ namespace Slang // it later during code generation. decl->importedModuleDecl = importedModuleDecl; + // If we've imported this one already, then + // skip the step where we modify the current scope. + if (importedModules.Contains(importedModuleDecl.Ptr())) + { + return; + } + importedModules.Add(importedModuleDecl.Ptr()); + + // Create a new sub-scope to wire the module // into our lookup chain. auto subScope = new Scope(); |
