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#include "llvm/ADT/APSInt.h"
15
16namespace lldb_private {
17
19
20enum DataType : uint8_t {
23 Int, ///< Deprecated: use Integer.
24 UInt, ///< Deprecated: use Integer.
29};
30
31enum OpCodes : uint8_t {
32#define DEFINE_OPCODE(OP, MNEMONIC, NAME) op_##NAME = OP,
33#include "FormatterBytecode.def"
34#undef DEFINE_OPCODE
35};
36
37enum Selectors : uint8_t {
38#define DEFINE_SELECTOR(ID, NAME) sel_##NAME = ID,
39#include "FormatterBytecode.def"
40#undef DEFINE_SELECTOR
41};
42
43enum Signatures : uint8_t {
44#define DEFINE_SIGNATURE(ID, NAME) sig_##NAME = ID,
45#include "FormatterBytecode.def"
46#undef DEFINE_SIGNATURE
47};
48
49using ControlStackElement = llvm::StringRef;
50using ControlStack = std::vector<ControlStackElement>;
51// uint64_t and int64_t are kept for compatibility with the deprecated
52// uint/int opcodes. New code should instead use APSInt (op_lit_integer).
54 std::variant<std::string, uint64_t, int64_t, lldb::ValueObjectSP,
55 CompilerType, Selectors, llvm::APSInt>;
56struct DataStack : public std::vector<DataStackElement> {
57 DataStack() = default;
59 : std::vector<DataStackElement>({initial_value}) {}
60 void Push(DataStackElement el) { push_back(el); }
61 template <typename T> T Pop() {
62 T el = std::get<T>(back());
63 pop_back();
64 return el;
65 }
67 DataStackElement el = back();
68 pop_back();
69 return el;
70 }
71};
72
73llvm::Error Interpret(ControlStack &control, DataStack &data, Signatures sig);
74
75} // namespace FormatterBytecode
76
80
81} // namespace lldb_private
82
83#endif
Generic representation of a type in a programming language.
std::vector< ControlStackElement > ControlStack
std::variant< std::string, uint64_t, int64_t, lldb::ValueObjectSP, CompilerType, Selectors, llvm::APSInt > DataStackElement
llvm::Error Interpret(ControlStack &control, DataStack &data, Signatures sig)
@ Int
Deprecated: use Integer.
@ UInt
Deprecated: use Integer.
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)