forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProp.h
35 lines (30 loc) · 900 Bytes
/
Prop.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
#ifndef SORBET_REWRITER_CHALK_ODM_PROP_H
#define SORBET_REWRITER_CHALK_ODM_PROP_H
#include "ast/ast.h"
namespace sorbet::rewriter {
/**
* This class desugars things of the form
*
* prop :foo, Type
*
* into
*
* sig {returns(Type)}
* def foo; ...; end
* sig {params(arg0: Type).returns(Type)}
* def foo=(arg0); ...; end
*
* We try to implement a simple approximation of the functionality that Chalk::ODM::Document.prop has. Any deviation
* from the expected shape stops the desugaring.
*
* Most other `run`s return just nodes, but we also want to keep track of the prop information so that at the end
* of the Rewriter pass on the classDef, we can construct an `initialize` method with good static types.
*
*/
class Prop final {
public:
static void run(core::MutableContext ctx, ast::ClassDef *klass);
Prop() = delete;
};
} // namespace sorbet::rewriter
#endif