-
-
Notifications
You must be signed in to change notification settings - Fork 941
Expand file tree
/
Copy pathIRScopeType.java
More file actions
48 lines (38 loc) · 1.24 KB
/
IRScopeType.java
File metadata and controls
48 lines (38 loc) · 1.24 KB
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
package org.jruby.ir;
public enum IRScopeType {
CLOSURE, EVAL_SCRIPT, INSTANCE_METHOD, CLASS_METHOD, MODULE_BODY, CLASS_BODY, METACLASS_BODY, SCRIPT_BODY, FOR;
private static final IRScopeType[] VALUES = values();
public static IRScopeType fromOrdinal(int ordinal) {
if (ordinal < 0 || ordinal >= VALUES.length) {
return null;
}
return VALUES[ordinal];
}
// Is this a block type of closure vs an instance of IRClosure (which is also a for/eval internally)?
public boolean isBlock() {
return this == CLOSURE;
}
public boolean isEval() {
return this == EVAL_SCRIPT;
}
public boolean isMethodType() {
return this == INSTANCE_METHOD || this == CLASS_METHOD;
}
public boolean isClosureType() {
return this == CLOSURE || this == FOR || this == EVAL_SCRIPT;
}
public boolean isMethod() {
return this == INSTANCE_METHOD || this == CLASS_METHOD;
}
public boolean isMethodContainer() {
switch (this) {
case MODULE_BODY:
case CLASS_BODY:
case METACLASS_BODY:
case SCRIPT_BODY:
return true;
default:
return false;
}
}
}