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/field-var.hh | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tiger-compiler/src/ast/field-var.hh (limited to 'tiger-compiler/src/ast/field-var.hh') diff --git a/tiger-compiler/src/ast/field-var.hh b/tiger-compiler/src/ast/field-var.hh new file mode 100644 index 0000000..06c0b9a --- /dev/null +++ b/tiger-compiler/src/ast/field-var.hh @@ -0,0 +1,60 @@ +/** + ** \file ast/field-var.hh + ** \brief Declaration of ast::FieldVar. + */ + +#pragma once + +#include +#include + +namespace ast +{ + /// FieldVar. + class FieldVar : public Var + { + public: + /** \name Ctor & dtor. + ** \{ */ + /// Construct a FieldVar node. + FieldVar(const Location& location, Var* var, misc::symbol name); + FieldVar(const FieldVar&) = delete; + FieldVar& operator=(const FieldVar&) = delete; + /// Destroy a FieldVar node. + ~FieldVar() 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 record that holds the field. + const Var& var_get() const; + /// Return the record that holds the field. + Var& var_get(); + /// Return the field's name. + misc::symbol name_get() const; + /// Set the field's name. + void name_set(misc::symbol); + /// Return handle the number of the field in the record that holds it. + int index_get() const; + /// Set handle the number of the field in the record that holds it. + void index_set(int); + /** \} */ + + protected: + /// The record that holds the field. + Var* var_; + /// The field's name. + misc::symbol name_; + /// Handle the number of the field in the record that holds it. + int index_ = -1; + }; +} // namespace ast +#include -- cgit v1.2.3