forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRScriptBody.java
More file actions
72 lines (58 loc) · 2.08 KB
/
Copy pathIRScriptBody.java
File metadata and controls
72 lines (58 loc) · 2.08 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
71
72
package org.jruby.ir;
import java.util.ArrayList;
import java.util.List;
import org.jruby.ir.operands.LocalVariable;
import org.jruby.parser.IRStaticScope;
import org.jruby.parser.StaticScope;
// FIXME: I made this IRModule because any methods placed in top-level script goes
// into something which an IRScript is basically a module that is special in that
// it represents a lexical unit. Fix what now?
public class IRScriptBody extends IRScope {
private List<IRClosure> beginBlocks;
private List<IRClosure> endBlocks;
public IRScriptBody(IRManager manager, String className, String sourceName,
StaticScope staticScope) {
super(manager, null, sourceName, sourceName, 0, staticScope);
if (!getManager().isDryRun()) {
if (staticScope != null) ((IRStaticScope)staticScope).setIRScope(this);
}
}
@Override
public IRScope getNearestModuleReferencingScope() {
return this;
}
@Override
public LocalVariable getImplicitBlockArg() {
assert false: "A Script body never accepts block args";
return null;
}
public String getScopeName() {
return "ScriptBody";
}
@Override
public String toString() {
return "Script: file: " + getFileName() + super.toString();
}
/* Record a begin block -- not all scope implementations can handle them */
@Override
public void recordBeginBlock(IRClosure beginBlockClosure) {
if (beginBlocks == null) beginBlocks = new ArrayList<IRClosure>();
beginBlocks.add(beginBlockClosure);
}
/* Record an end block -- not all scope implementations can handle them */
@Override
public void recordEndBlock(IRClosure endBlockClosure) {
if (endBlocks == null) endBlocks = new ArrayList<IRClosure>();
endBlocks.add(endBlockClosure);
}
public List<IRClosure> getBeginBlocks() {
return beginBlocks;
}
public List<IRClosure> getEndBlocks() {
return endBlocks;
}
@Override
public boolean isScriptScope() {
return true;
}
}