Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / TAO_IDL / fe / fe_home_header.cpp
blobd7a3118d20e17cbcaa630eb1c95d6a7faee0a837
1 #include "fe_home_header.h"
3 #include "global_extern.h"
4 #include "utl_err.h"
5 #include "fe_extern.h"
7 #include "ast_home.h"
8 #include "ast_component.h"
9 #include "ast_valuetype.h"
10 #include "ast_param_holder.h"
12 FE_HomeHeader::FE_HomeHeader (UTL_ScopedName *n,
13 UTL_ScopedName *base_home,
14 UTL_NameList *supports,
15 UTL_ScopedName *managed_component,
16 UTL_ScopedName *primary_key)
17 : FE_ComponentHeader (n,
19 supports,
20 false),
21 base_home_ (0),
22 primary_key_ (0)
24 // No need to call compile_supports(), it got done in
25 // the call to the base class FE_ComponentHeader.
26 this->compile_inheritance (base_home);
27 this->compile_managed_component (managed_component);
28 this->compile_primary_key (primary_key);
31 FE_HomeHeader::~FE_HomeHeader (void)
35 AST_Home *
36 FE_HomeHeader::base_home (void) const
38 return this->base_home_;
41 AST_Component *
42 FE_HomeHeader::managed_component (void) const
44 return this->managed_component_;
47 AST_Type *
48 FE_HomeHeader::primary_key (void) const
50 return this->primary_key_;
53 void
54 FE_HomeHeader::compile_inheritance (UTL_ScopedName *base_home)
56 if (base_home == 0)
58 return;
61 UTL_Scope *s = idl_global->scopes ().top_non_null ();
62 AST_Decl *d = s->lookup_by_name (base_home,
63 true);
65 if (d == 0)
67 idl_global->err ()->lookup_error (base_home);
69 // This is probably the result of bad IDL.
70 // We will crash if we continue from here.
71 throw Bailout ();
74 if (d->node_type () == AST_Decl::NT_typedef)
76 d = dynamic_cast<AST_Typedef*> (d)->primitive_base_type ();
79 this->base_home_ = dynamic_cast<AST_Home*> (d);
81 if (this->base_home_ == 0)
83 idl_global->err ()->inheritance_error (this->name (), d);
87 void
88 FE_HomeHeader::compile_managed_component (
89 UTL_ScopedName *mc_name)
91 if (mc_name == 0)
93 return;
96 UTL_Scope *s = idl_global->scopes ().top_non_null ();
97 AST_Decl *d = s->lookup_by_name (mc_name,
98 true);
100 if (d == 0)
102 idl_global->err ()->lookup_error (mc_name);
104 // This is probably the result of bad IDL.
105 // We will crash if we continue from here.
106 throw Bailout ();
109 if (d->node_type () == AST_Decl::NT_typedef)
111 d = dynamic_cast<AST_Typedef*> (d)->primitive_base_type ();
114 this->managed_component_ = dynamic_cast<AST_Component*> (d);
116 if (this->managed_component_ == 0)
118 idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_USE,
123 void
124 FE_HomeHeader::compile_primary_key (UTL_ScopedName *primary_key)
126 if (primary_key == 0)
128 return;
131 UTL_Scope *s = idl_global->scopes ().top_non_null ();
132 AST_Decl *d = s->lookup_by_name (primary_key,
133 true);
135 if (d == 0)
137 idl_global->err ()->lookup_error (primary_key);
139 // This is probably the result of bad IDL.
140 // We will crash if we continue from here.
141 throw Bailout ();
144 AST_Decl::NodeType nt = d->node_type ();
146 if (nt == AST_Decl::NT_typedef)
148 d = dynamic_cast<AST_Typedef*> (d)->primitive_base_type ();
151 this->primary_key_ = dynamic_cast<AST_Type*> (d);
153 if (this->primary_key_ == 0)
155 idl_global->err ()->valuetype_expected (d);
157 else
159 switch (nt)
161 case AST_Decl::NT_valuetype:
162 break;
163 case AST_Decl::NT_param_holder:
165 AST_Param_Holder *ph =
166 dynamic_cast<AST_Param_Holder*> (d);
168 nt = ph->info ()->type_;
170 if (nt != AST_Decl::NT_type
171 && nt != AST_Decl::NT_valuetype)
173 idl_global->err ()->mismatched_template_param (
174 ph->info ()->name_.c_str ());
177 break;
179 default:
180 idl_global->err ()->valuetype_expected (d);
181 break;