aboutsummaryrefslogtreecommitdiff
path: root/odb/semantics
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-03-29 11:40:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-03-29 11:40:32 +0200
commit16692f69f3ce5e533c835b553bd00e149191fd9c (patch)
tree1c0a0b6f45499aae413401c1f377ba7b4ef1cdab /odb/semantics
parent02900cdf9a156e631b16c4360c8cb7e6484b004f (diff)
Assign tree nodes to graph type nodes
Diffstat (limited to 'odb/semantics')
-rw-r--r--odb/semantics/class-template.hxx7
-rw-r--r--odb/semantics/class.hxx4
-rw-r--r--odb/semantics/derived.hxx28
-rw-r--r--odb/semantics/elements.hxx30
-rw-r--r--odb/semantics/enum.hxx4
-rw-r--r--odb/semantics/fundamental.hxx58
-rw-r--r--odb/semantics/union-template.hxx7
-rw-r--r--odb/semantics/union.hxx4
-rw-r--r--odb/semantics/unit.hxx20
9 files changed, 102 insertions, 60 deletions
diff --git a/odb/semantics/class-template.hxx b/odb/semantics/class-template.hxx
index 6443a19..68a6151 100644
--- a/odb/semantics/class-template.hxx
+++ b/odb/semantics/class-template.hxx
@@ -63,8 +63,11 @@ namespace semantics
class class_instantiation: public class_, public type_instantiation
{
public:
- class_instantiation (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ class_instantiation (path const& file,
+ size_t line,
+ size_t column,
+ tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/class.hxx b/odb/semantics/class.hxx
index bbe4687..348fbdf 100644
--- a/odb/semantics/class.hxx
+++ b/odb/semantics/class.hxx
@@ -91,8 +91,8 @@ namespace semantics
}
public:
- class_ (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ class_ (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/derived.hxx b/odb/semantics/derived.hxx
index 01dd79c..00ab18a 100644
--- a/odb/semantics/derived.hxx
+++ b/odb/semantics/derived.hxx
@@ -19,6 +19,12 @@ namespace semantics
public:
virtual type&
base_type () const = 0;
+
+ protected:
+ derived_type (tree tn)
+ : type (tn)
+ {
+ }
};
//
@@ -104,17 +110,17 @@ namespace semantics
qualifier (path const& file,
size_t line,
size_t column,
+ tree tn,
bool c,
bool v,
bool r)
- : node (file, line, column), c_ (c), v_ (v), r_ (r), qualifies_ (0)
+ : node (file, line, column), derived_type (tn), c_ (c), v_ (v), r_ (r)
{
}
void
add_edge_left (qualifies_type& e)
{
- assert (qualifies_ == 0);
qualifies_ = &e;
}
@@ -167,7 +173,7 @@ namespace semantics
pointer_type* pointer_;
};
- class pointer: public type
+ class pointer: public derived_type
{
public:
typedef semantics::points points_type;
@@ -185,15 +191,14 @@ namespace semantics
}
public:
- pointer (path const& file, size_t line, size_t column)
- : node (file, line, column), points_ (0)
+ pointer (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), derived_type (tn)
{
}
void
add_edge_left (points_type& e)
{
- assert (points_ == 0);
points_ = &e;
}
@@ -246,7 +251,7 @@ namespace semantics
reference_type* reference_;
};
- class reference: public type
+ class reference: public derived_type
{
public:
typedef semantics::references references_type;
@@ -264,15 +269,14 @@ namespace semantics
}
public:
- reference (path const& file, size_t line, size_t column)
- : node (file, line, column), references_ (0)
+ reference (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), derived_type (tn)
{
}
void
add_edge_left (references_type& e)
{
- assert (references_ == 0);
references_ = &e;
}
@@ -355,15 +359,15 @@ namespace semantics
array (path const& file,
size_t line,
size_t column,
+ tree tn,
unsigned long long size)
- : node (file, line, column), contains_ (0), size_ (size)
+ : node (file, line, column), derived_type (tn), size_ (size)
{
}
void
add_edge_left (contains_type& e)
{
- assert (contains_ == 0);
contains_ = &e;
}
diff --git a/odb/semantics/elements.hxx b/odb/semantics/elements.hxx
index 97f386f..969f33a 100644
--- a/odb/semantics/elements.hxx
+++ b/odb/semantics/elements.hxx
@@ -36,10 +36,6 @@ namespace semantics
using compiler::context;
- // GCC parse tree node.
- //
- typedef ::tree gcc_tree;
-
//
//
using fs::path;
@@ -422,6 +418,13 @@ namespace semantics
typedef std::vector<qualifies*> qualified;
public:
+ tree
+ tree_node () const
+ {
+ return tree_node_;
+ }
+
+ public:
typedef pointer_iterator<qualified::const_iterator> qualified_iterator;
qualified_iterator
@@ -437,11 +440,6 @@ namespace semantics
}
public:
- type (path const& file, size_t line, size_t column)
- : node (file, line, column)
- {
- }
-
void
add_edge_right (belongs&)
{
@@ -456,11 +454,22 @@ namespace semantics
using nameable::add_edge_right;
protected:
+ type (tree tn)
+ : tree_node_ (tn)
+ {
+ }
+
+ // For virtual inheritance. Should never be actually called.
+ //
type ()
{
+ // GCC plugin machinery #define's abort as a macro.
+ //
+ abort ();
}
private:
+ tree tree_node_;
qualified qualified_;
};
@@ -570,8 +579,9 @@ namespace semantics
unsupported_type (path const& file,
size_t line,
size_t column,
+ tree tn,
string const& type_name)
- : node (file, line, column), type_name_ (type_name)
+ : node (file, line, column), type (tn), type_name_ (type_name)
{
}
diff --git a/odb/semantics/enum.hxx b/odb/semantics/enum.hxx
index e628ad9..5ef369c 100644
--- a/odb/semantics/enum.hxx
+++ b/odb/semantics/enum.hxx
@@ -114,8 +114,8 @@ namespace semantics
}
public:
- enum_ (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ enum_ (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/fundamental.hxx b/odb/semantics/fundamental.hxx
index aa8225a..eea49a8 100644
--- a/odb/semantics/fundamental.hxx
+++ b/odb/semantics/fundamental.hxx
@@ -14,16 +14,23 @@ namespace semantics
// Fundamental C++ types.
//
- class fund_type: public type {};
+ class fund_type: public type
+ {
+ protected:
+ fund_type (tree tn)
+ : type (tn) {}
+ };
struct fund_void: fund_type
{
- fund_void (): node (path ("<fundamental>"), 0, 0) {}
+ fund_void (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_bool: fund_type
{
- fund_bool (): node (path ("<fundamental>"), 0, 0) {}
+ fund_bool (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
//
@@ -32,62 +39,74 @@ namespace semantics
struct fund_char: fund_type
{
- fund_char (): node (path ("<fundamental>"), 0, 0) {}
+ fund_char (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_wchar: fund_type
{
- fund_wchar (): node (path ("<fundamental>"), 0, 0) {}
+ fund_wchar (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_signed_char: fund_type
{
- fund_signed_char (): node (path ("<fundamental>"), 0, 0) {}
+ fund_signed_char (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_char: fund_type
{
- fund_unsigned_char (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_char (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_short: fund_type
{
- fund_short (): node (path ("<fundamental>"), 0, 0) {}
+ fund_short (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_short: fund_type
{
- fund_unsigned_short (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_short (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_int: fund_type
{
- fund_int (): node (path ("<fundamental>"), 0, 0) {}
+ fund_int (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_int: fund_type
{
- fund_unsigned_int (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_int (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_long: fund_type
{
- fund_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_long: fund_type
{
- fund_unsigned_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_long_long: fund_type
{
- fund_long_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_long_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_unsigned_long_long: fund_type
{
- fund_unsigned_long_long (): node (path ("<fundamental>"), 0, 0) {}
+ fund_unsigned_long_long (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
//
@@ -96,17 +115,20 @@ namespace semantics
struct fund_float: fund_type
{
- fund_float (): node (path ("<fundamental>"), 0, 0) {}
+ fund_float (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_double: fund_type
{
- fund_double (): node (path ("<fundamental>"), 0, 0) {}
+ fund_double (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
struct fund_long_double: fund_type
{
- fund_long_double (): node (path ("<fundamental>"), 0, 0) {}
+ fund_long_double (tree tn)
+ : node (path ("<fundamental>"), 0, 0), fund_type (tn) {}
};
}
diff --git a/odb/semantics/union-template.hxx b/odb/semantics/union-template.hxx
index 1aaadb7..8e74e6e 100644
--- a/odb/semantics/union-template.hxx
+++ b/odb/semantics/union-template.hxx
@@ -28,8 +28,11 @@ namespace semantics
class union_instantiation: public union_, public type_instantiation
{
public:
- union_instantiation (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ union_instantiation (path const& file,
+ size_t line,
+ size_t column,
+ tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/union.hxx b/odb/semantics/union.hxx
index 2873d97..e4b93a9 100644
--- a/odb/semantics/union.hxx
+++ b/odb/semantics/union.hxx
@@ -13,8 +13,8 @@ namespace semantics
class union_: public virtual type, public scope
{
public:
- union_ (path const& file, size_t line, size_t column)
- : node (file, line, column)
+ union_ (path const& file, size_t line, size_t column, tree tn)
+ : node (file, line, column), type (tn)
{
}
diff --git a/odb/semantics/unit.hxx b/odb/semantics/unit.hxx
index c208876..05eec7f 100644
--- a/odb/semantics/unit.hxx
+++ b/odb/semantics/unit.hxx
@@ -25,20 +25,20 @@ namespace semantics
new_edge<global_names> (*this, *this);
}
- // Mapping from GCC tree node to semantic graph node.
+ // Mapping from tree nodes to semantic graph nodes.
//
public:
node*
- find (gcc_tree key) const
+ find (tree key) const
{
- gcc_tree_node_map::const_iterator i (gcc_tree_node_map_.find (key));
- return i != gcc_tree_node_map_.end () ? i->second : 0;
+ tree_node_map::const_iterator i (tree_node_map_.find (key));
+ return i != tree_node_map_.end () ? i->second : 0;
}
void
- insert (gcc_tree key, node& value)
+ insert (tree key, node& value)
{
- gcc_tree_node_map_[key] = &value;
+ tree_node_map_[key] = &value;
}
public:
@@ -84,9 +84,9 @@ namespace semantics
//
template <typename T>
T&
- new_fund_node ()
+ new_fund_node (tree tn)
{
- return graph_.new_node<T> ();
+ return graph_.new_node<T> (tn);
}
protected:
@@ -134,8 +134,8 @@ namespace semantics
private:
graph<node, edge>& graph_;
- typedef std::map<gcc_tree, node*> gcc_tree_node_map;
- gcc_tree_node_map gcc_tree_node_map_;
+ typedef std::map<tree, node*> tree_node_map;
+ tree_node_map tree_node_map_;
};
}