Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
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>
26using boost::units::detail::demangle;
27#else
28using boost::core::demangle;
29#endif
30
31namespace Pyston {
32
41template <typename To, typename From>
42class Cast : public Node<To> {
43public:
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
74private:
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