83
83
import org .truffleruby .language .locals .WriteLocalVariableNode ;
84
84
import org .truffleruby .language .methods .Arity ;
85
85
import org .truffleruby .language .methods .SharedMethodInfo ;
86
- import org .truffleruby .parser .parser .ParserConfiguration ;
87
86
import org .truffleruby .shared .Metrics ;
88
87
import org .prism .Nodes ;
89
88
import org .prism .ParseResult ;
@@ -159,19 +158,6 @@ public RootCallTarget parse(RubySource rubySource, ParserContext parserContext,
159
158
// TODO: add these variables and treat it more like an eval case
160
159
}
161
160
162
- String sourcePath = rubySource .getSourcePath (language );
163
- boolean isInlineSource = sourcePath .equals ("-e" );
164
- boolean isEvalParse = parserContext .isEval ();
165
- final ParserConfiguration parserConfiguration = new ParserConfiguration (
166
- context ,
167
- isInlineSource ,
168
- !isEvalParse ,
169
- false );
170
-
171
- if (language .options .FROZEN_STRING_LITERALS ) {
172
- parserConfiguration .setFrozenStringLiteral (true );
173
- }
174
-
175
161
// Parse to the YARP AST
176
162
final RubyDeferredWarnings rubyWarnings = new RubyDeferredWarnings ();
177
163
@@ -192,13 +178,10 @@ public RootCallTarget parse(RubySource rubySource, ParserContext parserContext,
192
178
printParseTranslateExecuteMetric ("after-parsing" , context , source );
193
179
}
194
180
195
- handleWarningsErrorsPrimitives (context , language , parseResult , rubySource , parserConfiguration , rubyWarnings );
181
+ handleWarningsErrorsPrimitives (context , language , parseResult , rubySource , parseEnvironment , rubyWarnings );
196
182
197
183
var node = parseResult .value ;
198
184
199
- // Needs the magic comment to be parsed
200
- parseEnvironment .allowTruffleRubyPrimitives = parserConfiguration .allowTruffleRubyPrimitives ;
201
-
202
185
final SourceSection sourceSection = source .createSection (0 , rubySource .getBytes ().length );
203
186
final SourceIndexLength sourceIndexLength = SourceIndexLength .fromSourceSection (sourceSection );
204
187
@@ -431,7 +414,7 @@ public static ParseResult parseToYARPAST(RubyLanguage language, RubySource rubyS
431
414
}
432
415
433
416
public static void handleWarningsErrorsPrimitives (RubyContext context , RubyLanguage language ,
434
- ParseResult parseResult , RubySource rubySource , ParserConfiguration configuration ,
417
+ ParseResult parseResult , RubySource rubySource , ParseEnvironment parseEnvironment ,
435
418
RubyDeferredWarnings rubyWarnings ) {
436
419
437
420
// intern() to improve footprint
@@ -473,6 +456,7 @@ public static void handleWarningsErrorsPrimitives(RubyContext context, RubyLangu
473
456
context .getCoreExceptions ().syntaxErrorAlreadyWithFileLine (message , null , section ));
474
457
}
475
458
459
+ boolean allowTruffleRubyPrimitives = false ;
476
460
for (var magicComment : parseResult .magicComments ) {
477
461
String name = rubySource .getTStringWithEncoding ()
478
462
.substring (magicComment .keyLocation .startOffset , magicComment .keyLocation .length ).toJavaString ();
@@ -483,9 +467,10 @@ public static void handleWarningsErrorsPrimitives(RubyContext context, RubyLangu
483
467
484
468
// check the `primitive` TruffleRuby specific magic comment
485
469
if (MagicCommentParser .isMagicTruffleRubyPrimitivesComment (name )) {
486
- configuration . allowTruffleRubyPrimitives = value .equalsIgnoreCase ("true" );
470
+ allowTruffleRubyPrimitives = value .equalsIgnoreCase ("true" );
487
471
}
488
472
}
473
+ parseEnvironment .allowTruffleRubyPrimitives = allowTruffleRubyPrimitives ;
489
474
}
490
475
491
476
public static void handleWarningsErrorsNoContext (RubyLanguage language , ParseResult parseResult ,
0 commit comments