diff options
author | Martin Liska <mliska@suse.cz> | 2019-10-22 11:58:27 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2019-10-22 09:58:27 +0000 |
commit | 076222782e4558e0bd22711c6fdcc0faf0882daf (patch) | |
tree | 3cbd3dcafcbcaf3939736dfe771309b5915a6263 /gcc/json.h | |
parent | fc25649ccd251d9a6c2e27ac821276caaea986e4 (diff) | |
download | gcc-076222782e4558e0bd22711c6fdcc0faf0882daf.zip gcc-076222782e4558e0bd22711c6fdcc0faf0882daf.tar.gz gcc-076222782e4558e0bd22711c6fdcc0faf0882daf.tar.bz2 |
Come up with json::integer_number and use it in GCOV.
2019-10-22 Martin Liska <mliska@suse.cz>
* diagnostic-format-json.cc (json_from_expanded_location):
Use json::integer_number.
* gcov.c (output_intermediate_json_line): Use new
json::integer_number.
(output_json_intermediate_file): Likewise.
* json.cc (number::print): Move to ...
(float_number::print): ... this.
(integer_number::print): New.
(test_writing_numbers): Move to ...
(test_writing_float_numbers): ... this.
(test_writing_integer_numbers): New.
(json_cc_tests): Register test_writing_integer_numbers.
* json.h (class value): Add forward declaration
for float_number and integer_number.
(enum kind): Add JSON_INTEGER and JSON_FLOAT.
(class number): Move to ...
(class float_number): ... this.
(class integer_number): New.
* optinfo-emit-json.cc (optrecord_json_writer::impl_location_to_json):
Use json::integer_number.
(optrecord_json_writer::location_to_json): Likewise.
(optrecord_json_writer::profile_count_to_json): Likewise.
(optrecord_json_writer::pass_to_json): Likewise.
From-SVN: r277284
Diffstat (limited to 'gcc/json.h')
-rw-r--r-- | gcc/json.h | 35 |
1 files changed, 28 insertions, 7 deletions
@@ -39,7 +39,8 @@ namespace json class value; class object; class array; - class number; + class float_number; + class integer_number; class string; class literal; @@ -53,8 +54,11 @@ enum kind /* class json::array. */ JSON_ARRAY, - /* class json::number. */ - JSON_NUMBER, + /* class json::integer_number. */ + JSON_INTEGER, + + /* class json::float_number. */ + JSON_FLOAT, /* class json::string. */ JSON_STRING, @@ -114,14 +118,14 @@ class array : public value auto_vec<value *> m_elements; }; -/* Subclass of value for numbers. */ +/* Subclass of value for floating-point numbers. */ -class number : public value +class float_number : public value { public: - number (double value) : m_value (value) {} + float_number (double value) : m_value (value) {} - enum kind get_kind () const FINAL OVERRIDE { return JSON_NUMBER; } + enum kind get_kind () const FINAL OVERRIDE { return JSON_FLOAT; } void print (pretty_printer *pp) const FINAL OVERRIDE; double get () const { return m_value; } @@ -130,6 +134,23 @@ class number : public value double m_value; }; +/* Subclass of value for integer-valued numbers. */ + +class integer_number : public value +{ + public: + integer_number (long value) : m_value (value) {} + + enum kind get_kind () const FINAL OVERRIDE { return JSON_INTEGER; } + void print (pretty_printer *pp) const FINAL OVERRIDE; + + long get () const { return m_value; } + + private: + long m_value; +}; + + /* Subclass of value for strings. */ class string : public value |