Skip to content

Commit 9b62401

Browse files
committed
Make --regexp-instrumentation-output-format an enum option
1 parent 747c04b commit 9b62401

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/main/ruby/truffleruby/core/truffle/regexp_operations.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def self.match_stats(joni_matches:)
175175
def self.print_stats
176176
output_format = Truffle::Boot.get_option('regexp-instrumentation-output-format')
177177

178-
if output_format == 'text'
178+
if output_format == :TEXT
179179
puts '--------------------'
180180
puts 'Regular expression statistics'
181181
puts '--------------------'
@@ -204,7 +204,7 @@ def self.print_stats
204204

205205
puts '--------------------'
206206
end
207-
elsif output_format == 'json'
207+
elsif output_format == :JSON
208208
ret = {}
209209

210210
if Truffle::Boot.get_option('regexp-instrument-creation')

src/options.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ INTERNAL: # Options for debugging the TruffleRuby implementation
237237
REGEXP_INSTRUMENT_CREATION: [regexp-instrument-creation, boolean, false, Enable instrumentation to gather stats on regexp creation]
238238
REGEXP_INSTRUMENT_MATCH: [regexp-instrument-match, boolean, false, Enable instrumentation to gather stats on regexp matching]
239239
REGEXP_INSTRUMENT_MATCH_DETAILED: [regexp-instrument-match-detailed, boolean, false, Enable instrumentation to gather detailed stats on strings matched against a regexp]
240-
REGEXP_INSTRUMENT_OUTPUT_FORMAT: [regexp-instrumentation-output-format, string, 'text', 'Output format for regexp instrumentation (\\\"text\\\" or \\\"json\\\")']
240+
REGEXP_INSTRUMENT_OUTPUT_FORMAT: [regexp-instrumentation-output-format, enum/output_format, text, 'Output format for regexp instrumentation']
241241

242242
# Options for metrics, the output cannot be used directly without processing
243243
METRICS_TIME_PARSING_FILE: [metrics-time-parsing-file, boolean, false, 'Measure time for parsing, translating and executing files, per file']
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved. This
3+
* code is released under a tri EPL/GPL/LGPL license. You can use it,
4+
* redistribute it and/or modify it under the terms of the:
5+
*
6+
* Eclipse Public License version 2.0, or
7+
* GNU General Public License version 2, or
8+
* GNU Lesser General Public License version 2.1.
9+
*/
10+
package org.truffleruby.shared.options;
11+
12+
import java.util.Locale;
13+
14+
public enum Verbosity {
15+
NIL,
16+
FALSE,
17+
TRUE;
18+
19+
@Override
20+
public String toString() {
21+
return name().toLowerCase(Locale.ENGLISH);
22+
}
23+
}

0 commit comments

Comments
 (0)