Skip to content

Commit cb4c557

Browse files
committed
Replace the last usages of TranslatorDriver
1 parent 5ace708 commit cb4c557

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

src/main/java/org/truffleruby/RubyContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
import org.truffleruby.language.objects.shared.SharedObjects;
7979
import org.truffleruby.options.LanguageOptions;
8080
import org.truffleruby.options.Options;
81-
import org.truffleruby.parser.TranslatorDriver;
81+
import org.truffleruby.parser.YARPTranslatorDriver;
8282
import org.truffleruby.platform.NativeConfiguration;
8383
import org.truffleruby.platform.Signals;
8484
import org.truffleruby.platform.TruffleNFIPlatform;
@@ -335,10 +335,10 @@ protected boolean patch(Env newEnv) {
335335
.getSharedMethodInfo()
336336
.getSourceSection()
337337
.getSource();
338-
TranslatorDriver.printParseTranslateExecuteMetric("before-run-delayed-initialization", this, source);
338+
YARPTranslatorDriver.printParseTranslateExecuteMetric("before-run-delayed-initialization", this, source);
339339
ProcOperations.rootCall((RubyProc) proc, NoKeywordArgumentsDescriptor.INSTANCE,
340340
RubyBaseNode.EMPTY_ARGUMENTS);
341-
TranslatorDriver.printParseTranslateExecuteMetric("after-run-delayed-initialization", this, source);
341+
YARPTranslatorDriver.printParseTranslateExecuteMetric("after-run-delayed-initialization", this, source);
342342
}
343343
Metrics.printTime("after-run-delayed-initialization");
344344

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
import org.truffleruby.language.objects.SingletonClassNode;
6464
import org.truffleruby.parser.ParserContext;
6565
import org.truffleruby.parser.RubySource;
66-
import org.truffleruby.parser.TranslatorDriver;
66+
import org.truffleruby.parser.YARPTranslatorDriver;
6767
import org.truffleruby.platform.NativeConfiguration;
6868
import org.truffleruby.platform.NativeTypes;
6969
import org.truffleruby.shared.BuildInformationImpl;
@@ -770,9 +770,9 @@ public void loadRubyCoreLibraryAndPostBoot() {
770770
context.getCoreLibrary().mainObject,
771771
context.getRootLexicalScope());
772772

773-
TranslatorDriver.printParseTranslateExecuteMetric("before-execute", context, source);
773+
YARPTranslatorDriver.printParseTranslateExecuteMetric("before-execute", context, source);
774774
deferredCall.callWithoutCallNode();
775-
TranslatorDriver.printParseTranslateExecuteMetric("after-execute", context, source);
775+
YARPTranslatorDriver.printParseTranslateExecuteMetric("after-execute", context, source);
776776
}
777777
} catch (IOException e) {
778778
throw CompilerDirectives.shouldNotReachHere(e);

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,11 @@
107107
import com.oracle.truffle.api.nodes.NodeUtil;
108108
import com.oracle.truffle.api.object.Shape;
109109
import com.oracle.truffle.api.utilities.TriState;
110+
import org.truffleruby.parser.ParseEnvironment;
110111
import org.truffleruby.parser.ParserContext;
111-
import org.truffleruby.parser.RubyDeferredWarnings;
112112
import org.truffleruby.parser.RubySource;
113-
import org.truffleruby.parser.TranslatorDriver;
114113
import org.truffleruby.parser.TranslatorEnvironment;
115114
import org.truffleruby.parser.YARPTranslatorDriver;
116-
import org.truffleruby.parser.parser.ParserConfiguration;
117-
import org.truffleruby.parser.scope.StaticScope;
118115
import org.prism.Loader;
119116
import org.prism.Parser;
120117

@@ -343,13 +340,14 @@ Object ast(Object code,
343340
var source = Source.newBuilder("ruby", new ByteBasedCharSequence(codeString), name).build();
344341
var rubySource = new RubySource(source, name);
345342

346-
var staticScope = new StaticScope(StaticScope.Type.LOCAL, null);
347-
var parserConfiguration = new ParserConfiguration(null, false, true, false);
348-
var rubyWarnings = new RubyDeferredWarnings();
349-
var rootParseNode = TranslatorDriver
350-
.parseToJRubyAST(getContext(), rubySource, staticScope, parserConfiguration, rubyWarnings);
343+
var yarpSource = YARPTranslatorDriver.createYARPSource(rubySource.getBytes());
344+
var parseEnvironment = new ParseEnvironment(getLanguage(), rubySource, yarpSource, ParserContext.TOP_LEVEL,
345+
this);
351346

352-
return createString(fromJavaStringNode, rootParseNode.toString(), Encodings.UTF_8);
347+
var parseResult = YARPTranslatorDriver.parseToYARPAST(getLanguage(), rubySource, Collections.emptyList(),
348+
parseEnvironment);
349+
350+
return createString(fromJavaStringNode, parseResult.value.toString(), Encodings.UTF_8);
353351
}
354352
}
355353

