Skip to content

Commit

Permalink
[Truffle] Hide ignored flags warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Jan 30, 2015
1 parent 7156dac commit 0a6a2b9
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 6 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/RubyRegexp.java
Expand Up @@ -71,6 +71,7 @@
import org.jruby.util.Sprintf;
import org.jruby.util.StringSupport;
import org.jruby.util.TypeConverter;
import org.jruby.util.cli.Options;
import org.jruby.util.io.EncodingUtils;
import org.jruby.util.collections.WeakValuedMap;

Expand Down Expand Up @@ -1248,7 +1249,7 @@ public IRubyObject initialize_m19(IRubyObject arg) {

@JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE)
public IRubyObject initialize_m19(IRubyObject arg0, IRubyObject arg1) {
if (arg0 instanceof RubyRegexp) {
if (arg0 instanceof RubyRegexp && Options.PARSER_WARN_FLAGS_IGNORED.load()) {
getRuntime().getWarnings().warn(ID.REGEXP_IGNORED_FLAGS, "flags ignored");
return initializeByRegexp19((RubyRegexp)arg0);
}
Expand All @@ -1259,8 +1260,8 @@ public IRubyObject initialize_m19(IRubyObject arg0, IRubyObject arg1) {

@JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE)
public IRubyObject initialize_m19(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
if (arg0 instanceof RubyRegexp) {
getRuntime().getWarnings().warn(ID.REGEXP_IGNORED_FLAGS, "flags ignored");
if (arg0 instanceof RubyRegexp && Options.PARSER_WARN_FLAGS_IGNORED.load()) {
getRuntime().getWarnings().warn(ID.REGEXP_IGNORED_FLAGS, "flags ignored");
return initializeByRegexp19((RubyRegexp)arg0);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Expand Up @@ -819,7 +819,7 @@ private int hereDocumentIdentifier() throws IOException {
}

private void arg_ambiguous() {
if (warnings.isVerbose() && Options.PARSER_AMBIGUOUS_ARGUMENTS.load()) {
if (warnings.isVerbose() && Options.PARSER_WARN_AMBIGUOUS_ARGUMENTS.load()) {
warnings.warning(ID.AMBIGUOUS_ARGUMENT, getPosition(), "Ambiguous first argument; make sure.");
}
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Expand Up @@ -65,7 +65,8 @@ public class Options {
public static final Option<Boolean> PARSER_WARN_LOCAL_SHADOWING = bool(PARSER, "parser.warn.shadowing_local", true, "Warn about shadowing local variables.");
public static final Option<Boolean> PARSER_WARN_REGEX_CONDITION = bool(PARSER, "parser.warn.regex_condition", true, "Warn about regex literals in conditions.");
public static final Option<Boolean> PARSER_WARN_ARGUMENT_PREFIX = bool(PARSER, "parser.warn.argument_prefix", true, "Warn about splat operators being interpreted as argument prefixes.");
public static final Option<Boolean> PARSER_AMBIGUOUS_ARGUMENTS = bool(PARSER, "parser.warn.ambiguous_argument", true, "Warn about ambiguous arguments.");
public static final Option<Boolean> PARSER_WARN_AMBIGUOUS_ARGUMENTS = bool(PARSER, "parser.warn.ambiguous_argument", true, "Warn about ambiguous arguments.");
public static final Option<Boolean> PARSER_WARN_FLAGS_IGNORED = bool(PARSER, "parser.warn.flags_ignored", true, "Warn about ignored regex flags being ignored.");

public static final Option<CompileMode> COMPILE_MODE = enumeration(COMPILER, "compile.mode", CompileMode.class, CompileMode.JIT, "Set compilation mode. JIT = at runtime; FORCE = before execution.");
public static final Option<Boolean> COMPILE_DUMP = bool(COMPILER, "compile.dump", false, "Dump to console all bytecode generated at runtime.");
Expand Down
1 change: 1 addition & 0 deletions spec/truffle/spec-wrapper
Expand Up @@ -10,4 +10,5 @@ bin/jruby -X+T \
-Xparser.warn.regex_condition=false \
-Xparser.warn.argument_prefix=false \
-Xparser.warn.ambiguous_argument=false \
-Xparser.warn.flags_ignored=false \
-J-ea -J-Xmx2G "$@"
1 change: 1 addition & 0 deletions spec/truffle/spec-wrapper.bat
Expand Up @@ -6,4 +6,5 @@
-Xparser.warn.regex_condition=false ^
-Xparser.warn.argument_prefix=false ^
-Xparser.warn.ambiguous_argument=false ^
-Xparser.warn.flags_ignored=false ^
-J-ea -J-Xmx2G %*
6 changes: 6 additions & 0 deletions test/pom.rb
Expand Up @@ -236,6 +236,7 @@
'<arg value="-Xparser.warn.regex_condition=false" />' +
'<arg value="-Xparser.warn.argument_prefix=false" />' +
'<arg value="-Xparser.warn.ambiguous_argument=false" />' +
'<arg value="-Xparser.warn.flags_ignored=false" />' +
'<arg value="-J-ea" />' +
'<arg value="-J-Xmx1G" />' +
'<arg value="spec/mspec/bin/mspec" />' +
Expand All @@ -261,6 +262,8 @@
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.ambiguous_argument=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.flags_ignored=false" />' +
#'<arg value="-T" />' +
#'<arg value="-J-ea" />' +
'<arg value="--config" />' +
'<arg value="spec/truffle/truffle.mspec" />' +
Expand Down Expand Up @@ -290,6 +293,7 @@
'<arg value="-Xparser.warn.regex_condition=false" />' +
'<arg value="-Xparser.warn.argument_prefix=false" />' +
'<arg value="-Xparser.warn.ambiguous_argument=false" />' +
'<arg value="-Xparser.warn.flags_ignored=false" />' +
'<arg value="-J-ea" />' +
'<arg value="-J-Xmx1G" />' +
'<arg value="spec/mspec/bin/mspec" />' +
Expand All @@ -315,6 +319,8 @@
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.ambiguous_argument=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.flags_ignored=false" />' +
#'<arg value="-T" />' +
#'<arg value="-J-ea" />' +
'<arg value="--config" />' +
'<arg value="spec/truffle/truffle.mspec" />' +
Expand Down
2 changes: 2 additions & 0 deletions test/pom.xml
Expand Up @@ -725,6 +725,7 @@
<arg value="-Xparser.warn.regex_condition=false" />
<arg value="-Xparser.warn.argument_prefix=false" />
<arg value="-Xparser.warn.ambiguous_argument=false" />
<arg value="-Xparser.warn.flags_ignored=false" />
<arg value="-J-ea" />
<arg value="-J-Xmx1G" />
<arg value="spec/mspec/bin/mspec" />
Expand Down Expand Up @@ -769,6 +770,7 @@
<arg value="-Xparser.warn.regex_condition=false" />
<arg value="-Xparser.warn.argument_prefix=false" />
<arg value="-Xparser.warn.ambiguous_argument=false" />
<arg value="-Xparser.warn.flags_ignored=false" />
<arg value="-J-ea" />
<arg value="-J-Xmx1G" />
<arg value="spec/mspec/bin/mspec" />
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.util.ByteList;
import org.jruby.util.cli.Options;

import static org.jruby.util.StringSupport.CR_7BIT;

Expand Down Expand Up @@ -249,7 +250,9 @@ public RubyRegexp initialize(RubyRegexp regexp, RubyRegexp from, @SuppressWarnin
public RubyRegexp initialize(RubyRegexp regexp, RubyRegexp from, @SuppressWarnings("unused") Object options) {
notDesignedForCompilation();

getContext().getWarnings().warn("flags ignored");
if (Options.PARSER_WARN_FLAGS_IGNORED.load()) {
getContext().getWarnings().warn("flags ignored");
}

return initialize(regexp, from, UndefinedPlaceholder.INSTANCE);
}
Expand Down

0 comments on commit 0a6a2b9

Please sign in to comment.