1 | function AstNodeTypes() {
|
2 |
|
3 | }
|
4 |
|
5 | AstNodeTypes.LogicalExpression = "LogicalExpression";
|
6 | AstNodeTypes.BlockStatement = "BlockStatement";
|
7 | AstNodeTypes.SwitchStatement = "SwitchStatement";
|
8 | AstNodeTypes.IfStatement = "IfStatement";
|
9 | AstNodeTypes.ConditionalExpression = "ConditionalExpression";
|
10 | AstNodeTypes.StringLiteral = "StringLiteral";
|
11 | AstNodeTypes.Identifier = "Identifier";
|
12 |
|
13 | AstNodeTypes.isMethodNode = function (node) {
|
14 | if (!node && !node.type)
|
15 | return false;
|
16 |
|
17 | return methodNodeTypes[node.type];
|
18 | }
|
19 |
|
20 | AstNodeTypes.isBranchNode = function (node) {
|
21 | if (!node && !node.type)
|
22 | return false;
|
23 |
|
24 | return branchNodeTypes[node.type];
|
25 | }
|
26 |
|
27 | var branchNodeTypes = {
|
28 | "IfStatement": true,
|
29 | "SwitchStatement": true,
|
30 | "ConditionalExpression": true,
|
31 | "LogicalExpression": true
|
32 | };
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | var methodNodeTypes = {
|
43 | "FunctionDeclaration": true,
|
44 | "FunctionExpression": true,
|
45 | "ArrowFunctionExpression": true,
|
46 | "ObjectMethod": true,
|
47 | "ClassMethod": true
|
48 | }
|
49 |
|
50 | module.exports = AstNodeTypes; |
\ | No newline at end of file |