summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/object/libobject.hh
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/object/libobject.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/object/libobject.hh')
-rw-r--r--tiger-compiler/src/object/libobject.hh82
1 files changed, 82 insertions, 0 deletions
diff --git a/tiger-compiler/src/object/libobject.hh b/tiger-compiler/src/object/libobject.hh
new file mode 100644
index 0000000..d153ef4
--- /dev/null
+++ b/tiger-compiler/src/object/libobject.hh
@@ -0,0 +1,82 @@
+/**
+ ** \file object/libobject.hh
+ ** \brief Declare functions and variables exported by object module.
+ */
+
+#pragma once
+
+#include <ast/fwd.hh>
+#include <misc/error.hh>
+#include <object/fwd.hh>
+
+namespace object
+{
+ /*-------.
+ | Bind. |
+ `-------*/
+
+ // FIXME DONE: Some code was deleted here.
+ /// \brief Bind the whole ast_object in place, return the error code
+ ///
+ /// \param last the ast you want to bind
+ ///
+ /// \return a misc::error that serve to indicate possible failure
+ misc::error bind_obj(ast::ChunkList* last);
+
+ /*----------------.
+ | Compute types. |
+ `----------------*/
+
+ /** \brief Check types allowing objects.
+
+ \param tree abstract syntax tree's root.
+
+ \return success of the type-checking. */
+ misc::error types_check(ast::Ast& tree);
+
+ /*---------.
+ | Rename. |
+ `---------*/
+
+ /// Rename the variables of an AST so that they each have a unique
+ /// name, with support for objects.
+ ///
+ /// \param tree abstract syntax tree's root, whose bindings and types
+ /// have been computed.
+ /// \return a newly allocated dictionnary of class names
+ class_names_type* rename(ast::Ast& tree);
+
+ /*------------------.
+ | Desugar objects. |
+ `------------------*/
+
+ /** \brief Remove objects constructs from an AST.
+
+ \param tree abstract syntax tree's root, whose bindings
+ and types have been computed, and whose
+ identifiers are all unique.
+ \param class_names the names of the class types of the AST
+
+ \return the desugared, bound and type-checked AST. */
+ template <typename A>
+ A* desugar(const A& tree, const class_names_type& class_names);
+
+ /** \brief Remove objects constructs from an AST without recomputing
+ its bindings nor its types.
+
+ This function acts like object::object_desugar, but stops just
+ after the desugaring step (in fact, object::desugar is built
+ upon this function). It is meant to be used as a test of
+ DesugarVisitor (i.e., even if the desugared tree is badly bound
+ or typed, it can still be pretty-printed).
+
+ \param tree AST to desugar.
+ \param class_names the names of the class types of the AST
+
+ \return the desugared AST. */
+ template <typename A>
+ A* raw_desugar(const A& tree, const class_names_type& class_names);
+
+} // namespace object
+
+#include <object/libobject.hxx>