forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClassNew.h
58 lines (53 loc) · 1.05 KB
/
ClassNew.h
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
#ifndef SORBET_REWRITER_CLASS_NEW_H
#define SORBET_REWRITER_CLASS_NEW_H
#include "ast/ast.h"
namespace sorbet::rewriter {
/**
* This class actually contains three different rewriters depending on the kind of `Class.new` we ecounter:
*
* Assignments to a constant literal such as
*
* A = Class.new(Parent) do
* ...
* end
*
* Are rewritten into
*
* class A < Parent
* ...
* end
*
* Assignments to a non-constant literal such as
*
* c = Class.new(Parent) do
* ...
* end
*
* Are rewritten into
*
* c = Class.new(Parent)
* T.bind(self, T.class_of(Parent))
* ...
* end
*
* And sends such as
*
* Class.new(Parent) do
* ...
* end
*
* Are rewritten into
*
* Class.new(Parent)
* T.bind(self, T.class_of(Parent))
* ...
* end
*/
class ClassNew final {
public:
static std::vector<ast::ExpressionPtr> run(core::MutableContext ctx, ast::Assign *asgn);
static bool run(core::MutableContext ctx, ast::Send *send);
ClassNew() = delete;
};
} // namespace sorbet::rewriter
#endif