Skip to content

Commit 592a249

Browse files
committed
Make DATA be a File
1 parent 1f7e2db commit 592a249

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/org/jruby/prism/parser/ParserPrismBase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.jruby.ParseResult;
66
import org.jruby.Ruby;
77
import org.jruby.RubyArray;
8+
import org.jruby.RubyFile;
89
import org.jruby.RubyIO;
910
import org.jruby.RubyInstanceConfig;
1011
import org.jruby.RubySymbol;
@@ -20,6 +21,7 @@
2021
import org.jruby.util.ByteList;
2122
import org.jruby.util.CommonByteLists;
2223
import org.jruby.util.io.ChannelHelper;
24+
import org.jruby.util.io.SeekableByteChannelImpl;
2325
import org.ruby_lang.prism.Nodes.ArgumentsNode;
2426
import org.ruby_lang.prism.Nodes.CallNode;
2527
import org.ruby_lang.prism.Nodes.CallNodeFlags;
@@ -35,6 +37,7 @@
3537
import java.io.DataInputStream;
3638
import java.io.IOException;
3739
import java.io.InputStream;
40+
import java.nio.channels.SeekableByteChannel;
3841
import java.util.ArrayList;
3942
import java.util.Arrays;
4043
import java.util.EnumSet;
@@ -95,11 +98,9 @@ private ParseResult parseInternal(String fileName, DynamicScope blockScope, byte
9598
}
9699

97100
if (type == MAIN && res.dataLocation != null) {
98-
// FIXME: Intentionally leaving as original source for offset. This can just be an IO where pos is set to right value.
99-
// FIXME: Somehow spec will say this should File and not IO but I cannot figure out why legacy parser isn't IO also.
100101
ByteArrayInputStream bais = new ByteArrayInputStream(source, 0, source.length);
101102
bais.skip(res.dataLocation.startOffset + 8); // FIXME: 8 is for including __END__\n
102-
runtime.defineDATA(RubyIO.newIO(runtime, ChannelHelper.readableChannel(bais)));
103+
runtime.defineDATA(RubyFile.DATAFile(runtime, fileName, new SeekableByteChannelImpl(bais)));
103104
}
104105

105106
int lineCount = res.source.getLineCount();

0 commit comments

Comments
 (0)