LLDB mainline
FormatterBytecode.h
Go to the documentation of this file.
1//===-- FormatterBytecode.h -------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_DATAFORMATTERS_FORMATTERBYTECODE_H
10#define LLDB_DATAFORMATTERS_FORMATTERBYTECODE_H
11
14
15namespace lldb_private {
16
18
19enum DataType : uint8_t { Any, String, Int, UInt, Object, Type, Selector };
20
21enum OpCodes : uint8_t {
22#define DEFINE_OPCODE(OP, MNEMONIC, NAME) op_##NAME = OP,
23#include "FormatterBytecode.def"
24#undef DEFINE_OPCODE
25};
26
27enum Selectors : uint8_t {
28#define DEFINE_SELECTOR(ID, NAME) sel_##NAME = ID,
29#include "FormatterBytecode.def"
30#undef DEFINE_SELECTOR
31};
32
33enum Signatures : uint8_t {
34#define DEFINE_SIGNATURE(ID, NAME) sig_##NAME = ID,
35#include "FormatterBytecode.def"
36#undef DEFINE_SIGNATURE
37};
38
39using ControlStackElement = llvm::StringRef;
40using ControlStack = std::vector<ControlStackElement>;
42 std::variant<std::string, uint64_t, int64_t, lldb::ValueObjectSP,
44struct DataStack : public std::vector<DataStackElement> {
45 DataStack() = default;
47 : std::vector<DataStackElement>({initial_value}) {}
48 void Push(DataStackElement el) { push_back(el); }
49 template <typename T> T Pop() {
50 T el = std::get<T>(back());
51 pop_back();
52 return el;
53 }
55 DataStackElement el = back();
56 pop_back();
57 return el;
58 }
59};
60
61llvm::Error Interpret(ControlStack &control, DataStack &data, Signatures sig);
62
63} // namespace FormatterBytecode
64
68
69} // namespace lldb_private
70
71#endif
Generic representation of a type in a programming language.
std::vector< ControlStackElement > ControlStack
llvm::Error Interpret(ControlStack &control, DataStack &data, Signatures sig)
std::variant< std::string, uint64_t, int64_t, lldb::ValueObjectSP, CompilerType, Selectors > DataStackElement
A class that represents a running process on the host machine.
std::string toString(FormatterBytecode::OpCodes op)
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
DataStack(lldb::ValueObjectSP initial_value)