From d898d561e3c76ecf38db434ec7fbb4bbd0e25cb2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 18 Nov 2020 14:52:58 -0500 Subject: Serialized stdlib working (#1603) * #include an absolute path didn't work - because paths were taken to always be relative. * Mangling/module name extraction for GenericDecl * Add comment on SerialFilter to explain re-enabling Stmt. * Support setting up SyntaxDecl when reconstructed after deserialization. * Improvements to setup SyntaxDecl. * Fix typo so can read compressed SourceLocs. * Fix issue with SourceManger. --- source/slang/slang-ast-decl.h | 4 +- source/slang/slang-mangle.cpp | 13 ++ source/slang/slang-mangled-lexer.cpp | 13 +- source/slang/slang-parser.cpp | 255 ++++++++++++++++------------ source/slang/slang-parser.h | 17 ++ source/slang/slang-serialize-container.cpp | 71 ++++++-- source/slang/slang-serialize-factory.cpp | 11 ++ source/slang/slang-serialize-source-loc.cpp | 3 +- source/slang/slang.cpp | 8 +- 9 files changed, 267 insertions(+), 128 deletions(-) (limited to 'source') diff --git a/source/slang/slang-ast-decl.h b/source/slang/slang-ast-decl.h index 2bf4c488b..5b8c6a2f1 100644 --- a/source/slang/slang-ast-decl.h +++ b/source/slang/slang-ast-decl.h @@ -468,8 +468,8 @@ class SyntaxDecl : public Decl SLANG_UNREFLECTED // Callback to invoke in order to parse syntax with this keyword. - SyntaxParseCallback parseCallback; - void* parseUserData; + SyntaxParseCallback parseCallback = nullptr; + void* parseUserData = nullptr; }; // A declaration of an attribute to be used with `[name(...)]` syntax. diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index ab90f4bc2..a08b05a5d 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -415,6 +415,19 @@ namespace Slang // declarations out of this... else if(as(decl)) emitRaw(context, "V"); + else if(DeclRef genericDecl = declRef.as()) + { + // Mark that this is a generic, so we can differentiate bewteen when + // mangling the generic and the inner entity + emitRaw(context, "G"); + + SLANG_ASSERT(genericDecl.substitutions == nullptr); + + auto innerDecl = makeDeclRef(getInner(genericDecl)); + + emitQualifiedName(context, innerDecl); + return; + } else { // TODO: handle other cases diff --git a/source/slang/slang-mangled-lexer.cpp b/source/slang/slang-mangled-lexer.cpp index 237f9f2a5..32a8fa741 100644 --- a/source/slang/slang-mangled-lexer.cpp +++ b/source/slang/slang-mangled-lexer.cpp @@ -187,9 +187,18 @@ UInt MangledLexer::readParamCount() { MangledLexer lexer(in); - if (lexer.peekChar() == 'T') { - lexer.nextChar(); + switch (lexer.peekChar()) + { + case 'T': + case 'G': + case 'V': + { + lexer.nextChar(); + break; + } + default: break; + } } UnownedStringSlice name = lexer.readRawStringSegment(); diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 4d93c35a8..12fa90480 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -590,7 +590,7 @@ namespace Slang return false; } - NodeBase* ParseTypeDef(Parser* parser, void* /*userData*/) + NodeBase* parseTypeDef(Parser* parser, void* /*userData*/) { TypeDefDecl* typeDefDecl = parser->astBuilder->create(); @@ -1214,7 +1214,7 @@ namespace Slang } } - static NodeBase* ParseGenericDecl(Parser* parser, void*) + static NodeBase* parseGenericDecl(Parser* parser, void*) { GenericDecl* decl = parser->astBuilder->create(); parser->FillPosition(decl); @@ -2420,7 +2420,7 @@ namespace Slang } } - static NodeBase* ParseExtensionDecl(Parser* parser, void* /*userData*/) + static NodeBase* parseExtensionDecl(Parser* parser, void* /*userData*/) { ExtensionDecl* decl = parser->astBuilder->create(); parser->FillPosition(decl); @@ -2770,7 +2770,7 @@ namespace Slang } } - static NodeBase* ParseSubscriptDecl(Parser* parser, void* /*userData*/) + static NodeBase* parseSubscriptDecl(Parser* parser, void* /*userData*/) { SubscriptDecl* decl = parser->astBuilder->create(); parser->FillPosition(decl); @@ -2814,7 +2814,7 @@ namespace Slang } } - static NodeBase* ParsePropertyDecl(Parser* parser, void* /*userData*/) + static NodeBase* parsePropertyDecl(Parser* parser, void* /*userData*/) { PropertyDecl* decl = parser->astBuilder->create(); parser->FillPosition(decl); @@ -3020,7 +3020,7 @@ namespace Slang // This is a catch-all syntax-construction callback to handle cases where // a piece of syntax is fully defined by the keyword to use, along with // the class of AST node to construct. - static NodeBase* parseSimpleSyntax(Parser* parser, void* userData) + NodeBase* parseSimpleSyntax(Parser* parser, void* userData) { SyntaxClassBase syntaxClass((ReflectClassInfo*) userData); return (NodeBase*)syntaxClass.createInstanceImpl(parser->astBuilder); @@ -5662,135 +5662,170 @@ namespace Slang return modifier; } - ModuleDecl* populateBaseLanguageModule( - ASTBuilder* astBuilder, - RefPtr scope) - { - Session* session = astBuilder->getGlobalSession(); - - ModuleDecl* moduleDecl = astBuilder->create(); - scope->containerDecl = moduleDecl; - - // Add syntax for declaration keywords - #define DECL(KEYWORD, CALLBACK) \ - addBuiltinSyntax(session, scope, #KEYWORD, &CALLBACK) - DECL(typedef, ParseTypeDef); - DECL(associatedtype, parseAssocType); - DECL(type_param, parseGlobalGenericTypeParamDecl); - DECL(cbuffer, parseHLSLCBufferDecl); - DECL(tbuffer, parseHLSLTBufferDecl); - DECL(__generic, ParseGenericDecl); - DECL(__extension, ParseExtensionDecl); - DECL(extension, ParseExtensionDecl); - DECL(__init, parseConstructorDecl); - DECL(__subscript, ParseSubscriptDecl); - DECL(property, ParsePropertyDecl); - DECL(interface, parseInterfaceDecl); - DECL(syntax, parseSyntaxDecl); - DECL(attribute_syntax,parseAttributeSyntaxDecl); - DECL(__import, parseImportDecl); - DECL(import, parseImportDecl); - DECL(let, parseLetDecl); - DECL(var, parseVarDecl); - DECL(func, parseFuncDecl); - DECL(typealias, parseTypeAliasDecl); - DECL(__generic_value_param, parseGlobalGenericValueParamDecl); - DECL(namespace, parseNamespaceDecl); - DECL(using, parseUsingDecl); - - #undef DECL + static SyntaxParseInfo _makeParseExpr(const char* keywordName, SyntaxParseCallback callback) + { + SyntaxParseInfo entry; + entry.classInfo = &Expr::kReflectClassInfo; + entry.keywordName = keywordName; + entry.callback = callback; + return entry; + } + static SyntaxParseInfo _makeParseDecl(const char* keywordName, SyntaxParseCallback callback) + { + SyntaxParseInfo entry; + entry.keywordName = keywordName; + entry.callback = callback; + entry.classInfo = &Decl::kReflectClassInfo; + return entry; + } + static SyntaxParseInfo _makeParseModifier(const char* keywordName, const ReflectClassInfo& classInfo) + { + // If we just have class info - use simple parser + SyntaxParseInfo entry; + entry.keywordName = keywordName; + entry.callback = &parseSimpleSyntax; + entry.classInfo = &classInfo; + return entry; + } + static SyntaxParseInfo _makeParseModifier(const char* keywordName, SyntaxParseCallback callback) + { + SyntaxParseInfo entry; + entry.keywordName = keywordName; + entry.callback = callback; + entry.classInfo = &Modifier::kReflectClassInfo; + return entry; + } + + // Maps a keyword to the associated parsing function + static const SyntaxParseInfo g_parseSyntaxEntries[] = + { + // !!!!!!!!!!!!!!!!!!!! Decls !!!!!!!!!!!!!!!!!! + + _makeParseDecl("typedef", parseTypeDef), + _makeParseDecl("associatedtype", parseAssocType), + _makeParseDecl("type_param", parseGlobalGenericTypeParamDecl ), + _makeParseDecl("cbuffer", parseHLSLCBufferDecl ), + _makeParseDecl("tbuffer", parseHLSLTBufferDecl ), + _makeParseDecl("__generic", parseGenericDecl ), + _makeParseDecl("__extension", parseExtensionDecl ), + _makeParseDecl("extension", parseExtensionDecl ), + _makeParseDecl("__init", parseConstructorDecl ), + _makeParseDecl("__subscript", parseSubscriptDecl ), + _makeParseDecl("property", parsePropertyDecl ), + _makeParseDecl("interface", parseInterfaceDecl ), + _makeParseDecl("syntax", parseSyntaxDecl ), + _makeParseDecl("attribute_syntax", parseAttributeSyntaxDecl ), + _makeParseDecl("__import", parseImportDecl ), + _makeParseDecl("import", parseImportDecl ), + _makeParseDecl("let", parseLetDecl ), + _makeParseDecl("var", parseVarDecl ), + _makeParseDecl("func", parseFuncDecl ), + _makeParseDecl("typealias", parseTypeAliasDecl ), + _makeParseDecl("__generic_value_param", parseGlobalGenericValueParamDecl ), + _makeParseDecl("namespace", parseNamespaceDecl ), + _makeParseDecl("using", parseUsingDecl ), + + // !!!!!!!!!!!!!!!!!!!!!! Modifer !!!!!!!!!!!!!!!!!!!!!! // Add syntax for "simple" modifier keywords. // These are the ones that just appear as a single // keyword (no further tokens expected/allowed), // and which can be represented just by creating // a new AST node of the corresponding type. - #define MODIFIER(KEYWORD, CLASS) \ - addSimpleModifierSyntax(session, scope, #KEYWORD) - - MODIFIER(in, InModifier); - MODIFIER(input, InputModifier); - MODIFIER(out, OutModifier); - MODIFIER(inout, InOutModifier); - MODIFIER(__ref, RefModifier); - MODIFIER(const, ConstModifier); - MODIFIER(instance, InstanceModifier); - MODIFIER(__builtin, BuiltinModifier); - - MODIFIER(inline, InlineModifier); - MODIFIER(public, PublicModifier); - MODIFIER(require, RequireModifier); - MODIFIER(param, ParamModifier); - MODIFIER(extern, ExternModifier); - - MODIFIER(row_major, HLSLRowMajorLayoutModifier); - MODIFIER(column_major, HLSLColumnMajorLayoutModifier); - - MODIFIER(nointerpolation, HLSLNoInterpolationModifier); - MODIFIER(noperspective, HLSLNoPerspectiveModifier); - MODIFIER(linear, HLSLLinearModifier); - MODIFIER(sample, HLSLSampleModifier); - MODIFIER(centroid, HLSLCentroidModifier); - MODIFIER(precise, PreciseModifier); - MODIFIER(shared, HLSLEffectSharedModifier); - MODIFIER(groupshared, HLSLGroupSharedModifier); - MODIFIER(static, HLSLStaticModifier); - MODIFIER(uniform, HLSLUniformModifier); - MODIFIER(volatile, HLSLVolatileModifier); + + _makeParseModifier("in", InModifier::kReflectClassInfo), + _makeParseModifier("input", InputModifier::kReflectClassInfo), + _makeParseModifier("out", OutModifier::kReflectClassInfo), + _makeParseModifier("inout", InOutModifier::kReflectClassInfo), + _makeParseModifier("__ref", RefModifier::kReflectClassInfo), + _makeParseModifier("const", ConstModifier::kReflectClassInfo), + _makeParseModifier("instance", InstanceModifier::kReflectClassInfo), + _makeParseModifier("__builtin", BuiltinModifier::kReflectClassInfo), + + _makeParseModifier("inline", InlineModifier::kReflectClassInfo), + _makeParseModifier("public", PublicModifier::kReflectClassInfo), + _makeParseModifier("require", RequireModifier::kReflectClassInfo), + _makeParseModifier("param", ParamModifier::kReflectClassInfo), + _makeParseModifier("extern", ExternModifier::kReflectClassInfo), + + _makeParseModifier("row_major", HLSLRowMajorLayoutModifier::kReflectClassInfo), + _makeParseModifier("column_major", HLSLColumnMajorLayoutModifier::kReflectClassInfo), + + _makeParseModifier("nointerpolation", HLSLNoInterpolationModifier::kReflectClassInfo), + _makeParseModifier("noperspective", HLSLNoPerspectiveModifier::kReflectClassInfo), + _makeParseModifier("linear", HLSLLinearModifier::kReflectClassInfo), + _makeParseModifier("sample", HLSLSampleModifier::kReflectClassInfo), + _makeParseModifier("centroid", HLSLCentroidModifier::kReflectClassInfo), + _makeParseModifier("precise", PreciseModifier::kReflectClassInfo), + _makeParseModifier("shared", HLSLEffectSharedModifier::kReflectClassInfo), + _makeParseModifier("groupshared", HLSLGroupSharedModifier::kReflectClassInfo), + _makeParseModifier("static", HLSLStaticModifier::kReflectClassInfo), + _makeParseModifier("uniform", HLSLUniformModifier::kReflectClassInfo), + _makeParseModifier("volatile", HLSLVolatileModifier::kReflectClassInfo), // Modifiers for geometry shader input - MODIFIER(point, HLSLPointModifier); - MODIFIER(line, HLSLLineModifier); - MODIFIER(triangle, HLSLTriangleModifier); - MODIFIER(lineadj, HLSLLineAdjModifier); - MODIFIER(triangleadj, HLSLTriangleAdjModifier); + _makeParseModifier("point", HLSLPointModifier::kReflectClassInfo), + _makeParseModifier("line", HLSLLineModifier::kReflectClassInfo), + _makeParseModifier("triangle", HLSLTriangleModifier::kReflectClassInfo), + _makeParseModifier("lineadj", HLSLLineAdjModifier::kReflectClassInfo), + _makeParseModifier("triangleadj", HLSLTriangleAdjModifier::kReflectClassInfo), // Modifiers for unary operator declarations - MODIFIER(__prefix, PrefixModifier); - MODIFIER(__postfix, PostfixModifier); + _makeParseModifier("__prefix", PrefixModifier::kReflectClassInfo), + _makeParseModifier("__postfix", PostfixModifier::kReflectClassInfo), // Modifier to apply to `import` that should be re-exported - MODIFIER(__exported, ExportedModifier); - - #undef MODIFIER + _makeParseModifier("__exported", ExportedModifier::kReflectClassInfo), // Add syntax for more complex modifiers, which allow // or expect more tokens after the initial keyword. - #define MODIFIER(KEYWORD, CALLBACK) \ - addBuiltinSyntax(session, scope, #KEYWORD, &CALLBACK) - MODIFIER(layout, parseLayoutModifier); + _makeParseModifier("layout", parseLayoutModifier), - MODIFIER(__intrinsic_op, parseIntrinsicOpModifier); - MODIFIER(__target_intrinsic, parseTargetIntrinsicModifier); - MODIFIER(__specialized_for_target, parseSpecializedForTargetModifier); - MODIFIER(__glsl_extension, parseGLSLExtensionModifier); - MODIFIER(__glsl_version, parseGLSLVersionModifier); - MODIFIER(__spirv_version, parseSPIRVVersionModifier); - MODIFIER(__cuda_sm_version, parseCUDASMVersionModifier); + _makeParseModifier("__intrinsic_op", parseIntrinsicOpModifier), + _makeParseModifier("__target_intrinsic", parseTargetIntrinsicModifier), + _makeParseModifier("__specialized_for_target", parseSpecializedForTargetModifier), + _makeParseModifier("__glsl_extension", parseGLSLExtensionModifier), + _makeParseModifier("__glsl_version", parseGLSLVersionModifier), + _makeParseModifier("__spirv_version", parseSPIRVVersionModifier), + _makeParseModifier("__cuda_sm_version", parseCUDASMVersionModifier), - MODIFIER(__builtin_type, parseBuiltinTypeModifier); - MODIFIER(__magic_type, parseMagicTypeModifier); - MODIFIER(__intrinsic_type, parseIntrinsicTypeModifier); - MODIFIER(__implicit_conversion, parseImplicitConversionModifier); + _makeParseModifier("__builtin_type", parseBuiltinTypeModifier), + _makeParseModifier("__magic_type", parseMagicTypeModifier), + _makeParseModifier("__intrinsic_type", parseIntrinsicTypeModifier), + _makeParseModifier("__implicit_conversion", parseImplicitConversionModifier), - MODIFIER(__attributeTarget, parseAttributeTargetModifier); + _makeParseModifier("__attributeTarget", parseAttributeTargetModifier), + // !!!!!!!!!!!!!!!!!!!!!!! Expr !!!!!!!!!!!!!!!!!!!!!!!!!!! -#undef MODIFIER + _makeParseExpr("this", parseThisExpr), + _makeParseExpr("This", parseThisTypeExpr), + _makeParseExpr("true", parseTrueExpr), + _makeParseExpr("false", parseFalseExpr), + _makeParseExpr("__TaggedUnion", parseTaggedUnionType), + }; - // Add syntax for expression keywords - #define EXPR(KEYWORD, CALLBACK) \ - addBuiltinSyntax(session, scope, #KEYWORD, &CALLBACK) + ConstArrayView getSyntaxParseInfos() + { + return makeConstArrayView(g_parseSyntaxEntries, SLANG_COUNT_OF(g_parseSyntaxEntries)); + } - EXPR(this, parseThisExpr); - EXPR(This, parseThisTypeExpr); - EXPR(true, parseTrueExpr); - EXPR(false, parseFalseExpr); - EXPR(__TaggedUnion, parseTaggedUnionType); + ModuleDecl* populateBaseLanguageModule( + ASTBuilder* astBuilder, + RefPtr scope) + { + Session* session = astBuilder->getGlobalSession(); - #undef EXPR + ModuleDecl* moduleDecl = astBuilder->create(); + scope->containerDecl = moduleDecl; + // Add syntax for declaration keywords + for (const auto& info : getSyntaxParseInfos()) + { + addBuiltinSyntaxImpl(session, scope, info.keywordName, info.callback, const_cast(info.classInfo), info.classInfo); + } + return moduleDecl; } diff --git a/source/slang/slang-parser.h b/source/slang/slang-parser.h index bcc0fb6e9..a1077d4a7 100644 --- a/source/slang/slang-parser.h +++ b/source/slang/slang-parser.h @@ -26,6 +26,23 @@ namespace Slang ModuleDecl* populateBaseLanguageModule( ASTBuilder* astBuilder, RefPtr scope); + + /// Information used to set up SyntaxDecl. Such decls + /// when correctly setup define a callback. For some of the callbacks it's necessary + /// for the `parseUserData` to be set the the associated classInfo + struct SyntaxParseInfo + { + const char* keywordName; ///< The keyword associated with this parse + SyntaxParseCallback callback; ///< The callback to apply to the parse + const ReflectClassInfo* classInfo; ///< + }; + + /// Get all of the predefined SyntaxParseInfos + ConstArrayView getSyntaxParseInfos(); + + /// Assumes the userInfo is the ReflectClassInfo + NodeBase* parseSimpleSyntax(Parser* parser, void* userData); + } #endif diff --git a/source/slang/slang-serialize-container.cpp b/source/slang/slang-serialize-container.cpp index 067e6637a..abdc382f9 100644 --- a/source/slang/slang-serialize-container.cpp +++ b/source/slang/slang-serialize-container.cpp @@ -12,6 +12,8 @@ #include "slang-serialize-source-loc.h" #include "slang-serialize-factory.h" +#include "slang-parser.h" + #include "slang-mangled-lexer.h" namespace Slang { @@ -490,27 +492,74 @@ static List& _getCandidateExtensionList( astRootNode = reader.getPointer(SerialIndex(1)).dynamicCast(); // 2) Add the extensions to the module mapTypeToCandidateExtensions cache + // 3) We need to fix the callback pointers for parsing { ModuleDecl* moduleDecl = as(astRootNode); - + + // Maps from keyword name name to index in (syntaxParseInfos) + // Will be filled in lazily if needed (for SyntaxDecl setup) + Dictionary syntaxKeywordDict; + + // Get the parse infos + const auto syntaxParseInfos = getSyntaxParseInfos(); + SLANG_ASSERT(syntaxParseInfos.getCount()); + for (auto& obj : reader.getObjects()) { - if (Type* type = obj.dynamicCast()) + if (obj.m_kind == SerialTypeKind::NodeBase) { - type->_setASTBuilder(astBuilder); - } + NodeBase* nodeBase = (NodeBase*)obj.m_ptr; + SLANG_ASSERT(nodeBase); - if (ExtensionDecl* extensionDecl = obj.dynamicCast()) - { - if (auto targetDeclRefType = as(extensionDecl->targetType)) + if (Type* type = dynamicCast(nodeBase)) + { + type->_setASTBuilder(astBuilder); + } + else if (ExtensionDecl* extensionDecl = dynamicCast(nodeBase)) { - // Attach our extension to that type as a candidate... - if (auto aggTypeDeclRef = targetDeclRefType->declRef.as()) + if (auto targetDeclRefType = as(extensionDecl->targetType)) { - auto aggTypeDecl = aggTypeDeclRef.getDecl(); + // Attach our extension to that type as a candidate... + if (auto aggTypeDeclRef = targetDeclRefType->declRef.as()) + { + auto aggTypeDecl = aggTypeDeclRef.getDecl(); - _getCandidateExtensionList(aggTypeDecl, moduleDecl->mapTypeToCandidateExtensions).add(extensionDecl); + _getCandidateExtensionList(aggTypeDecl, moduleDecl->mapTypeToCandidateExtensions).add(extensionDecl); + } + } + } + else if (SyntaxDecl* syntaxDecl = dynamicCast(nodeBase)) + { + // Set up the dictionary lazily + if (syntaxKeywordDict.Count() == 0) + { + NamePool* namePool = options.session->getNamePool(); + for (Index i = 0; i < syntaxParseInfos.getCount(); ++i) + { + const auto& entry = syntaxParseInfos[i]; + syntaxKeywordDict.Add(namePool->getName(entry.keywordName), i); + } + // Must have something in it at this point + SLANG_ASSERT(syntaxKeywordDict.Count()); + } + + // Look up the index + Index* entryIndexPtr = syntaxKeywordDict.TryGetValue(syntaxDecl->getName()); + if (entryIndexPtr) + { + // Set up SyntaxDecl based on the ParseSyntaxIndo + auto& info = syntaxParseInfos[*entryIndexPtr]; + syntaxDecl->parseCallback = *info.callback; + syntaxDecl->parseUserData = const_cast(info.classInfo); + } + else + { + // If we don't find a setup entry, we use `parseSimpleSyntax`, and set + // the parseUserData to the ReflectClassInfo (as parseSimpleSyntax needs this) + syntaxDecl->parseCallback = &parseSimpleSyntax; + SLANG_ASSERT(syntaxDecl->syntaxClass.classInfo); + syntaxDecl->parseUserData = const_cast(syntaxDecl->syntaxClass.classInfo); } } } diff --git a/source/slang/slang-serialize-factory.cpp b/source/slang/slang-serialize-factory.cpp index 3ff536137..9b3ba9994 100644 --- a/source/slang/slang-serialize-factory.cpp +++ b/source/slang/slang-serialize-factory.cpp @@ -86,6 +86,16 @@ SerialIndex ModuleSerialFilter::writePointer(SerialWriter* writer, const NodeBas } } + // 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? @@ -99,6 +109,7 @@ SerialIndex ModuleSerialFilter::writePointer(SerialWriter* writer, const NodeBas writer->setPointerIndex(stmt, SerialIndex(0)); return SerialIndex(0); } +#endif // For now for everything else just write it return writer->writeObject(ptr); diff --git a/source/slang/slang-serialize-source-loc.cpp b/source/slang/slang-serialize-source-loc.cpp index 7e9cca106..331ca96ae 100644 --- a/source/slang/slang-serialize-source-loc.cpp +++ b/source/slang/slang-serialize-source-loc.cpp @@ -156,7 +156,7 @@ void SerialSourceLocWriter::write(SerialSourceLocData* outSourceLocData) SerialStringTableUtil::encodeStringTable(m_stringSlicePool, outSourceLocData->m_stringTable); } -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DebugSerialReader !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SerialSourceLocReader !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ Index SerialSourceLocReader::findViewIndex(SerialSourceLocData::SourceLoc loc) { @@ -393,6 +393,7 @@ SlangResult SerialSourceLocReader::read(const SerialSourceLocData* serialData, S SLANG_RETURN_ON_FAIL(SerialRiffUtil::readArrayUncompressedChunk(dataChunk, m_adjustedLineInfos)); break; } + case SLANG_MAKE_COMPRESSED_FOUR_CC(SerialSourceLocData::kDebugSourceInfoFourCc): case SerialSourceLocData::kDebugSourceInfoFourCc: { SLANG_RETURN_ON_FAIL(SerialRiffUtil::readArrayChunk(moduleCompressionType, dataChunk, m_sourceInfos)); diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index ea17a0cf7..6f670167d 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -195,7 +195,9 @@ void Session::init() // Set up options SerialContainerUtil::WriteOptions options; - //options.optionFlags |= SerialOptionFlag::SourceLocation; + + options.optionFlags |= SerialOptionFlag::SourceLocation; + // TODO(JS): Should this be the Session::getBuiltinSourceManager() options.sourceManager = m_builtinLinkage->getSourceManager(); StringBuilder builder; @@ -249,6 +251,8 @@ SlangResult Session::_readBuiltinModule(Scope* scope, String moduleName) Linkage* linkage = getBuiltinLinkage(); + SourceManager* sourceManger = getBuiltinSourceManager(); + NamePool* sessionNamePool = &namePool; NamePool* linkageNamePool = linkage->getNamePool(); @@ -256,7 +260,7 @@ SlangResult Session::_readBuiltinModule(Scope* scope, String moduleName) options.namePool = linkageNamePool; options.session = this; options.sharedASTBuilder = linkage->getASTBuilder()->getSharedASTBuilder(); - options.sourceManager = linkage->getSourceManager(); + options.sourceManager = sourceManger; options.linkage = linkage; // Hmm - don't have a suitable sink yet, so attempt to just not have one -- cgit v1.2.3