diff options
Diffstat (limited to 'tiger-compiler/src/ast/cast-exp.hh')
| -rw-r--r-- | tiger-compiler/src/ast/cast-exp.hh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/cast-exp.hh b/tiger-compiler/src/ast/cast-exp.hh new file mode 100644 index 0000000..a73e7bb --- /dev/null +++ b/tiger-compiler/src/ast/cast-exp.hh @@ -0,0 +1,62 @@ +/** + ** \file ast/cast-exp.hh + ** \brief Declaration of ast::CastExp. + */ + +#pragma once + +#include <ast/exp.hh> +#include <ast/ty.hh> + +namespace ast +{ + /** \class ast::CastExp + ** \brief Cast the type of an expression to a given type. + ** + ** This node is only used in the bounds checking transformation + ** (see desugar::bounds_checks_add). You don't need to worry + ** about it (nor about the `cast' keyword) if you don't implement + ** this option. + */ + + class CastExp : public Exp + { + public: + /** \name Ctor & dtor. + ** \{ */ + /// Construct a CastExp node. + CastExp(const Location& location, Exp* exp, Ty* ty); + CastExp(const CastExp&) = delete; + CastExp& operator=(const CastExp&) = delete; + /// Destroy a CastExp node. + ~CastExp() override; + /** \} */ + + /// \name Visitors entry point. + /// \{ */ + /// Accept a const visitor \a v. + void accept(ConstVisitor& v) const override; + /// Accept a non-const visitor \a v. + void accept(Visitor& v) override; + /// \} + + /** \name Accessors. + ** \{ */ + /// Return the cast expression. + const Exp& exp_get() const; + /// Return the cast expression. + Exp& exp_get(); + /// Return the target type. + const Ty& ty_get() const; + /// Return the target type. + Ty& ty_get(); + /** \} */ + + protected: + /// The cast expression. + Exp* exp_; + /// The target type. + Ty* ty_; + }; +} // namespace ast +#include <ast/cast-exp.hxx> |
