14#ifndef LLDB_SYMBOL_POSTFIXEXPRESSION_H
15#define LLDB_SYMBOL_POSTFIXEXPRESSION_H
17#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/Allocator.h"
19#include "llvm/Support/Casting.h"
163template <
typename ResultT =
void>
class Visitor {
179 return Visit(llvm::cast<BinaryOpNode>(*node), node);
181 return Visit(llvm::cast<InitialValueNode>(*node), node);
183 return Visit(llvm::cast<IntegerNode>(*node), node);
185 return Visit(llvm::cast<RegisterNode>(*node), node);
187 return Visit(llvm::cast<SymbolNode>(*node), node);
189 return Visit(llvm::cast<UnaryOpNode>(*node), node);
191 llvm_unreachable(
"Fully covered switch!");
206template <
typename T,
typename...
Args>
208 static_assert(std::is_trivially_destructible<T>::value,
209 "This object will not be destroyed!");
210 return new (alloc.Allocate<T>()) T(std::forward<Args>(args)...);
217std::vector<std::pair<llvm::StringRef, Node *>>
A command line argument class.
A stream class that can stream formatted output to a file.
A node representing a binary expression.
const Node * Right() const
static bool classof(const Node *node)
const Node * Left() const
BinaryOpNode(OpType op_type, Node &left, Node &right)
A node representing the canonical frame address.
static bool classof(const Node *node)
A node representing an integer literal.
static bool classof(const Node *node)
IntegerNode(int64_t value)
The base class for all nodes in the parsed postfix tree.
A node representing the value of a register with the given register number.
uint32_t GetRegNum() const
RegisterNode(uint32_t reg_num)
static bool classof(const Node *node)
A node representing a symbolic reference to a named entity.
SymbolNode(llvm::StringRef name)
llvm::StringRef GetName() const
static bool classof(const Node *node)
A node representing a unary operation.
static bool classof(const Node *node)
UnaryOpNode(OpType op_type, Node &operand)
const Node * Operand() const
A template class implementing a visitor pattern, but with a couple of twists:
virtual ResultT Visit(BinaryOpNode &binary, Node *&ref)=0
virtual ResultT Visit(RegisterNode ®, Node *&)=0
ResultT Dispatch(Node *&node)
Invoke the correct Visit function based on the dynamic type of the given node.
virtual ResultT Visit(SymbolNode &symbol, Node *&ref)=0
virtual ~Visitor()=default
virtual ResultT Visit(IntegerNode &integer, Node *&)=0
virtual ResultT Visit(InitialValueNode &val, Node *&ref)=0
virtual ResultT Visit(UnaryOpNode &unary, Node *&ref)=0
Node * ParseOneExpression(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc)
Parse the given postfix expression.
void ToDWARF(Node &node, Stream &stream)
Serialize the given expression tree as DWARF.
bool ResolveSymbols(Node *&node, llvm::function_ref< Node *(SymbolNode &symbol)> replacer)
A utility function for "resolving" SymbolNodes.
T * MakeNode(llvm::BumpPtrAllocator &alloc, Args &&... args)
std::vector< std::pair< llvm::StringRef, Node * > > ParseFPOProgram(llvm::StringRef prog, llvm::BumpPtrAllocator &alloc)
A class that represents a running process on the host machine.