From 494e09af2cebafa34db49dc1f60afd43aebed619 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 29 Oct 2020 11:45:56 -0400 Subject: Handling imported/exporting symbols from serialized modules (#1589) * #include an absolute path didn't work - because paths were taken to always be relative. * Fix handling of access modifiers inside type definition. * Fix access problem for AST node. Make dumping produce a single function with switch, to potentially make available without Dump specific access. * WIP on serialization design doc. * Remove project references to previously generated files. * More docs on serialization design. * Improve serialization documentation. Remove unused function from IRSerialReader. * Small fixes around naming. Remove long comment from slang-serialize.h - as covered in serialization.md * Remove long comment in slang-serialize.h as covered in serialization.md * More information about doing replacements on read for AST and problems surrounding. * Typo fix. * Spelling fixes. * Value serialize. * Value types with inheritence. * Use value reflection serial conversion for more AST types * Use automatic serialization on more of AST. * Get the types via decltype, simplifies what the extractor has to do. * Update the serialization.md for the value serialization. * Small doc improvements. * Update project. * Remove ImportExternalDecl type Added addImportSymbol and ImportSymbol type Fixed bug in container which meant it wouldn't read back AST module * Because of change of how imports and handled, store objects as SerialPointers. * First pass symbol lookup from mangled names. * Cache current module looked up from mangled name. * Fix SourceLoc bug. Improve comments. * Added diagnostic on mangled symbol not being found * Fix typo. Co-authored-by: Tim Foley --- source/slang/slang-mangled-lexer.h | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'source/slang/slang-mangled-lexer.h') diff --git a/source/slang/slang-mangled-lexer.h b/source/slang/slang-mangled-lexer.h index 6c8060cfd..7d096e45e 100644 --- a/source/slang/slang-mangled-lexer.h +++ b/source/slang/slang-mangled-lexer.h @@ -3,6 +3,7 @@ #define SLANG_MANGLED_LEXER_H_INCLUDED #include "../core/slang-basic.h" +#include "../core/slang-char-util.h" #include "slang-compiler.h" @@ -41,6 +42,12 @@ public: UInt readParamCount(); + /// Returns the character at the current position + char peekChar() { return *m_cursor; } + // Returns the current character and moves to next character. + char nextChar() { return *m_cursor++; } + + /// Ctor SLANG_FORCE_INLINE MangledLexer(const UnownedStringSlice& slice); @@ -50,13 +57,6 @@ private: // to strip off the main prefix void _start() { _expect("_S"); } - static bool _isDigit(char c) { return (c >= '0') && (c <= '9'); } - - /// Returns the character at the current position - char _peek() { return *m_cursor; } - // Returns the current character and moves to next character. - char _next() { return *m_cursor++; } - SLANG_INLINE void _expect(char c); void _expect(char const* str) @@ -82,10 +82,10 @@ SLANG_FORCE_INLINE MangledLexer::MangledLexer(const UnownedStringSlice& slice) // --------------------------------------------------------------------------- SLANG_INLINE void MangledLexer::readSimpleIntVal() { - int c = _peek(); - if (_isDigit((char)c)) + int c = peekChar(); + if (CharUtil::isDigit((char)c)) { - _next(); + nextChar(); } else { @@ -110,9 +110,9 @@ SLANG_INLINE void MangledLexer::readExtensionSpec() // --------------------------------------------------------------------------- SLANG_INLINE void MangledLexer::_expect(char c) { - if (_peek() == c) + if (peekChar() == c) { - _next(); + nextChar(); } else { @@ -121,5 +121,13 @@ SLANG_INLINE void MangledLexer::_expect(char c) } } +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! MangledNameParser !!!!!!!!!!!!!!!!!!!!!!!!!! + +struct MangledNameParser +{ + /// Tries to extract the module name from this mangled name. + static SlangResult parseModuleName(const UnownedStringSlice& in, UnownedStringSlice& outModuleName); +}; + } #endif -- cgit v1.2.3