blob: 6c62a86521c6f73882bf39427eea965e7b335ae7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/**
** \file object/renamer.hh
** \brief Implementation of object::Renamer.
*/
#pragma once
#include <map>
#include <bind/renamer.hh>
#include <object/fwd.hh>
namespace object
{
/// \brief Perform identifier renaming within an AST (in place),
/// with support for objects.
class Renamer : public bind::Renamer
{
public:
using super_type = ::bind::Renamer;
// Import overloaded virtual functions.
using super_type::operator();
/// Build a Renamer.
Renamer();
// Visit methods.
/// \name Visiting definition sites.
/// \{
/// This method is like bind::Binder's, but prevent the renaming
/// of attributes.
void operator()(ast::VarDec& e) override;
/// Rename methods.
void operator()(ast::MethodChunk& e) override;
/// Rename a method.
void operator()(ast::MethodDec& e) override;
/// In addition to performing the renaming, collect the name of
/// the classes.
void operator()(ast::TypeDec& e) override;
/// \}
/// \name Visiting usage sites.
/// \{
void operator()(ast::MethodCallExp& e) override;
/// \}
/// \name Visiting other object-related nodes.
///
/// These methods should be part of an ObjectDefaultVisitor, but
/// our current design makes the implementation (and the use) of
/// such a visitor difficult.
/// \{
void operator()(ast::ClassTy& e) override;
void operator()(ast::ObjectExp& e) override;
/// \}
/// \name Visiting LetExp.
///
/// In order to handle variable declarations that might be
/// situated in a ClassTy and yet do not qualify as attributes.
/// \{
void operator()(ast::LetExp& e) override;
/// \}
/// Class names.
/// \{
/// Get the class names.
class_names_type* class_names_get() const;
private:
/// Dictionnary mapping class types to their names.
class_names_type* class_names_;
/// Are we in a class definition?
bool within_class_ty_;
/// \}
};
} // namespace object
|