Mercurial > hg > CbC > CbC_gcc
diff gcc/json.h @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line diff
--- a/gcc/json.h Thu Oct 25 07:37:49 2018 +0900 +++ b/gcc/json.h Thu Feb 13 11:34:05 2020 +0900 @@ -1,5 +1,5 @@ /* JSON trees - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2017-2020 Free Software Foundation, Inc. Contributed by David Malcolm <dmalcolm@redhat.com>. This file is part of GCC. @@ -39,7 +39,8 @@ class value; class object; class array; - class number; + class float_number; + class integer_number; class string; class literal; @@ -53,8 +54,11 @@ /* 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, @@ -90,6 +94,7 @@ void print (pretty_printer *pp) const FINAL OVERRIDE; void set (const char *key, value *v); + value *get (const char *key) const; private: typedef hash_map <char *, value *, @@ -113,14 +118,14 @@ 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; } @@ -129,6 +134,23 @@ 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 @@ -154,6 +176,9 @@ public: literal (enum kind kind) : m_kind (kind) {} + /* Construct literal for a boolean value. */ + literal (bool value): m_kind (value ? JSON_TRUE : JSON_FALSE) {} + enum kind get_kind () const FINAL OVERRIDE { return m_kind; } void print (pretty_printer *pp) const FINAL OVERRIDE;