================
@@ -251,3 +254,150 @@ std::string ScriptedSyntheticChildren::GetDescription() {
 
   return std::string(sstr.GetString());
 }
+
+BytecodeSyntheticChildren::FrontEnd::FrontEnd(
+    ValueObject &backend,
+    FormatterBytecode::SyntheticProviderDefinition &definition)
+    : SyntheticChildrenFrontEnd(backend), m_definition(definition) {
+  FormatterBytecode::DataStack data(backend.GetSP());
+  if (!m_definition.init) {
+    m_self = std::move(data);
+    return;
+  }
+
+  FormatterBytecode::ControlStack control = {m_definition.init->getBuffer()};
+  llvm::Error error =
+      FormatterBytecode::Interpret(control, data, FormatterBytecode::sig_init);
+  if (error) {
+    LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), std::move(error),
+                   "@init failed: {0}");
+    return;
+  }
+
+  if (data.size() > 0)
+    m_self = std::move(data);
+}
+
+lldb::ChildCacheState BytecodeSyntheticChildren::FrontEnd::Update() {
+  if (!m_definition.update)
+    return ChildCacheState::eRefetch;
+
+  FormatterBytecode::ControlStack control = {m_definition.update->getBuffer()};
+  FormatterBytecode::DataStack data = m_self;
+  llvm::Error error = FormatterBytecode::Interpret(
+      control, data, FormatterBytecode::sig_update);
+  if (error) {
+    LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), std::move(error),
+                   "@update failed: {0}");
+    return ChildCacheState::eRefetch;
+  }
+
+  if (data.size() > 0)
+    m_self = std::move(data);
+
+  return ChildCacheState::eRefetch;
+}
+
+llvm::Expected<uint32_t>
----------------
Michael137 wrote:

High-level question for all of these `SyntheticFrontend` implementations: do we 
re-interpret the bytecode everytime these are called? Should there be some 
level of "caching"? In the existing formatters I was under the impression that 
`Update` is the expensive thing that computes all the info we need to answer 
the other APIs efficiently. And LLDB makes sure to call `Update` in such a way 
that children information doesn't become stale

https://github.com/llvm/llvm-project/pull/179832
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to