Path: blob/main/contrib/llvm-project/lldb/source/DataFormatters/FormatterBytecode.h
213764 views
//===-- FormatterBytecode.h -------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/DataFormatters/TypeSummary.h"9#include "lldb/Symbol/CompilerType.h"1011namespace lldb_private {1213namespace FormatterBytecode {1415enum DataType : uint8_t { Any, String, Int, UInt, Object, Type, Selector };1617enum OpCodes : uint8_t {18#define DEFINE_OPCODE(OP, MNEMONIC, NAME) op_##NAME = OP,19#include "FormatterBytecode.def"20#undef DEFINE_OPCODE21};2223enum Selectors : uint8_t {24#define DEFINE_SELECTOR(ID, NAME) sel_##NAME = ID,25#include "FormatterBytecode.def"26#undef DEFINE_SELECTOR27};2829enum Signatures : uint8_t {30#define DEFINE_SIGNATURE(ID, NAME) sig_##NAME = ID,31#include "FormatterBytecode.def"32#undef DEFINE_SIGNATURE33};3435using ControlStackElement = llvm::StringRef;36using DataStackElement =37std::variant<std::string, uint64_t, int64_t, lldb::ValueObjectSP,38CompilerType, Selectors>;39struct DataStack : public std::vector<DataStackElement> {40DataStack() = default;41DataStack(lldb::ValueObjectSP initial_value)42: std::vector<DataStackElement>({initial_value}) {}43void Push(DataStackElement el) { push_back(el); }44template <typename T> T Pop() {45T el = std::get<T>(back());46pop_back();47return el;48}49DataStackElement PopAny() {50DataStackElement el = back();51pop_back();52return el;53}54};55llvm::Error Interpret(std::vector<ControlStackElement> &control,56DataStack &data, Selectors sel);57} // namespace FormatterBytecode5859std::string toString(FormatterBytecode::OpCodes op);60std::string toString(FormatterBytecode::Selectors sel);61std::string toString(FormatterBytecode::Signatures sig);6263} // namespace lldb_private646566