47
47
import org .jcodings .specific .SJISEncoding ;
48
48
import org .jcodings .specific .USASCIIEncoding ;
49
49
import org .jcodings .specific .UTF8Encoding ;
50
- import org .truffleruby .RubyContext ;
50
+ import org .truffleruby .RubyLanguage ;
51
51
import org .truffleruby .SuppressFBWarnings ;
52
52
import org .truffleruby .core .encoding .EncodingManager ;
53
53
import org .truffleruby .core .regexp .ClassicRegexp ;
@@ -176,21 +176,15 @@ private static String prefixName(String name) {
176
176
protected ParserConfiguration configuration ;
177
177
private RubyParserResult result ;
178
178
179
- private final RubyContext context ;
180
179
private final String file ;
181
180
private final RubyDeferredWarnings warnings ;
182
181
private final ParserRopeOperations parserRopeOperations = new ParserRopeOperations ();
183
182
184
- public ParserSupport (RubyContext context , LexerSource source , RubyDeferredWarnings warnings ) {
185
- this .context = context ;
183
+ public ParserSupport (LexerSource source , RubyDeferredWarnings warnings ) {
186
184
this .file = source .getSourcePath ();
187
185
this .warnings = warnings ;
188
186
}
189
187
190
- public RubyContext getContext () {
191
- return context ;
192
- }
193
-
194
188
public void reset () {
195
189
inSingleton = 0 ;
196
190
inDefinition = false ;
@@ -408,7 +402,7 @@ public ParseNode appendToBlock(ParseNode head, ParseNode tail) {
408
402
head = new BlockParseNode (head .getPosition ()).add (head );
409
403
}
410
404
411
- if (isVerbose () && isBreakStatement (((ListParseNode ) head ).getLast ())) {
405
+ if (isBreakStatement (((ListParseNode ) head ).getLast ())) {
412
406
warnings .warning (
413
407
file ,
414
408
tail .getPosition ().toSourceSection (lexer .getSource ()).getStartLine (),
@@ -420,14 +414,6 @@ public ParseNode appendToBlock(ParseNode head, ParseNode tail) {
420
414
return head ;
421
415
}
422
416
423
- private boolean isVerbose () {
424
- return context != null && context .getCoreLibrary ().isVerbose ();
425
- }
426
-
427
- private boolean warningsEnabled () {
428
- return context .getCoreLibrary ().warningsEnabled ();
429
- }
430
-
431
417
// We know it has to be tLABEL or tIDENTIFIER so none of the other assignable logic is needed
432
418
public AssignableParseNode assignableInCurr (Rope name , ParseNode value ) {
433
419
String nameString = name .getString ().intern ();
@@ -640,7 +626,7 @@ public boolean checkExpression(ParseNode node) {
640
626
}
641
627
642
628
private void handleUselessWarn (ParseNode node , String useless ) {
643
- warnings .warn (
629
+ warnings .warning (
644
630
file ,
645
631
node .getPosition ().toSourceSection (lexer .getSource ()).getStartLine (),
646
632
"Useless use of " + useless + " in void context." );
@@ -650,7 +636,7 @@ private void handleUselessWarn(ParseNode node, String useless) {
650
636
*
651
637
* @param node to be checked. */
652
638
public void checkUselessStatement (ParseNode node ) {
653
- if (!isVerbose () || (! configuration .isInlineSource () && configuration .isEvalParse () )) {
639
+ if (!configuration .isInlineSource () && configuration .isEvalParse ()) {
654
640
return ;
655
641
}
656
642
@@ -736,15 +722,13 @@ public void checkUselessStatement(ParseNode node) {
736
722
*
737
723
* @param blockNode to be checked. */
738
724
public void checkUselessStatements (BlockParseNode blockNode ) {
739
- if (isVerbose ()) {
740
- ParseNode lastNode = blockNode .getLast ();
725
+ ParseNode lastNode = blockNode .getLast ();
741
726
742
- for (int i = 0 ; i < blockNode .size (); i ++) {
743
- ParseNode currentNode = blockNode .get (i );
727
+ for (int i = 0 ; i < blockNode .size (); i ++) {
728
+ ParseNode currentNode = blockNode .get (i );
744
729
745
- if (lastNode != currentNode ) {
746
- checkUselessStatement (currentNode );
747
- }
730
+ if (lastNode != currentNode ) {
731
+ checkUselessStatement (currentNode );
748
732
}
749
733
}
750
734
}
@@ -1271,7 +1255,7 @@ public ParseNode asSymbol(SourceIndexLength position, ParseNode value) {
1271
1255
private void checkSymbolCodeRange (SymbolParseNode symbolParseNode ) {
1272
1256
if (symbolParseNode .getRope ().getCodeRange () == CR_BROKEN ) {
1273
1257
throw new RaiseException (
1274
- getContext (),
1258
+ RubyLanguage . getCurrentContext (),
1275
1259
getConfiguration ().getContext ().getCoreExceptions ().encodingError ("invalid encoding symbol" , null ));
1276
1260
}
1277
1261
}
@@ -1703,7 +1687,7 @@ private void allocateNamedLocals(RegexpParseNode regexpNode) {
1703
1687
int slot = scope .isDefined (names [i ]);
1704
1688
if (slot >= 0 ) {
1705
1689
// If verbose and the variable is not just another named capture, warn
1706
- if (isVerbose () && !scope .isNamedCapture (slot )) {
1690
+ if (!scope .isNamedCapture (slot )) {
1707
1691
warn (getPosition (regexpNode ), "named capture conflicts a local variable - " + names [i ]);
1708
1692
}
1709
1693
} else {
@@ -1746,7 +1730,7 @@ public RuntimeException compile_error(String message) { // mri: rb_compile_error
1746
1730
}
1747
1731
1748
1732
throw new RaiseException (
1749
- getContext (),
1733
+ RubyLanguage . getCurrentContext (),
1750
1734
getConfiguration ().getContext ().getCoreExceptions ().syntaxError (
1751
1735
errorMessage + message ,
1752
1736
null ,
0 commit comments