src/main/java/org/truffleruby/language/RubyInlineParsingRequestNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.truffleruby.language.methods.SharedMethodInfo;
2020
import org.truffleruby.parser.ParserContext;
2121
import org.truffleruby.parser.RubySource;
22-
import org.truffleruby.parser.TranslatorDriver;
2322

2423
import com.oracle.truffle.api.RootCallTarget;
2524
import com.oracle.truffle.api.Truffle;
@@ -28,6 +27,7 @@
2827
import com.oracle.truffle.api.nodes.DirectCallNode;
2928
import com.oracle.truffle.api.nodes.ExecutableNode;
3029
import com.oracle.truffle.api.source.Source;
30+
import org.truffleruby.parser.YARPTranslatorDriver;
3131

3232
public final class RubyInlineParsingRequestNode extends ExecutableNode {
3333

@@ -47,7 +47,7 @@ public RubyInlineParsingRequestNode(
4747
final RubySource rubySource = new RubySource(source, language.getSourcePath(source), null, true, 0);
4848

4949
// We use the current frame as the lexical scope to parse, but then we may run with a new frame in the future
50-
final TranslatorDriver translator = new TranslatorDriver(context);
50+
final YARPTranslatorDriver translator = new YARPTranslatorDriver(context);
5151
final RootCallTarget callTarget = translator.parse(
5252
rubySource,
5353
ParserContext.INLINE,

src/main/java/org/truffleruby/language/RubyParsingRequestNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.truffleruby.language.objects.shared.SharedObjects;
2222
import org.truffleruby.parser.ParserContext;
2323
import org.truffleruby.parser.RubySource;
24-
import org.truffleruby.parser.TranslatorDriver;
24+
import org.truffleruby.parser.YARPTranslatorDriver;
2525
import org.truffleruby.shared.Metrics;
2626

2727
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
@@ -42,7 +42,7 @@ public RubyParsingRequestNode(RubyLanguage language, RubyContext context, Source
4242

4343
final RubySource rubySource = new RubySource(source, language.getSourcePath(source));
4444

45-
final TranslatorDriver translator = new TranslatorDriver(context);
45+
final YARPTranslatorDriver translator = new YARPTranslatorDriver(context);
4646
callTarget = translator.parse(
4747
rubySource,
4848
ParserContext.TOP_LEVEL,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.truffleruby.parser.ParserContext;
2727
import org.truffleruby.parser.ParsingParameters;
2828
import org.truffleruby.parser.RubySource;
29-
import org.truffleruby.parser.TranslatorDriver;
3029

3130
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
3231
import com.oracle.truffle.api.RootCallTarget;
@@ -77,7 +76,7 @@ public RootCallTarget parse(RubySource source,
7776
MaterializedFrame parentFrame,
7877
LexicalScope lexicalScope,
7978
Node currentNode) {
80-
final TranslatorDriver translator = new TranslatorDriver(context);
79+
final YARPTranslatorDriver translator = new YARPTranslatorDriver(context);
8180
return translator.parse(source, parserContext, null, parentFrame, lexicalScope, currentNode);
8281
}
8382

0 commit comments

Comments
 (0)