Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
// -*- mode: C++ -*-
|
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
#ifndef __ABG_IR_H__
|
|
|
|
#define __ABG_IR_H__
|
2013-02-28 10:42:57 +00:00
|
|
|
|
|
|
|
#include <cstddef>
|
2013-02-28 23:38:28 +00:00
|
|
|
#include <tr1/memory>
|
|
|
|
#include <list>
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
#include <string>
|
|
|
|
#include <tr1/functional>
|
|
|
|
#include <typeinfo>
|
2013-03-28 14:27:15 +00:00
|
|
|
#include <utility> // for std::rel_ops, at least.
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
#include "abg-hash.h"
|
2013-02-28 10:42:57 +00:00
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
using std::tr1::shared_ptr;
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
using std::tr1::hash;
|
|
|
|
using std::string;
|
2013-02-28 10:42:57 +00:00
|
|
|
|
|
|
|
// Our real stuff
|
|
|
|
namespace abigail
|
|
|
|
{
|
2013-03-28 14:27:15 +00:00
|
|
|
|
|
|
|
using namespace std::rel_ops; // Pull in relational operators so that
|
|
|
|
// we don't have to define them all here.
|
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
/// \brief The source location of a token.
|
2013-03-21 13:43:30 +00:00
|
|
|
///
|
2013-02-28 23:38:28 +00:00
|
|
|
/// This represents the location of a token coming from a given ABI
|
|
|
|
/// Corpus. This location is actually an abstraction of cursor in the
|
|
|
|
/// table of all the locations of all the tokens of the ABI Corpus.
|
|
|
|
/// That table is managed by the location_manager type.
|
|
|
|
class location
|
|
|
|
{
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
location (unsigned v)
|
|
|
|
: m_value(v)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
public:
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
location()
|
|
|
|
: m_value(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned
|
|
|
|
get_value() const
|
|
|
|
{
|
|
|
|
return m_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator bool() const
|
|
|
|
{
|
|
|
|
return !!m_value;
|
|
|
|
}
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
bool
|
|
|
|
operator==(const location other) const
|
|
|
|
{return m_value == other.m_value;}
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator<(const location other) const
|
|
|
|
{return m_value < other.m_value;}
|
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
friend class location_manager;
|
2013-03-04 15:29:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned m_value;
|
2013-02-28 23:38:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief The entry point to manage locations.
|
|
|
|
///
|
|
|
|
/// This type keeps a table of all the locations for tokens of a
|
|
|
|
/// given ABI Corpus
|
|
|
|
class location_manager
|
|
|
|
{
|
|
|
|
struct priv;
|
|
|
|
shared_ptr<priv> m_priv;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
location_manager();
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
|
|
|
location
|
|
|
|
create_new_location(const std::string& file,
|
|
|
|
size_t line,
|
|
|
|
size_t column);
|
|
|
|
|
|
|
|
void
|
|
|
|
expand_location(const location location,
|
|
|
|
std::string& path,
|
|
|
|
unsigned& line,
|
2013-03-21 13:43:30 +00:00
|
|
|
unsigned& column) const;
|
2013-02-28 23:38:28 +00:00
|
|
|
};
|
|
|
|
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
class decl_base;
|
2013-02-28 23:38:28 +00:00
|
|
|
class scope_decl;
|
|
|
|
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
void add_decl_to_scope(shared_ptr<decl_base>,
|
2013-03-31 17:35:41 +00:00
|
|
|
scope_decl*);
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
/// \brief The base type of all declarations.
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
class decl_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
decl_base();
|
|
|
|
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
void
|
2013-03-31 17:35:41 +00:00
|
|
|
set_scope(scope_decl*);
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
public:
|
2013-02-28 23:38:28 +00:00
|
|
|
|
2013-03-31 18:04:17 +00:00
|
|
|
enum visibility
|
|
|
|
{
|
|
|
|
VISIBILITY_NONE,
|
|
|
|
VISIBILITY_DEFAULT,
|
|
|
|
VISIBILITY_PROTECTED,
|
|
|
|
VISIBILITY_HIDDEN,
|
|
|
|
VISIBILITY_INTERNAL
|
|
|
|
};
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
decl_base(const std::string& name,
|
2013-03-31 18:04:17 +00:00
|
|
|
location locus,
|
|
|
|
visibility = VISIBILITY_DEFAULT);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
decl_base(location);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
decl_base(const decl_base&);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~decl_base();
|
|
|
|
|
|
|
|
location
|
|
|
|
get_location() const
|
2013-03-31 18:09:52 +00:00
|
|
|
{return m_location;}
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
set_location(const location&l)
|
2013-03-31 18:09:52 +00:00
|
|
|
{m_location = l;}
|
2013-02-28 23:38:28 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
const string&
|
|
|
|
get_name() const
|
2013-03-31 18:09:52 +00:00
|
|
|
{return m_name;}
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
set_name(const string& n)
|
2013-03-31 18:09:52 +00:00
|
|
|
{m_name = n;}
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-31 17:35:41 +00:00
|
|
|
scope_decl*
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
get_scope() const
|
|
|
|
{
|
|
|
|
return m_context;
|
|
|
|
}
|
2013-03-04 15:29:31 +00:00
|
|
|
|
2013-03-31 18:04:17 +00:00
|
|
|
visibility
|
|
|
|
get_visibility() const
|
|
|
|
{return m_visibility;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_visibility(visibility v)
|
|
|
|
{m_visibility = v;}
|
|
|
|
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
friend void
|
|
|
|
add_decl_to_scope(shared_ptr<decl_base>,
|
2013-03-31 17:35:41 +00:00
|
|
|
scope_decl*);
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
private:
|
|
|
|
location m_location;
|
|
|
|
std::string m_name;
|
2013-03-31 17:35:41 +00:00
|
|
|
scope_decl* m_context;
|
2013-03-31 18:04:17 +00:00
|
|
|
visibility m_visibility;
|
2013-02-28 23:38:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief A declaration that introduces a scope.
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
class scope_decl : public decl_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
|
|
|
scope_decl();
|
|
|
|
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
void
|
|
|
|
add_member_decl(const shared_ptr<decl_base>);
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
public:
|
2013-03-31 18:04:17 +00:00
|
|
|
scope_decl(const std::string& name,
|
|
|
|
location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
scope_decl(location);
|
2013-02-28 23:38:28 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const scope_decl&) const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
const std::list<shared_ptr<decl_base> >&
|
|
|
|
get_member_decls() const;
|
|
|
|
|
|
|
|
virtual ~scope_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
friend void
|
|
|
|
add_decl_to_scope(shared_ptr<decl_base>,
|
2013-03-31 17:35:41 +00:00
|
|
|
scope_decl*);
|
Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
2013-03-25 15:56:00 +00:00
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
private:
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
std::list<shared_ptr<decl_base> > m_members;
|
2013-02-28 23:38:28 +00:00
|
|
|
};
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
/// \brief Facility to hash instances of decl_base.
|
|
|
|
struct decl_base_hash
|
|
|
|
{
|
|
|
|
size_t
|
2013-03-27 22:34:07 +00:00
|
|
|
operator() (const decl_base& d) const
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
{
|
|
|
|
hash<string> str_hash;
|
|
|
|
hash<unsigned> unsigned_hash;
|
|
|
|
|
|
|
|
size_t v = str_hash(typeid(d).name());
|
|
|
|
if (!d.get_name().empty())
|
|
|
|
v = hashing::combine_hashes(v, str_hash(d.get_name()));
|
|
|
|
if (d.get_location())
|
|
|
|
v = hashing::combine_hashes(v, unsigned_hash(d.get_location()));
|
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
if (d.get_scope())
|
|
|
|
v = hashing::combine_hashes(v, this->operator()(*d.get_scope()));
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};//end struct decl_base_hash
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
/// An abstraction helper for type declarations
|
2013-02-28 23:38:28 +00:00
|
|
|
class type_base
|
|
|
|
{
|
2013-03-04 15:29:31 +00:00
|
|
|
// Forbid this.
|
2013-02-28 23:38:28 +00:00
|
|
|
type_base();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
type_base(size_t s, size_t a);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~type_base();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
void
|
|
|
|
set_size_in_bits(size_t);
|
2013-02-28 23:38:28 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
size_t
|
|
|
|
get_size_in_bits() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_alignment_in_bits(size_t);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
get_alignment_in_bits() const;
|
2013-03-04 15:29:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
size_t m_size_in_bits;
|
|
|
|
size_t m_alignment_in_bits;
|
2013-03-27 22:34:07 +00:00
|
|
|
};//class type_base;
|
|
|
|
|
|
|
|
/// A hasher for type_base types.
|
|
|
|
struct type_base_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const type_base& t) const
|
|
|
|
{
|
|
|
|
hash<size_t> size_t_hash;
|
2013-03-29 14:30:34 +00:00
|
|
|
hash<string> str_hash;
|
2013-03-27 22:34:07 +00:00
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
size_t v = str_hash(typeid(t).name());
|
|
|
|
v = hashing::combine_hashes(v, size_t_hash(t.get_size_in_bits()));
|
2013-03-27 22:34:07 +00:00
|
|
|
v = hashing::combine_hashes(v, size_t_hash(t.get_alignment_in_bits()));
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};//end struct type_base_hash
|
|
|
|
|
|
|
|
/// A hasher for types. It gets the dynamic type of the current
|
|
|
|
/// instance of type and hashes it accordingly. Note that the hashing
|
|
|
|
/// function of this hasher must be updated each time a new kind of
|
|
|
|
/// type is added to the IR.
|
|
|
|
struct dynamic_type_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const type_base* t) const;
|
|
|
|
};//end struct dynamic_type_hash
|
|
|
|
|
|
|
|
/// A hasher for shared_ptr<type_base> that will hash it based on the
|
|
|
|
/// runtime type of the type pointed to.
|
|
|
|
struct type_shared_ptr_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const shared_ptr<type_base> t) const
|
|
|
|
{
|
|
|
|
return dynamic_type_hash()(t.get());
|
|
|
|
}
|
|
|
|
};//end struct type_shared_ptr_hash
|
2013-02-28 23:38:28 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
/// A predicate for deep equality of instances of
|
|
|
|
/// shared_ptr<type_base>
|
|
|
|
struct type_shared_ptr_equal
|
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const shared_ptr<type_base>l,
|
|
|
|
const shared_ptr<type_base>r) const
|
|
|
|
{
|
|
|
|
if (l != r)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (l)
|
|
|
|
return *l == *r;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};//end struct type_shared_ptr_equal
|
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
/// A basic type declaration that introduces no scope.
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
class type_decl : public decl_base, public type_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
2013-03-04 15:29:31 +00:00
|
|
|
// Forbidden.
|
2013-02-28 23:38:28 +00:00
|
|
|
type_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
public:
|
|
|
|
|
2013-03-31 18:04:17 +00:00
|
|
|
type_decl(const std::string& name,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits,
|
|
|
|
location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const type_decl&) const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~type_decl();
|
2013-03-27 22:34:07 +00:00
|
|
|
};// class type_decl
|
2013-02-28 23:38:28 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
/// Facility to hash instance of type_decl
|
|
|
|
struct type_decl_hash
|
|
|
|
{
|
|
|
|
size_t
|
2013-03-27 22:34:07 +00:00
|
|
|
operator()(const type_decl& t) const
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
{
|
|
|
|
decl_base_hash decl_hash;
|
2013-03-27 22:34:07 +00:00
|
|
|
type_base_hash type_hash;
|
2013-03-29 14:30:34 +00:00
|
|
|
hash<string> str_hash;
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
size_t v = str_hash(typeid(t).name());
|
|
|
|
v = hashing::combine_hashes(v, decl_hash(t));
|
2013-03-27 22:34:07 +00:00
|
|
|
v = hashing::combine_hashes(v, type_hash(t));
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};//end struct type_decl_hash
|
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
/// A type that introduces a scope.
|
|
|
|
class scope_type_decl : public scope_decl, public type_base
|
|
|
|
{
|
|
|
|
scope_type_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
scope_type_decl(const std::string& name,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits,
|
|
|
|
location locus);
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const scope_type_decl&) const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~scope_type_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
};
|
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
/// Hasher for instances of scope_type_decl
|
|
|
|
struct scope_type_decl_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const scope_type_decl& t) const
|
|
|
|
{
|
|
|
|
decl_base_hash decl_hash;
|
|
|
|
type_base_hash type_hash;
|
2013-03-29 14:30:34 +00:00
|
|
|
hash<string> str_hash;
|
2013-03-27 22:34:07 +00:00
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
size_t v = str_hash(typeid(t).name());
|
|
|
|
v = hashing::combine_hashes(v, decl_hash(t));
|
2013-03-30 20:48:46 +00:00
|
|
|
v = hashing::combine_hashes(v, type_hash(t));
|
2013-03-27 22:34:07 +00:00
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};//end struct scope_type_decl_hash
|
|
|
|
|
|
|
|
/// The abstraction of a namespace declaration
|
2013-03-04 15:29:31 +00:00
|
|
|
class namespace_decl : public scope_decl
|
|
|
|
{
|
2013-02-28 23:38:28 +00:00
|
|
|
public:
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
namespace_decl(const std::string& name,
|
|
|
|
location locus);
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const namespace_decl&) const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~namespace_decl();
|
2013-03-27 22:34:07 +00:00
|
|
|
};//end class namespace_decl
|
|
|
|
|
|
|
|
/// The abstraction of a qualified type.
|
|
|
|
class qualified_type_def : public type_base, public decl_base
|
|
|
|
{
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
// Forbidden.
|
|
|
|
qualified_type_def();
|
2013-03-27 22:34:07 +00:00
|
|
|
public:
|
|
|
|
/// Bit field values representing the cv qualifiers of the
|
|
|
|
/// underlying type.
|
|
|
|
enum CV
|
|
|
|
{
|
|
|
|
CV_NONE = 0,
|
|
|
|
CV_CONST = 1,
|
|
|
|
CV_VOLATILE = 1 << 1
|
|
|
|
};
|
|
|
|
|
|
|
|
qualified_type_def(shared_ptr<type_base> underlying_type,
|
|
|
|
CV quals,
|
|
|
|
location locus);
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const qualified_type_def&) const;
|
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
char
|
|
|
|
get_cv_quals() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_cv_quals(char cv_quals);
|
|
|
|
|
|
|
|
const shared_ptr<type_base>
|
|
|
|
get_underlying_type() const;
|
|
|
|
|
|
|
|
virtual ~qualified_type_def();
|
|
|
|
|
|
|
|
private:
|
|
|
|
char m_cv_quals;
|
|
|
|
shared_ptr<type_base> m_underlying_type;
|
|
|
|
};//end class qualified_type_def
|
|
|
|
|
|
|
|
/// A Hasher for instances of qualified_type_def
|
|
|
|
struct qualified_type_def_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const qualified_type_def& t) const
|
|
|
|
{
|
|
|
|
type_base_hash type_hash;
|
|
|
|
decl_base_hash decl_hash;
|
2013-03-29 14:30:34 +00:00
|
|
|
hash<string> str_hash;
|
2013-03-27 22:34:07 +00:00
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
size_t v = str_hash(typeid(t).name());
|
2013-03-30 20:48:46 +00:00
|
|
|
v = hashing::combine_hashes(v, type_hash(t));
|
|
|
|
v = hashing::combine_hashes(v, decl_hash(t));
|
2013-03-27 22:34:07 +00:00
|
|
|
v = hashing::combine_hashes(v, t.get_cv_quals());
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};//end struct qualified_type_def_hash
|
2013-02-28 10:42:57 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
/// The abstraction of a pointer type.
|
|
|
|
class pointer_type_def : public type_base, public decl_base
|
|
|
|
{
|
|
|
|
// Forbidden.
|
|
|
|
pointer_type_def();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
pointer_type_def(shared_ptr<type_base>& pointed_to_type,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits,
|
|
|
|
location locus);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const pointer_type_def&) const;
|
|
|
|
|
|
|
|
shared_ptr<type_base>
|
|
|
|
get_pointed_to_type() const;
|
|
|
|
|
|
|
|
virtual ~pointer_type_def();
|
|
|
|
|
|
|
|
private:
|
|
|
|
shared_ptr<type_base> m_pointed_to_type;
|
|
|
|
};//end class pointer_type_def
|
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
/// A hasher for instances of pointer_type_def
|
|
|
|
struct pointer_type_def_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const pointer_type_def& t) const
|
|
|
|
{
|
|
|
|
hash<string> str_hash;
|
|
|
|
type_base_hash type_hash;
|
|
|
|
decl_base_hash decl_hash;
|
|
|
|
|
|
|
|
size_t v = str_hash(typeid(t).name());
|
2013-03-30 20:48:46 +00:00
|
|
|
v = hashing::combine_hashes(v, decl_hash(t));
|
|
|
|
v = hashing::combine_hashes(v, type_hash(t));
|
2013-03-29 14:30:34 +00:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};// end struct pointer_type_def_hash
|
|
|
|
|
|
|
|
/// Abstracts a reference type.
|
|
|
|
class reference_type_def : public type_base, public decl_base
|
|
|
|
{
|
|
|
|
// Forbidden.
|
|
|
|
reference_type_def();
|
|
|
|
|
|
|
|
public:
|
|
|
|
reference_type_def(shared_ptr<type_base>& pointed_to_type,
|
|
|
|
bool lvalue,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits,
|
|
|
|
location locus);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const reference_type_def&) const;
|
|
|
|
|
|
|
|
shared_ptr<type_base>
|
|
|
|
get_pointed_to_type() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_lvalue() const;
|
|
|
|
|
|
|
|
virtual ~reference_type_def();
|
|
|
|
|
|
|
|
private:
|
|
|
|
shared_ptr<type_base> m_pointed_to_type;
|
|
|
|
bool m_is_lvalue;
|
|
|
|
};//end class reference_type_def
|
|
|
|
|
|
|
|
/// Hasher for intances of reference_type_def.
|
|
|
|
struct reference_type_def_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator() (const reference_type_def& t)
|
|
|
|
{
|
|
|
|
hash<string> str_hash;
|
|
|
|
type_base_hash type_hash;
|
|
|
|
decl_base_hash decl_hash;
|
|
|
|
|
|
|
|
size_t v = str_hash(typeid(t).name());
|
|
|
|
v = hashing::combine_hashes(v, str_hash(t.is_lvalue()
|
|
|
|
? "lvalue"
|
|
|
|
: "rvalue"));
|
2013-03-30 20:48:46 +00:00
|
|
|
v = hashing::combine_hashes(v, type_hash(t));
|
|
|
|
v = hashing::combine_hashes(v, decl_hash(t));
|
2013-03-29 14:30:34 +00:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};//end struct reference_type_def_hash
|
|
|
|
|
2013-03-30 18:02:51 +00:00
|
|
|
/// Abstracts a declaration for an enum type.
|
|
|
|
class enum_type_decl: public type_base, public decl_base
|
|
|
|
{
|
|
|
|
// Forbidden
|
|
|
|
enum_type_decl();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
class enumerator
|
|
|
|
{
|
|
|
|
//Forbidden
|
|
|
|
enumerator();
|
|
|
|
public:
|
|
|
|
|
|
|
|
enumerator(const string& name,
|
|
|
|
size_t value)
|
|
|
|
:m_name(name),
|
|
|
|
m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const enumerator& other) const
|
|
|
|
{
|
|
|
|
return (get_name() == other.get_name()
|
|
|
|
&& get_value() == other.get_value());
|
|
|
|
}
|
|
|
|
const string&
|
|
|
|
get_name() const
|
|
|
|
{return m_name;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_name(const string& n)
|
|
|
|
{m_name = n;}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
get_value() const
|
|
|
|
{return m_value;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_value(size_t v)
|
|
|
|
{m_value=v;}
|
|
|
|
|
|
|
|
private:
|
|
|
|
string m_name;
|
|
|
|
size_t m_value;
|
|
|
|
};//end struct enumerator
|
|
|
|
|
|
|
|
enum_type_decl(const string& name,
|
|
|
|
location locus,
|
|
|
|
shared_ptr<type_base> underlying_type,
|
2013-03-31 18:04:17 +00:00
|
|
|
const std::list<enumerator>& enumerators,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
2013-03-30 18:02:51 +00:00
|
|
|
|
|
|
|
shared_ptr<type_base>
|
|
|
|
get_underlying_type() const;
|
|
|
|
|
|
|
|
const std::list<enumerator>&
|
|
|
|
get_enumerators() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const enum_type_decl&) const;
|
|
|
|
|
|
|
|
virtual ~enum_type_decl();
|
|
|
|
|
|
|
|
private:
|
|
|
|
shared_ptr<type_base> m_underlying_type;
|
|
|
|
std::list<enumerator> m_enumerators;
|
|
|
|
};// end class enum_type_decl
|
|
|
|
|
|
|
|
/// A hasher for an enum_type_decl.
|
|
|
|
struct enum_type_decl_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const enum_type_decl& t) const
|
|
|
|
{
|
|
|
|
hash<string> str_hash;
|
|
|
|
type_shared_ptr_hash type_ptr_hash;
|
|
|
|
hash<size_t> size_t_hash;
|
|
|
|
|
|
|
|
size_t v = str_hash(typeid(t).name());
|
|
|
|
v = hashing::combine_hashes(v, type_ptr_hash(t.get_underlying_type()));
|
|
|
|
for (std::list<enum_type_decl::enumerator>::const_iterator i =
|
|
|
|
t.get_enumerators().begin();
|
|
|
|
i != t.get_enumerators().end();
|
|
|
|
++i)
|
|
|
|
{
|
|
|
|
v = hashing::combine_hashes(v, str_hash(i->get_name()));
|
|
|
|
v = hashing::combine_hashes(v, size_t_hash(i->get_value()));
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};//end struct enum_type_decl_hash
|
|
|
|
|
2013-03-30 20:51:43 +00:00
|
|
|
/// The abstraction of a typedef declaration.
|
|
|
|
class typedef_decl: public type_base, public decl_base
|
|
|
|
{
|
|
|
|
// Forbidden
|
|
|
|
typedef_decl();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef_decl(const string& name,
|
|
|
|
const shared_ptr<type_base> underlying_type,
|
2013-03-31 18:04:17 +00:00
|
|
|
location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
2013-03-30 20:51:43 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const typedef_decl&) const;
|
|
|
|
|
|
|
|
shared_ptr<type_base>
|
|
|
|
get_underlying_type() const;
|
|
|
|
|
|
|
|
virtual ~typedef_decl();
|
|
|
|
|
|
|
|
private:
|
|
|
|
shared_ptr<type_base> m_underlying_type;
|
|
|
|
};//end class typedef_decl
|
|
|
|
|
|
|
|
/// Hasher for the typedef_decl type.
|
|
|
|
struct typedef_decl_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const typedef_decl& t) const
|
|
|
|
{
|
|
|
|
hash<string> str_hash;
|
|
|
|
type_base_hash type_hash;
|
|
|
|
decl_base_hash decl_hash;
|
|
|
|
type_shared_ptr_hash type_ptr_hash;
|
|
|
|
|
|
|
|
size_t v = str_hash(typeid(t).name());
|
|
|
|
v = hashing::combine_hashes(v, type_hash(t));
|
|
|
|
v = hashing::combine_hashes(v, decl_hash(t));
|
|
|
|
v = hashing::combine_hashes(v, type_ptr_hash(t.get_underlying_type()));
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
};// end struct typedef_decl_hash
|
2013-02-28 23:38:28 +00:00
|
|
|
} // end namespace abigail
|
2013-03-29 14:30:34 +00:00
|
|
|
#endif // __ABG_IR_H__
|