private Task ScheduleSavePublicFacadeAndAstAsync( RuntimeModelContext runtimeModelContext, AbsolutePath path, string specPath, FileContent publicFacadeContent, SourceFileParseResult result) { Task savePublicFacadeTask = null; // Serializing public facade if available if (publicFacadeContent.IsValid) { m_statistics.PublicFacadeSerializationBlobSize.AddAtomic(publicFacadeContent.Length); using (m_statistics.PublicFacadeSaves.Start(specPath)) { savePublicFacadeTask = runtimeModelContext.FrontEndHost.FrontEndArtifactManager.SavePublicFacadeAsync(path, publicFacadeContent); } } else { savePublicFacadeTask = Task.FromResult <object>(null); } // Serializing AST var serializeAstTask = SerializeAndSaveAst(result, runtimeModelContext, specPath, path); return(Task.WhenAll(savePublicFacadeTask, serializeAstTask)); }
private async Task SerializeAndSaveAst(SourceFileParseResult result, RuntimeModelContext runtimeModelContext, string specPath, AbsolutePath path) { // Pooled stream can be released only when the blob is saved to disk using (var pooledStream = BuildXL.Utilities.Pools.MemoryStreamPool.GetInstance()) { byte[] serializedAst; using (m_statistics.SpecAstSerialization.Start(specPath)) { var stream = pooledStream.Instance; // TODO: change to a regular BuildXLWriter when we start serializing the qualifier table using (var writer = new QualifierTableAgnosticWriter( runtimeModelContext.QualifierTable, debug: false, stream: stream, leaveOpen: true, logStats: false)) { result.Serialize(writer); writer.Flush(); serializedAst = stream.GetBuffer(); } } // Saving AST using (m_statistics.AstSerializationSaves.Start(specPath)) { m_statistics.AstSerializationBlobSize.AddAtomic(pooledStream.Instance.Position); await runtimeModelContext.FrontEndHost.FrontEndArtifactManager.SaveAstAsync(path, ByteContent.Create(serializedAst, pooledStream.Instance.Position)); } } }
private static SourceFileParseResult DeserializeAst(RuntimeModelContext runtimeModelContext, ByteContent ast) { var stream = new MemoryStream(ast.Content, 0, ast.Length); // TODO: change to a regular BuildXLReader when we start serializing the qualifier table using (var reader = new QualifierTableAgnosticReader( runtimeModelContext.QualifierTable, stream: stream, debug: false, leaveOpen: false)) { var deserializedResult = SourceFileParseResult.Read( reader, runtimeModelContext.Globals, runtimeModelContext.ModuleRegistry, runtimeModelContext.PathTable); return(deserializedResult); } }