LLDB mainline
Namespaces | Macros | Functions
FormatterBytecode.cpp File Reference
#include "FormatterBytecode.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/ValueObject/ValueObject.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatProviders.h"
#include "llvm/Support/FormatVariadicDetails.h"
#include "FormatterBytecode.def"

Go to the source code of this file.

Namespaces

namespace  lldb_private
 A class that represents a running process on the host machine.
 
namespace  lldb_private::FormatterBytecode
 

Macros

#define DEFINE_OPCODE(OP, MNEMONIC, NAME)
 
#define DEFINE_SELECTOR(ID, NAME)
 
#define DEFINE_SIGNATURE(ID, NAME)
 
#define TYPE_CHECK(...)
 
#define BINOP_IMPL(OP, CHECK_ZERO)
 
#define BINOP(OP)   BINOP_IMPL(OP, false)
 
#define BINOP_CHECKZERO(OP)   BINOP_IMPL(OP, true)
 
#define SHIFTOP(OP, LEFT)
 
#define POP_VALOBJ(VALOBJ)
 

Functions

std::string lldb_private::toString (FormatterBytecode::OpCodes op)
 
std::string lldb_private::toString (FormatterBytecode::Selectors sel)
 
std::string lldb_private::toString (FormatterBytecode::Signatures sig)
 
std::string lldb_private::toString (const FormatterBytecode::DataStack &data)
 
static llvm::Error lldb_private::FormatterBytecode::FormatImpl (DataStack &data)
 Implement the @format function.
 
static llvm::Error lldb_private::FormatterBytecode::TypeCheck (llvm::ArrayRef< DataStackElement > data, DataType type)
 
static llvm::Error lldb_private::FormatterBytecode::TypeCheck (llvm::ArrayRef< DataStackElement > data, DataType type1, DataType type2)
 
static llvm::Error lldb_private::FormatterBytecode::TypeCheck (llvm::ArrayRef< DataStackElement > data, DataType type1, DataType type2, DataType type3)
 
llvm::Error lldb_private::FormatterBytecode::Interpret (std::vector< ControlStackElement > &control, DataStack &data, Selectors sel)
 

Macro Definition Documentation

◆ BINOP

#define BINOP (   OP)    BINOP_IMPL(OP, false)

◆ BINOP_CHECKZERO

#define BINOP_CHECKZERO (   OP)    BINOP_IMPL(OP, true)

◆ BINOP_IMPL

#define BINOP_IMPL (   OP,
  CHECK_ZERO 
)
Value:
{ \
TYPE_CHECK(Any, Any); \
auto y = data.PopAny(); \
if (std::holds_alternative<uint64_t>(y)) { \
if (CHECK_ZERO && !std::get<uint64_t>(y)) \
return error(#OP " by zero"); \
TYPE_CHECK(UInt); \
data.Push((uint64_t)(data.Pop<uint64_t>() OP std::get<uint64_t>(y))); \
} else if (std::holds_alternative<int64_t>(y)) { \
if (CHECK_ZERO && !std::get<int64_t>(y)) \
return error(#OP " by zero"); \
TYPE_CHECK(Int); \
data.Push((int64_t)(data.Pop<int64_t>() OP std::get<int64_t>(y))); \
} else \
return error("unsupported data types"); \
}
static llvm::raw_ostream & error(Stream &strm)
#define UInt(x)

◆ DEFINE_OPCODE

#define DEFINE_OPCODE (   OP,
  MNEMONIC,
  NAME 
)
Value:
case OP: { \
const char *s = MNEMONIC; \
return s ? s : #NAME; \
}

◆ DEFINE_SELECTOR

#define DEFINE_SELECTOR (   ID,
  NAME 
)
Value:
case ID: \
return "@" #NAME;
static char ID
Definition: HostInfoBase.h:37

◆ DEFINE_SIGNATURE

#define DEFINE_SIGNATURE (   ID,
  NAME 
)
Value:
case ID: \
return "@" #NAME;

◆ POP_VALOBJ

#define POP_VALOBJ (   VALOBJ)
Value:
auto VALOBJ = data.Pop<ValueObjectSP>(); \
if (!VALOBJ) \
return error("null object");
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:484

◆ SHIFTOP

#define SHIFTOP (   OP,
  LEFT 
)
Value:
{ \
TYPE_CHECK(Any, UInt); \
uint64_t y = data.Pop<uint64_t>(); \
if (y > 64) \
return error("shift out of bounds"); \
if (std::holds_alternative<uint64_t>(data.back())) { \
uint64_t x = data.Pop<uint64_t>(); \
data.Push(x OP y); \
} else if (std::holds_alternative<int64_t>(data.back())) { \
int64_t x = data.Pop<int64_t>(); \
if (x < 0 && LEFT) \
return error("left shift of negative value"); \
if (y > 64) \
return error("shift out of bounds"); \
data.Push(x OP y); \
} else \
return error("unsupported data types"); \
}

◆ TYPE_CHECK

#define TYPE_CHECK (   ...)
Value:
if (auto error = TypeCheck(data, __VA_ARGS__)) \
return error;