diff options
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 29b46c805..26a846d6d 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -968,6 +968,24 @@ void FrontEndCompileRequest::parseTranslationUnit( translationUnitSyntax->module = module; module->setModuleDecl(translationUnitSyntax); + // When compiling a module of code that belongs to the Slang + // standard library, we add a modifier to the module to act + // as a marker, so that downstream code can detect declarations + // that came from the standard library (by walking up their + // chain of ancestors and looking for the marker), and treat + // them differently from user declarations. + // + // We are adding the marker here, before we even parse the + // code in the module, in case the subsequent steps would + // like to treat the standard library differently. Alternatiely + // we could pass down the `m_isStandardLibraryCode` flag to + // these passes. + // + if( m_isStandardLibraryCode ) + { + translationUnitSyntax->modifiers.first = new FromStdLibModifier(); + } + for (auto sourceFile : translationUnit->getSourceFiles()) { auto tokens = preprocessSource( @@ -2570,7 +2588,7 @@ void Session::addBuiltinSource( RefPtr<FrontEndCompileRequest> compileRequest = new FrontEndCompileRequest( m_builtinLinkage, &sink); - + compileRequest->m_isStandardLibraryCode = true; // Set the source manager on the sink sink.sourceManager = sourceManager; @@ -2602,16 +2620,6 @@ void Session::addBuiltinSource( // Extract the AST for the code we just parsed auto syntax = compileRequest->translationUnits[translationUnitIndex]->getModuleDecl(); - // HACK(tfoley): mark all declarations in the "stdlib" so - // that we can detect them later (e.g., so we don't emit them) - for (auto m : syntax->Members) - { - auto fromStdLibModifier = new FromStdLibModifier(); - - fromStdLibModifier->next = m->modifiers.first; - m->modifiers.first = fromStdLibModifier; - } - // Add the resulting code to the appropriate scope if (!scope->containerDecl) { |
