diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/desugar/bounds-checking-visitor.hh | |
Diffstat (limited to 'tiger-compiler/src/desugar/bounds-checking-visitor.hh')
| -rw-r--r-- | tiger-compiler/src/desugar/bounds-checking-visitor.hh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tiger-compiler/src/desugar/bounds-checking-visitor.hh b/tiger-compiler/src/desugar/bounds-checking-visitor.hh new file mode 100644 index 0000000..65e955d --- /dev/null +++ b/tiger-compiler/src/desugar/bounds-checking-visitor.hh @@ -0,0 +1,46 @@ +/** + ** \file desugar/bounds-checking-visitor.hh + ** \brief Declaration of desugar::BoundsCheckingVisitor. + */ + +#pragma once + +#include <map> + +#include <astclone/cloner.hh> +#include <parse/tweast.hh> + +namespace desugar +{ + /// \brief Add dynamic array bounds checks while duplicating an AST. + class BoundsCheckingVisitor : public astclone::Cloner + { + public: + /// Parent type. + using super_type = astclone::Cloner; + + // Import overloaded virtual functions. + using super_type::operator(); + + /// Build a BoundsCheckingVisitor. + BoundsCheckingVisitor(); + + /// \name Visit methods. + /// \{ + // FIXME: Some code was deleted here. + /// \} + + private: + /// The bounds checking runtime. + /// + /// Additional definitions to insert in the prelude. + static const std::string prelude; + + // Symbols would be nicer, but maps of symbols are + // inconvenient since there is no default ctor. + using boxes_type = std::map<const type::Array*, std::string>; + /// Map from an array type to the corresponding `box' type name. + boxes_type boxes_; + }; + +} // namespace desugar |
