Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions instructionAPI/statefull_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "InstructionDecoder.h"
#include "Operand.h"
#include "Register.h"
#include "MultiRegister.h"
#include "Visitor.h"

#include <array>
Expand All @@ -22,6 +23,7 @@ namespace di = Dyninst::InstructionAPI;

struct stateful_visitor : di::Visitor {
bool foundReg{};
bool foundMultiReg{};
bool foundImm{};
bool foundBin{};
bool foundDer{};
Expand All @@ -32,12 +34,15 @@ struct stateful_visitor : di::Visitor {

void visit(di::RegisterAST*) override { foundReg = true; }

void visit(di::MultiRegisterAST*) override { foundMultiReg = true; }

void visit(di::Dereference*) override { foundDer = true; }

// clang-format off
friend std::ostream& operator<<(std::ostream &os, stateful_visitor const& v) {
std::cout << std::boolalpha
<< " foundReg: " << v.foundReg << '\n'
<< " foundMultiReg: " << v.foundMultiReg << '\n'
<< " foundImm: " << v.foundImm << '\n'
<< " foundBin: " << v.foundBin << '\n'
<< " foundDer: " << v.foundDer << '\n';
Expand Down
6 changes: 6 additions & 0 deletions instructionAPI/stateless_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "InstructionDecoder.h"
#include "Operand.h"
#include "Register.h"
#include "MultiRegister.h"
#include "Visitor.h"

#include <array>
Expand Down Expand Up @@ -38,6 +39,11 @@ class printer : public di::Visitor {
void visit(di::RegisterAST* r) override {
std::cout << " Register '" << r->format(di::defaultStyle) << "'\n";
}

void visit(di::MultiRegisterAST* r) override {
std::cout << " MultiRegister '" << r->format(di::defaultStyle) << "'\n";
}

};

void print(di::Instruction const& insn) {
Expand Down
Loading