diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-23 16:39:46 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-23 16:39:46 -0800 |
| commit | 401d8cdb12ae69aeb216c80c9bb90240d8359649 (patch) | |
| tree | 4548c9de52bdeff424a0a3969ad407fccb3c0f09 /source/slang/slang-serialize-factory.cpp | |
| parent | 58eb6f7da01af1767282ee12b0b4b25c57e52afb (diff) | |
Add slangc interface to compile and use ir modules. (#3615)
* Add slangc interface to compile and use ir modules.
* Fix glsl scalar layout settings not copied to target.
* Fix.
* Cleanups.
Diffstat (limited to 'source/slang/slang-serialize-factory.cpp')
| -rw-r--r-- | source/slang/slang-serialize-factory.cpp | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/source/slang/slang-serialize-factory.cpp b/source/slang/slang-serialize-factory.cpp index 5eae5e740..e8cb82dc1 100644 --- a/source/slang/slang-serialize-factory.cpp +++ b/source/slang/slang-serialize-factory.cpp @@ -78,8 +78,14 @@ SerialIndex ModuleSerialFilter::writePointer(SerialWriter* writer, const NodeBas { ASTBuilder* astBuilder = m_moduleDecl->module->getASTBuilder(); - // It's a reference to a declaration in another module, so first get the symbol name. - String mangledName = getMangledName(astBuilder, decl); + // It's a reference to a declaration in another module, so first get the symbol name. + // Note that we will always name an import symbol in the form of + // <module_name>!<symbol_mangled_name> for serialization. + // This is because <symbol_mangled_name> does not necessarily include the name of its + // parent module when it is qualified as `extern` or `export`. + // + String mangledName = getText(moduleDecl->getName()) +"!"+ getMangledName(astBuilder, decl); + // Add as an import symbol return writer->addImportSymbol(mangledName); } @@ -89,34 +95,6 @@ SerialIndex ModuleSerialFilter::writePointer(SerialWriter* writer, const NodeBas return writer->writeObject(ptr); } } - - // TODO(JS): If I enable this section then the stdlib doesn't work correctly, it appears to be because of - // `addCatchAllIntrinsicDecorationIfNeeded`. If this is enabled when AST is serialized, the 'body' (ie Stmt) - // will not be serialized. When serialized back in, it will appear to be a function without a body. - // In that case `addCatchAllIntrinsicDecorationIfNeeded` will add an intrinsic which in some cases is incorrect. - // This happens during lowering. - // - // So it seems the fix is for some other mechanism. Another solution is perhaps to run something like `addCatchAllIntrinsicDecorationIfNeeded` - // on the stdlib after compilation, and before serialization. Then removing it from lowering. - -#if 0 - // TODO(JS): What we really want to do here is to ignore bodies functions. - // It's not 100% clear if this is even right though - for example does type inference - // imply the body is needed to say infer a return type? - // Also not clear if statements in other scenarios (if there are others) might need to be kept. - // - // For now we just ignore all stmts - - // TODO(yong): We should by default serialize everything. The logic to skip bodies need to be - // behind a option flag. - if (Stmt* stmt = as<Stmt>(ptr)) - { - // - writer->setPointerIndex(stmt, SerialIndex(0)); - return SerialIndex(0); - } -#endif - // For now for everything else just write it return writer->writeObject(ptr); } |
