================
@@ -251,3 +253,122 @@ 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()};
+  auto error =
+      FormatterBytecode::Interpret(control, data, FormatterBytecode::sig_init);
+
+  if (!error && 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;
+  auto error = FormatterBytecode::Interpret(control, data,
+                                            FormatterBytecode::sig_update);
+  if (!error && data.size() > 0)
+    m_self = std::move(data);
+
+  return ChildCacheState::eRefetch;
+}
+
+llvm::Expected<uint32_t>
+BytecodeSyntheticChildren::FrontEnd::CalculateNumChildren() {
+  if (!m_definition.num_children)
+    return 0;
+
+  FormatterBytecode::ControlStack control = {
+      m_definition.num_children->getBuffer()};
+  FormatterBytecode::DataStack data = m_self;
+  auto error = FormatterBytecode::Interpret(
+      control, data, FormatterBytecode::sig_get_num_children);
+  if (error)
+    return error;
+
+  if (data.size() == 0)
+    return llvm::createStringError(
+        "@get_num_children returned empty data stack");
+
+  const auto &top = data.back();
----------------
adrian-prantl wrote:

let's spell out the type again

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