ICG 2
Electric Boogaloo
FindLeaves.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include "Value/Value.hpp"
6 
7 #include <vector>
8 #include <stack>
9 
10 
11 namespace FindLeaves {
12 
13  // Struct for returning results
14  struct Leaf {
15  Leaf(MutableVariableName n, Value * v) : Leaf(n, v, false, NULL) {}
16  Leaf(MutableVariableName n, Value * v, bool is_ptr, std::shared_ptr<const DataType> ptr_sub) :
17  name_stack(n), value(v), is_pointer(is_ptr), pointer_subtype(ptr_sub), is_stl(false), stl_size(0) {}
18 
21  bool is_pointer;
22  std::shared_ptr<const DataType> pointer_subtype;
23  bool is_stl;
24  int stl_size;
25  };
26 
27  typedef std::vector<Leaf> Result;
28 
30 
31  public:
33  FindLeavesVisitor(std::string starting_name, void * starting_address);
34 
35  // Visitor Interface
36 
37  virtual bool visitPrimitiveDataType(std::shared_ptr<const PrimitiveDataType> node) override;
38  virtual bool visitCompositeType(std::shared_ptr<const CompositeDataType> node) override;
39  virtual bool visitArrayType(std::shared_ptr<const ArrayDataType> node) override;
40  virtual bool visitPointerType(std::shared_ptr<const PointerDataType> node) override;
41  virtual bool visitEnumeratedType(std::shared_ptr<const EnumDataType> node) override;
42  virtual bool visitStringType (std::shared_ptr<const StringDataType> node) override;
43  virtual bool visitSequenceType (std::shared_ptr<const SequenceDataType> node) override;
44 
45  // FindLeavesVisitor Specific Interface
46  Result getResult();
47 
48  private:
49  // Visitor State
50  MutableVariableName current_name_stack;
51  std::stack<void *> address_stack;
52 
53  // Result
54  std::vector<Leaf> leaves;
55  };
56 
57 }
Abstract base class for a DataTypeVisitor.
Definition: DataTypeVisitor.hpp:20
Definition: FindLeaves.hpp:29
FindLeavesVisitor()
Definition: FindLeaves.cpp:9
Result getResult()
Definition: FindLeaves.cpp:118
virtual bool visitCompositeType(std::shared_ptr< const CompositeDataType > node) override
Definition: FindLeaves.cpp:31
virtual bool visitStringType(std::shared_ptr< const StringDataType > node) override
Definition: FindLeaves.cpp:24
virtual bool visitEnumeratedType(std::shared_ptr< const EnumDataType > node) override
Definition: FindLeaves.cpp:82
virtual bool visitPointerType(std::shared_ptr< const PointerDataType > node) override
Definition: FindLeaves.cpp:72
virtual bool visitArrayType(std::shared_ptr< const ArrayDataType > node) override
Definition: FindLeaves.cpp:53
virtual bool visitSequenceType(std::shared_ptr< const SequenceDataType > node) override
Definition: FindLeaves.cpp:91
virtual bool visitPrimitiveDataType(std::shared_ptr< const PrimitiveDataType > node) override
Definition: FindLeaves.cpp:18
Definition: MutableVariableName.hpp:9
Value is an abstract base-class that represents a value on the right-hand-side of an assignment.
Definition: Value.hpp:9
Definition: FindLeaves.hpp:11
std::vector< Leaf > Result
Definition: FindLeaves.hpp:27
Definition: FindLeaves.hpp:14
MutableVariableName name_stack
Definition: FindLeaves.hpp:19
bool is_pointer
Definition: FindLeaves.hpp:21
bool is_stl
Definition: FindLeaves.hpp:23
Leaf(MutableVariableName n, Value *v, bool is_ptr, std::shared_ptr< const DataType > ptr_sub)
Definition: FindLeaves.hpp:16
Value * value
Definition: FindLeaves.hpp:20
int stl_size
Definition: FindLeaves.hpp:24
std::shared_ptr< const DataType > pointer_subtype
Definition: FindLeaves.hpp:22
Leaf(MutableVariableName n, Value *v)
Definition: FindLeaves.hpp:15