forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtil.h
38 lines (28 loc) · 1.64 KB
/
Util.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
#ifndef SORBET_REWRITER_UTIL_H
#define SORBET_REWRITER_UTIL_H
#include "ast/ast.h"
#include "core/Names.h"
#include <memory>
namespace sorbet::rewriter {
class ASTUtil {
public:
static ast::ExpressionPtr dupType(const ast::ExpressionPtr &orig);
static bool hasHashValue(core::MutableContext ctx, const ast::Hash &hash, core::NameRef name);
static bool hasTruthyHashValue(core::MutableContext ctx, const ast::Hash &hash, core::NameRef name);
/** Removes the key, value matching key with symbol `name` from hash and returns it */
static std::pair<ast::ExpressionPtr, ast::ExpressionPtr> extractHashValue(core::MutableContext ctx, ast::Hash &hash,
core::NameRef name);
static ast::Send *castSig(ast::ExpressionPtr &expr);
static ast::Send *castSig(ast::Send *expr);
static ast::ExpressionPtr mkKwArgsHash(const ast::Send *send);
static ast::ExpressionPtr mkGet(core::Context ctx, core::LocOffsets loc, core::NameRef name, ast::ExpressionPtr rhs,
ast::MethodDef::Flags flags = ast::MethodDef::Flags());
static ast::ExpressionPtr mkSet(core::Context ctx, core::LocOffsets loc, core::NameRef name,
core::LocOffsets argLoc, ast::ExpressionPtr rhs,
ast::MethodDef::Flags flags = ast::MethodDef::Flags());
static ast::ExpressionPtr mkNilable(core::LocOffsets loc, ast::ExpressionPtr type);
static ast::ExpressionPtr thunkBody(core::MutableContext ctx, ast::ExpressionPtr &node);
ASTUtil() = delete;
};
} // namespace sorbet::rewriter
#endif