Skip to content

Commit 0b6adfb

Browse files
committed
Remove the dependency on StaticScope in YARPTranslatorDriver
1 parent 9aed25b commit 0b6adfb

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
import org.truffleruby.language.methods.SharedMethodInfo;
8686
import org.truffleruby.parser.lexer.RubyLexer;
8787
import org.truffleruby.parser.parser.ParserConfiguration;
88-
import org.truffleruby.parser.scope.StaticScope;
8988
import org.truffleruby.shared.Metrics;
9089
import org.prism.Nodes;
9190
import org.prism.ParseResult;
@@ -126,14 +125,12 @@ public RootCallTarget parse(RubySource rubySource, ParserContext parserContext,
126125

127126
final Source source = rubySource.getSource();
128127

129-
final StaticScope staticScope = new StaticScope(StaticScope.Type.LOCAL, null);
130-
131128
// TODO: check if we still need this for YARP
132129
/* Note that jruby-parser will be mistaken about how deep the existing variables are, but that doesn't matter as
133130
* we look them up ourselves after being told they're in some parent scope. */
134131

135132
final TranslatorEnvironment parentEnvironment;
136-
final ArrayList<ArrayList<String>> localVariableNames = new ArrayList<>();
133+
final List<List<String>> localVariableNames = new ArrayList<>();
137134

138135
int blockDepth = 0;
139136
if (parentFrame != null) {
@@ -145,9 +142,7 @@ public RootCallTarget parse(RubySource rubySource, ParserContext parserContext,
145142
for (Object identifier : FrameDescriptorNamesIterator.iterate(frame.getFrameDescriptor())) {
146143
if (!BindingNodes.isHiddenVariable(identifier)) {
147144
final String name = (String) identifier;
148-
staticScope.addVariableThisScope(name.intern()); // StaticScope expects interned var names
149-
150-
names.add(name);
145+
names.add(name.intern()); // intern() for footprint
151146
}
152147
}
153148

@@ -162,9 +157,7 @@ public RootCallTarget parse(RubySource rubySource, ParserContext parserContext,
162157
}
163158

164159
if (argumentNames != null) {
165-
for (String name : argumentNames) {
166-
staticScope.addVariableThisScope(name.intern()); // StaticScope expects interned var names
167-
}
160+
// TODO: add these variables and treat it more like an eval case
168161
}
169162

170163
String sourcePath = rubySource.getSourcePath(language);
@@ -259,9 +252,7 @@ public RootCallTarget parse(RubySource rubySource, ParserContext parserContext,
259252
truffleNode = context.getMetricsProfiler().callWithMetrics(
260253
"translating",
261254
source.getName(),
262-
() -> {
263-
return node.accept(translator);
264-
});
255+
() -> node.accept(translator));
265256
} finally {
266257
printParseTranslateExecuteMetric("after-translate", context, source);
267258
}
@@ -402,16 +393,8 @@ private String getMethodName(ParserContext parserContext, MaterializedFrame pare
402393
}
403394

404395
public static org.prism.ParseResult parseToYARPAST(RubyContext context, RubyLanguage language,
405-
RubySource rubySource, StaticScope blockScope, ArrayList<ArrayList<String>> localVariableNames,
396+
RubySource rubySource, List<List<String>> localVariableNames,
406397
ParserConfiguration configuration, RubyDeferredWarnings rubyWarnings, ParseEnvironment parseEnvironment) {
407-
// LexerSource lexerSource = new LexerSource(rubySource);
408-
// We only need to pass in current scope if we are evaluating as a block (which
409-
// is only done for evals). We need to pass this in so that we can appropriately scope
410-
// down to captured scopes when we are parsing.
411-
if (blockScope != null) {
412-
configuration.parseAsBlock(blockScope);
413-
}
414-
415398
TruffleSafepoint.poll(DummyNode.INSTANCE);
416399

417400
// YARP begin

0 commit comments

Comments
 (0)