Alexandria  2.22.0
Please provide a description of the project.
Cast.h
Go to the documentation of this file.
1 
19 #ifndef PYSTON_CAST_H
20 #define PYSTON_CAST_H
21 
22 #include "Node.h"
23 
24 #if BOOST_VERSION < 105600
25 #include <boost/units/detail/utility.hpp>
26 using boost::units::detail::demangle;
27 #else
28 using boost::core::demangle;
29 #endif
30 
31 namespace Pyston {
32 
41 template <typename To, typename From>
42 class Cast : public Node<To> {
43 public:
49  explicit Cast(const std::shared_ptr<Node<From>>& node) : m_node{node} {}
50 
54  std::string repr() const final {
55  return demangle(typeid(To).name());
56  }
57 
61  To eval(const Context& context, const Arguments& args) const final {
62  return static_cast<To>(m_node->eval(context, args));
63  }
64 
68  void visit(Visitor& visitor) const final {
69  visitor.enter(this);
70  m_node->visit(visitor);
71  visitor.exit(this);
72  }
73 
74 private:
76 };
77 
78 } // end of namespace Pyston
79 
80 #endif // PYSTON_CAST_H
void visit(Visitor &visitor) const final
Definition: Cast.h:68
std::shared_ptr< Node< From > > m_node
Definition: Cast.h:75
To eval(const Context &context, const Arguments &args) const final
Definition: Cast.h:61
std::string repr() const final
Definition: Cast.h:54
Cast(const std::shared_ptr< Node< From >> &node)
Definition: Cast.h:49