Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / TAO_IDL / be_include / be_map.h
blobd95a7a4bd8dd313df143a9d14009e5a51fc8fc2b
1 // -*- C++ -*-
4 //=============================================================================
5 /**
6 * @file be_map.h
8 * Extension of class AST_Map that provides additional means for C++
9 * mapping.
11 * @author Tyler Mayoff
13 //=============================================================================
15 #ifndef BE_MAP_H
16 #define BE_MAP_H
18 #include "be_scope.h"
19 #include "be_type.h"
20 #include "ast_map.h"
22 class AST_Expression;
23 class AST_Type;
24 class be_visitor;
25 class be_typedef;
26 class be_field;
28 // A map in OMG IDL does not define a scoping construct just as a struct
29 // or union or an interface do. However, in the C++ mapping, a map becomes
30 // a class. If the base type of a map is another anonymous map, then
31 // the base type is defined in the scope of this map. Hence we define
32 // be_map to possess the additional characteristics of a scope.
33 class be_map : public virtual AST_Map,
34 public virtual be_scope,
35 public virtual be_type
37 public:
38 be_map (AST_Expression *v,
39 AST_Type *kt,
40 AST_Type *vt,
41 UTL_ScopedName *n,
42 bool local,
43 bool abstract);
45 /// Non-virtual override of frontend method.
46 be_type *key_type () const;
47 be_type *value_type () const;
49 /**
50 * Returns the fully dealiased key type if it's a typedef. If it's not a
51 * typedef, the it returns the same value as as key_type().
53 be_type *primitive_key_type () const;
55 /**
56 * Returns the fully dealiased key type if it's a typedef. If it's not a
57 * typedef, the it returns the same value as as value_type().
59 be_type *primitive_value_type () const;
61 /// Create a name for ourselves. If we are typedefed, then we get the name of
62 /// the typedef node, else we generate a name for ourselves.
63 int create_name (be_typedef *node);
65 // Scope management functions.
66 virtual AST_Map *fe_add_map (AST_Map *);
68 /// Overridden method on the be_scope class.
69 virtual be_decl *decl ();
71 /// Overridden from class be_type.
72 virtual void gen_ostream_operator (TAO_OutStream *os,
73 bool use_underscore);
75 /// Cleanup method.
76 virtual void destroy ();
78 // Visiting.
79 virtual int accept (be_visitor *visitor);
81 /// Report the instance name for instantiation.
82 const char *instance_name ();
84 /// Accessors for the member.
85 be_field *field_node () const;
86 void field_node (be_field *node);
88 /// Helper to create_name, also used by the traits visitor.
89 virtual char *gen_name ();
91 private:
92 const char *smart_fwd_helper_name (AST_Decl *elem_scope,
93 be_type *elem);
95 private:
96 /// Used if we are an anonymous member, to help generate a unique name.
97 be_field *field_node_;
100 #endif