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/overload/binder.hh | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tiger-compiler/src/overload/binder.hh (limited to 'tiger-compiler/src/overload/binder.hh') diff --git a/tiger-compiler/src/overload/binder.hh b/tiger-compiler/src/overload/binder.hh new file mode 100644 index 0000000..607debb --- /dev/null +++ b/tiger-compiler/src/overload/binder.hh @@ -0,0 +1,65 @@ +/** + ** \file overload/binder.hh + ** \brief Declaration of overload::Binder. + **/ + +#pragma once + +#include + +#include +#include + +namespace overload +{ + /// Type of the dictionary of potential function bindings. + using overfun_bindings_type = std::multimap; + + /** \brief Computing bindings with support for overloaded functions. + ** + ** This visitor inherits from Binder, but redefines methods + ** dealing with function declarations and uses, to allow + ** overloading. + ** + ** As overloading requires some knowledge of the type of the + ** arguments of a function, no real function binding is done here. + ** We store all potential function declarations (``homonyms'') for + ** each function call, and we'll let the overload::TypeChecker + ** decide later. + ** + ** Inheritance is declared virtual to enable diamond inheritance with + ** the combine::Binder (src/combine/binder.hh), inheriting from + ** overload::Binder and object::Binder, both inheriting from bind::Binder. + **/ + class Binder : virtual public bind::Binder + { + public: + /// Super class type. + using super_type = bind::Binder; + /// Import all the overloaded operator() methods. + using super_type::operator(); + + /* The visiting methods. */ + /// Visit a function call. + void operator()(ast::CallExp& e) override; + + /// Check a function declaration header. + void visit_dec_header(ast::FunctionDec& e); + /// Visit a chunk of function declarations. + void operator()(ast::FunctionChunk& e) override; + + /// Return the function bindings. + overfun_bindings_type& overfun_bindings_get(); + + // FIXME: Some code was deleted here (Overload scope handling). + /** \} */ + + private: + using overtable_type = OverTable; + /// The environment of (overloaded) functions. + overtable_type overfuns_; + /// The potential function bindings. + overfun_bindings_type overfun_bindings_; + }; + +} // namespace overload -- cgit v1.2.3