-
-
Notifications
You must be signed in to change notification settings - Fork 938
Expand file tree
/
Copy pathIREvalScript.java
More file actions
70 lines (56 loc) · 1.83 KB
/
IREvalScript.java
File metadata and controls
70 lines (56 loc) · 1.83 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package org.jruby.ir;
import org.jruby.EvalType;
import org.jruby.ir.operands.Label;
import org.jruby.parser.StaticScope;
import org.jruby.util.ByteList;
public class IREvalScript extends IRClosure {
private String fileName;
private static final ByteList EVAL = new ByteList(new byte[] {'E', 'V', 'A', 'L'});
public IREvalScript(IRManager manager, IRScope lexicalParent, String fileName,
int lineNumber, StaticScope staticScope, EvalType evalType) {
// ALL eval scopes are not really closures and are always new scopes. We should not reference an eval
// by a TemporaryClosureVariable ever.
super(manager, lexicalParent, lineNumber, staticScope, 0, EVAL);
this.fileName = fileName;
if (staticScope != null) {
// SSS FIXME: This is awkward!
if (evalType == EvalType.MODULE_EVAL) {
staticScope.setScopeType(getScopeType());
} else {
IRScope s = lexicalParent;
while (s instanceof IREvalScript) {
s = s.getLexicalParent();
}
staticScope.setScopeType(s.getScopeType());
}
}
}
@Override
public int getNextClosureId() {
nextClosureIndex++;
return nextClosureIndex;
}
@Override
public Label getNewLabel() {
return getNewLabel("EV" + closureId + "_LBL");
}
@Override
public IRScopeType getScopeType() {
return IRScopeType.EVAL_SCRIPT;
}
public boolean isWhereFlipFlopStateVariableIs() {
return true;
}
@Override
public boolean isScriptScope() {
return true;
}
@Override
public void setFileName(String fileName) {
this.fileName = fileName;
}
@Override
public String getFile() {
return fileName;
}
}