Skip to content

Commit f0b351c

Browse files
eregonandrykonchin
authored andcommitted
Remove Truffle::Debug.parse_with_yarp_and_dump_truffle_ast and parseWithYARP()
* They are redundant with parse_and_dump_truffle_ast and parse().
1 parent 851ab1f commit f0b351c

File tree

4 files changed

+1
-59
lines changed

4 files changed

+1
-59
lines changed

spec/truffle/parsing/parsing_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@
8383
it "a #{subject} (#{description}) case is parsed correctly" do
8484
# p "a #{subject} (#{description.strip}) case is parsed correctly"
8585

86-
if original_parser
87-
actual_ast = Truffle::Debug.parse_and_dump_truffle_ast(source_code, focused_on_node, index, main_script).strip
88-
else
89-
actual_ast = Truffle::Debug.parse_with_yarp_and_dump_truffle_ast(source_code, focused_on_node, index, main_script).strip
90-
end
86+
actual_ast = Truffle::Debug.parse_and_dump_truffle_ast(source_code, focused_on_node, index, main_script).strip
9187

9288
if overwrite
9389
example = File.read(filename)

src/main/java/org/truffleruby/debug/TruffleDebugNodes.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,33 +1369,4 @@ private RubyRootNode parse(TStringWithEncoding sourceCode, boolean mainScript) {
13691369
}
13701370
}
13711371

1372-
@CoreMethod(names = "parse_with_yarp_and_dump_truffle_ast", onSingleton = true, required = 4, lowerFixnum = 3)
1373-
public abstract static class ParseWithYARPAndDumpTruffleASTNode extends CoreMethodArrayArgumentsNode {
1374-
1375-
@TruffleBoundary
1376-
@Specialization(guards = "strings.isRubyString(code)", limit = "1")
1377-
Object parseAndDump(Object code, Object focusedNodeClassName, int index, boolean mainScript,
1378-
@Cached RubyStringLibrary strings,
1379-
@Cached TruffleString.FromJavaStringNode fromJavaStringNode) {
1380-
String nodeClassNameString = RubyGuards.getJavaString(focusedNodeClassName);
1381-
RubyRootNode rootNode = parse(code, mainScript);
1382-
String output = TruffleASTPrinter.dump(rootNode, nodeClassNameString, index);
1383-
return createString(fromJavaStringNode, output, Encodings.UTF_8);
1384-
}
1385-
1386-
private RubyRootNode parse(Object code, boolean mainScript) {
1387-
TranslatorEnvironment.resetTemporaryVariablesIndex();
1388-
var parserContext = mainScript ? ParserContext.TOP_LEVEL_FIRST : ParserContext.TOP_LEVEL;
1389-
1390-
final RootCallTarget callTarget = getContext().getCodeLoader().parseWithYARP(
1391-
code,
1392-
parserContext,
1393-
null,
1394-
getContext().getRootLexicalScope(),
1395-
null);
1396-
1397-
return RubyRootNode.of(callTarget);
1398-
}
1399-
}
1400-
14011372
}

src/main/java/org/truffleruby/language/loader/CodeLoader.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ public RootCallTarget parse(RubySource source,
8080
return translator.parse(source, parserContext, null, parentFrame, lexicalScope, currentNode);
8181
}
8282

83-
@TruffleBoundary
84-
public RootCallTarget parseWithYARP(Object code,
85-
ParserContext parserContext,
86-
MaterializedFrame parentFrame,
87-
LexicalScope lexicalScope,
88-
Node currentNode) {
89-
RubySource rubySource = YARPTranslatorDriver.createRubySource(code);
90-
final YARPTranslatorDriver translator = new YARPTranslatorDriver(context);
91-
return translator.parse(rubySource, parserContext, null, parentFrame, lexicalScope, currentNode);
92-
}
93-
9483
@TruffleBoundary
9584
public DeferredCall prepareExecute(RootCallTarget callTarget,
9685
ParserContext parserContext,

src/main/java/org/truffleruby/parser/YARPTranslatorDriver.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@
6060
import org.truffleruby.core.kernel.KernelGetsNode;
6161
import org.truffleruby.core.kernel.KernelPrintLastLineNode;
6262
import org.truffleruby.core.string.StringOperations;
63-
import org.truffleruby.core.string.TStringWithEncoding;
6463
import org.truffleruby.language.DataNode;
6564
import org.truffleruby.language.EmitWarningsNode;
6665
import org.truffleruby.language.LexicalScope;
6766
import org.truffleruby.language.RubyEvalRootNode;
68-
import org.truffleruby.language.RubyGuards;
6967
import org.truffleruby.language.RubyNode;
7068
import org.truffleruby.language.RubyRootNode;
7169
import org.truffleruby.language.RubyTopLevelRootNode;
@@ -77,8 +75,6 @@
7775
import org.truffleruby.language.control.RaiseException;
7876
import org.truffleruby.language.control.WhileNode;
7977
import org.truffleruby.language.control.WhileNodeFactory;
80-
import org.truffleruby.language.library.RubyStringLibrary;
81-
import org.truffleruby.language.loader.ByteBasedCharSequence;
8278
import org.truffleruby.language.locals.FrameDescriptorNamesIterator;
8379
import org.truffleruby.language.locals.WriteLocalVariableNode;
8480
import org.truffleruby.language.methods.Arity;
@@ -492,16 +488,6 @@ private static String fileLineYARPSource(Nodes.Location location, RubyLanguage l
492488
return rubySource.getSourcePath(language) + ":" + yarpSource.line(location.startOffset);
493489
}
494490

495-
public static RubySource createRubySource(Object code) {
496-
var tstringWithEnc = new TStringWithEncoding(RubyGuards.asTruffleStringUncached(code),
497-
RubyStringLibrary.getUncached().getEncoding(code));
498-
var sourceTString = MagicCommentParser.createSourceTStringBasedOnMagicEncodingComment(tstringWithEnc,
499-
tstringWithEnc.encoding);
500-
var charSequence = new ByteBasedCharSequence(sourceTString);
501-
Source source = Source.newBuilder("ruby", charSequence, "<parse_ast>").build();
502-
return new RubySource(source, source.getName(), sourceTString);
503-
}
504-
505491
public static Nodes.Source createYARPSource(byte[] sourceBytes) {
506492
return new Nodes.Source(sourceBytes);
507493
}

0 commit comments

Comments
 (0)