From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/ast/var-dec.hh | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tiger-compiler/src/ast/var-dec.hh (limited to 'tiger-compiler/src/ast/var-dec.hh') diff --git a/tiger-compiler/src/ast/var-dec.hh b/tiger-compiler/src/ast/var-dec.hh new file mode 100644 index 0000000..fd15b7e --- /dev/null +++ b/tiger-compiler/src/ast/var-dec.hh @@ -0,0 +1,61 @@ +/** + ** \file ast/var-dec.hh + ** \brief Declaration of ast::VarDec. + */ + +#pragma once + +#include +#include +#include +#include + +namespace ast +{ + /// VarDec. + class VarDec + : public Dec + , public Escapable + { + public: + /** \name Ctor & dtor. + ** \{ */ + /// Construct a VarDec node. + VarDec(const Location& location, + misc::symbol name, + NameTy* type_name, + Exp* init); + VarDec(const VarDec&) = delete; + VarDec& operator=(const VarDec&) = delete; + /// Destroy a VarDec node. + ~VarDec() 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 optional type of the declared variable. + const NameTy* type_name_get() const; + /// Return optional type of the declared variable. + NameTy* type_name_get(); + /// Return the initial value (expression) assigned to the variable. + const Exp* init_get() const; + /// Return the initial value (expression) assigned to the variable. + Exp* init_get(); + /** \} */ + + protected: + /// Optional type of the declared variable. + NameTy* type_name_; + /// The initial value (expression) assigned to the variable. + Exp* init_; + }; +} // namespace ast +#include -- cgit v1.2.3