1*d291ea28SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*d291ea28SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d291ea28SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*d291ea28SAndrew Rist * distributed with this work for additional information
6*d291ea28SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*d291ea28SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d291ea28SAndrew Rist * "License"); you may not use this file except in compliance
9*d291ea28SAndrew Rist * with the License. You may obtain a copy of the License at
10*d291ea28SAndrew Rist *
11*d291ea28SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d291ea28SAndrew Rist *
13*d291ea28SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d291ea28SAndrew Rist * software distributed under the License is distributed on an
15*d291ea28SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d291ea28SAndrew Rist * KIND, either express or implied. See the License for the
17*d291ea28SAndrew Rist * specific language governing permissions and limitations
18*d291ea28SAndrew Rist * under the License.
19*d291ea28SAndrew Rist *
20*d291ea28SAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir
23cdf0e10cSrcweir #include <precomp.h>
24cdf0e10cSrcweir #include "ca_ce.hxx"
25cdf0e10cSrcweir
26cdf0e10cSrcweir
27cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
28cdf0e10cSrcweir #include <ary/qualiname.hxx>
29cdf0e10cSrcweir #include <ary/cpp/inpcontx.hxx>
30cdf0e10cSrcweir #include <ary/cpp/c_namesp.hxx>
31cdf0e10cSrcweir #include <ary/cpp/c_class.hxx>
32cdf0e10cSrcweir #include <ary/cpp/c_enum.hxx>
33cdf0e10cSrcweir #include <ary/cpp/c_enuval.hxx>
34cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx>
35cdf0e10cSrcweir #include <ary/cpp/c_tydef.hxx>
36cdf0e10cSrcweir #include <ary/cpp/c_type.hxx>
37cdf0e10cSrcweir #include <ary/cpp/c_vari.hxx>
38cdf0e10cSrcweir #include <ary/cpp/cp_type.hxx>
39cdf0e10cSrcweir #include <ary/loc/loc_file.hxx>
40cdf0e10cSrcweir #include <ary/getncast.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir
46cdf0e10cSrcweir
47cdf0e10cSrcweir namespace
48cdf0e10cSrcweir {
49cdf0e10cSrcweir
50cdf0e10cSrcweir String Get_NewAnonymousNamespaceName();
51cdf0e10cSrcweir String Get_NewAnonymousName(
52cdf0e10cSrcweir char i_start );
53cdf0e10cSrcweir
54cdf0e10cSrcweir
55cdf0e10cSrcweir } // anonymous namespace
56cdf0e10cSrcweir
57cdf0e10cSrcweir
58cdf0e10cSrcweir
59cdf0e10cSrcweir
60cdf0e10cSrcweir namespace ary
61cdf0e10cSrcweir {
62cdf0e10cSrcweir namespace cpp
63cdf0e10cSrcweir {
64cdf0e10cSrcweir
65cdf0e10cSrcweir
66cdf0e10cSrcweir // KORR_FUTURE
67cdf0e10cSrcweir // What about namespace visibility ?
68cdf0e10cSrcweir // Perhaps handle all/some visibility transfer only after parse is complete.
69cdf0e10cSrcweir void
transfer_visibility(const Class * i_owner,CodeEntity & o_child)70cdf0e10cSrcweir transfer_visibility( const Class * i_owner,
71cdf0e10cSrcweir CodeEntity & o_child )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir if ( i_owner != 0 ? NOT i_owner->IsVisible() : false )
74cdf0e10cSrcweir o_child.Set_InVisible();
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir inline const TypePilot &
Types() const78cdf0e10cSrcweir CeAdmin::Types() const
79cdf0e10cSrcweir {
80cdf0e10cSrcweir csv_assert(pTypes != 0);
81cdf0e10cSrcweir return *pTypes;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir
85cdf0e10cSrcweir
86cdf0e10cSrcweir
87cdf0e10cSrcweir
88cdf0e10cSrcweir
CeAdmin(RepositoryPartition & io_myReposyPartition)89cdf0e10cSrcweir CeAdmin::CeAdmin(RepositoryPartition & io_myReposyPartition)
90cdf0e10cSrcweir : aStorage(),
91cdf0e10cSrcweir pTypes(0),
92cdf0e10cSrcweir pCppRepositoryPartition(&io_myReposyPartition)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir void
Set_Related(const TypePilot & i_types)97cdf0e10cSrcweir CeAdmin::Set_Related(const TypePilot & i_types)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir pTypes = &i_types;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
~CeAdmin()102cdf0e10cSrcweir CeAdmin::~CeAdmin()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir Namespace &
CheckIn_Namespace(const InputContext & i_context,const String & i_localName)107cdf0e10cSrcweir CeAdmin::CheckIn_Namespace( const InputContext & i_context,
108cdf0e10cSrcweir const String & i_localName )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir const String
111cdf0e10cSrcweir local_name = NOT i_localName.empty()
112cdf0e10cSrcweir ? i_localName
113cdf0e10cSrcweir : Get_NewAnonymousNamespaceName();
114cdf0e10cSrcweir Namespace &
115cdf0e10cSrcweir rParent = i_context.CurNamespace();
116cdf0e10cSrcweir Namespace *
117cdf0e10cSrcweir ret = rParent.Search_LocalNamespace(local_name);
118cdf0e10cSrcweir if ( ret == 0 )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir ret = &Create_Namespace(rParent, local_name);
121cdf0e10cSrcweir }
122cdf0e10cSrcweir return *ret;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir Class &
Store_Class(const InputContext & i_context,const String & i_localName,E_ClassKey i_eClassKey)126cdf0e10cSrcweir CeAdmin::Store_Class( const InputContext & i_context,
127cdf0e10cSrcweir const String & i_localName,
128cdf0e10cSrcweir E_ClassKey i_eClassKey )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir const String
131cdf0e10cSrcweir local_name = i_localName.empty()
132cdf0e10cSrcweir ? Get_NewAnonymousName( i_eClassKey == CK_class
133cdf0e10cSrcweir ? 'c'
134cdf0e10cSrcweir : i_eClassKey == CK_struct
135cdf0e10cSrcweir ? 's'
136cdf0e10cSrcweir : 'u' )
137cdf0e10cSrcweir : i_localName;
138cdf0e10cSrcweir
139cdf0e10cSrcweir Class &
140cdf0e10cSrcweir ret = * new Class( local_name,
141cdf0e10cSrcweir i_context.CurOwner().CeId(),
142cdf0e10cSrcweir i_context.CurProtection(),
143cdf0e10cSrcweir i_context.CurFile().LeId(),
144cdf0e10cSrcweir i_eClassKey );
145cdf0e10cSrcweir aStorage.Store_Type(ret);
146cdf0e10cSrcweir i_context.CurOwner().Add_Class(local_name, ret.CeId());
147cdf0e10cSrcweir transfer_visibility(i_context.CurClass(), ret);
148cdf0e10cSrcweir
149cdf0e10cSrcweir return ret;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir Enum &
Store_Enum(const InputContext & i_context,const String & i_localName)153cdf0e10cSrcweir CeAdmin::Store_Enum( const InputContext & i_context,
154cdf0e10cSrcweir const String & i_localName )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir const String
157cdf0e10cSrcweir local_name = i_localName.empty()
158cdf0e10cSrcweir ? Get_NewAnonymousName('e')
159cdf0e10cSrcweir : i_localName;
160cdf0e10cSrcweir Enum &
161cdf0e10cSrcweir ret = * new Enum( local_name,
162cdf0e10cSrcweir i_context.CurOwner().CeId(),
163cdf0e10cSrcweir i_context.CurProtection(),
164cdf0e10cSrcweir i_context.CurFile().LeId() );
165cdf0e10cSrcweir aStorage.Store_Type(ret);
166cdf0e10cSrcweir i_context.CurOwner().Add_Enum(local_name, ret.CeId());
167cdf0e10cSrcweir transfer_visibility(i_context.CurClass(), ret);
168cdf0e10cSrcweir
169cdf0e10cSrcweir return ret;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir Typedef &
Store_Typedef(const InputContext & i_context,const String & i_localName,Type_id i_referredType)173cdf0e10cSrcweir CeAdmin::Store_Typedef( const InputContext& i_context,
174cdf0e10cSrcweir const String & i_localName,
175cdf0e10cSrcweir Type_id i_referredType )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir Typedef &
178cdf0e10cSrcweir ret = * new Typedef( i_localName,
179cdf0e10cSrcweir i_context.CurOwner().CeId(),
180cdf0e10cSrcweir i_context.CurProtection(),
181cdf0e10cSrcweir i_context.CurFile().LeId(),
182cdf0e10cSrcweir i_referredType );
183cdf0e10cSrcweir aStorage.Store_Type(ret);
184cdf0e10cSrcweir i_context.CurOwner().Add_Typedef(i_localName, ret.CeId());
185cdf0e10cSrcweir transfer_visibility(i_context.CurClass(), ret);
186cdf0e10cSrcweir
187cdf0e10cSrcweir return ret;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
190cdf0e10cSrcweir Function *
Store_Operation(const InputContext & i_context,const String & i_localName,Type_id i_returnType,const std::vector<S_Parameter> & i_parameters,E_Virtuality i_virtuality,E_ConVol i_conVol,FunctionFlags i_flags,bool i_throwExists,const std::vector<Type_id> & i_exceptions)191cdf0e10cSrcweir CeAdmin::Store_Operation( const InputContext & i_context,
192cdf0e10cSrcweir const String & i_localName,
193cdf0e10cSrcweir Type_id i_returnType,
194cdf0e10cSrcweir const std::vector<S_Parameter> & i_parameters,
195cdf0e10cSrcweir E_Virtuality i_virtuality,
196cdf0e10cSrcweir E_ConVol i_conVol,
197cdf0e10cSrcweir FunctionFlags i_flags,
198cdf0e10cSrcweir bool i_throwExists,
199cdf0e10cSrcweir const std::vector<Type_id> & i_exceptions )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir Function &
202cdf0e10cSrcweir ret = * new Function( i_localName,
203cdf0e10cSrcweir i_context.CurOwner().CeId(),
204cdf0e10cSrcweir i_context.CurProtection(),
205cdf0e10cSrcweir i_context.CurFile().LeId(),
206cdf0e10cSrcweir i_returnType,
207cdf0e10cSrcweir i_parameters,
208cdf0e10cSrcweir i_conVol,
209cdf0e10cSrcweir i_virtuality,
210cdf0e10cSrcweir i_flags,
211cdf0e10cSrcweir i_throwExists,
212cdf0e10cSrcweir i_exceptions );
213cdf0e10cSrcweir
214cdf0e10cSrcweir // Check for double declaration:
215cdf0e10cSrcweir Ce_id
216cdf0e10cSrcweir nAlreadyExistingFunction(0);
217cdf0e10cSrcweir switch ( lhf_CheckAndHandle_DuplicateOperation(
218cdf0e10cSrcweir nAlreadyExistingFunction,
219cdf0e10cSrcweir i_context,
220cdf0e10cSrcweir ret) )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir case df_discard_new:
223cdf0e10cSrcweir delete &ret;
224cdf0e10cSrcweir return 0;
225cdf0e10cSrcweir case df_replace:
226cdf0e10cSrcweir csv_assert(nAlreadyExistingFunction.IsValid());
227cdf0e10cSrcweir aStorage.Replace_Entity(
228cdf0e10cSrcweir nAlreadyExistingFunction,
229cdf0e10cSrcweir ret );
230cdf0e10cSrcweir break;
231cdf0e10cSrcweir case df_no:
232cdf0e10cSrcweir aStorage.Store_Operation(ret); // Now it has a valid id.
233cdf0e10cSrcweir i_context.CurOwner().Add_Operation( i_localName, ret.CeId(), i_flags.IsStaticMember() );
234cdf0e10cSrcweir break;
235cdf0e10cSrcweir default:
236cdf0e10cSrcweir csv_assert(false);
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir transfer_visibility(i_context.CurClass(), ret);
240cdf0e10cSrcweir if ( i_context.CurProtection() != PROTECT_global )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir Class *
243cdf0e10cSrcweir pClass = i_context.CurClass();
244cdf0e10cSrcweir if ( pClass != 0 AND i_virtuality != VIRTUAL_none)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir pClass->UpdateVirtuality(i_virtuality);
247cdf0e10cSrcweir }
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir return &ret;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir Variable &
Store_Variable(const InputContext & i_context,const String & i_localName,Type_id i_type,VariableFlags i_flags,const String & i_arraySize,const String & i_initValue)254cdf0e10cSrcweir CeAdmin::Store_Variable( const InputContext& i_context,
255cdf0e10cSrcweir const String & i_localName,
256cdf0e10cSrcweir Type_id i_type,
257cdf0e10cSrcweir VariableFlags i_flags,
258cdf0e10cSrcweir const String & i_arraySize,
259cdf0e10cSrcweir const String & i_initValue )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir Variable &
262cdf0e10cSrcweir ret = * new Variable( i_localName,
263cdf0e10cSrcweir i_context.CurOwner().CeId(),
264cdf0e10cSrcweir i_context.CurProtection(),
265cdf0e10cSrcweir i_context.CurFile().LeId(),
266cdf0e10cSrcweir i_type,
267cdf0e10cSrcweir i_flags,
268cdf0e10cSrcweir i_arraySize,
269cdf0e10cSrcweir i_initValue );
270cdf0e10cSrcweir
271cdf0e10cSrcweir bool
272cdf0e10cSrcweir is_const = Types().Find_Type(i_type).IsConst();
273cdf0e10cSrcweir aStorage.Store_Datum(ret);
274cdf0e10cSrcweir i_context.CurOwner().Add_Variable(
275cdf0e10cSrcweir i_localName,
276cdf0e10cSrcweir ret.CeId(),
277cdf0e10cSrcweir is_const,
278cdf0e10cSrcweir i_flags.IsStaticMember() );
279cdf0e10cSrcweir transfer_visibility(i_context.CurClass(), ret);
280cdf0e10cSrcweir
281cdf0e10cSrcweir return ret;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir EnumValue &
Store_EnumValue(const InputContext & i_context,const String & i_localName,const String & i_initValue)285cdf0e10cSrcweir CeAdmin::Store_EnumValue( const InputContext & i_context,
286cdf0e10cSrcweir const String & i_localName,
287cdf0e10cSrcweir const String & i_initValue )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir Enum *
290cdf0e10cSrcweir parent = i_context.CurEnum();
291cdf0e10cSrcweir csv_assert( parent != 0 );
292cdf0e10cSrcweir
293cdf0e10cSrcweir EnumValue &
294cdf0e10cSrcweir ret = * new EnumValue( i_localName,
295cdf0e10cSrcweir parent->CeId(),
296cdf0e10cSrcweir i_initValue );
297cdf0e10cSrcweir aStorage.Store_Datum(ret);
298cdf0e10cSrcweir parent->Add_Value(ret.CeId());
299cdf0e10cSrcweir
300cdf0e10cSrcweir // KORR also for current enum:
301cdf0e10cSrcweir transfer_visibility(i_context.CurClass(), ret);
302cdf0e10cSrcweir
303cdf0e10cSrcweir return ret;
304cdf0e10cSrcweir }
305cdf0e10cSrcweir
306cdf0e10cSrcweir const Namespace &
GlobalNamespace() const307cdf0e10cSrcweir CeAdmin::GlobalNamespace() const
308cdf0e10cSrcweir {
309cdf0e10cSrcweir return ary_cast<Namespace>( aStorage[predefined::ce_GlobalNamespace] );
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir const CodeEntity &
Find_Ce(Ce_id i_id) const313cdf0e10cSrcweir CeAdmin::Find_Ce(Ce_id i_id) const
314cdf0e10cSrcweir {
315cdf0e10cSrcweir return aStorage[i_id];
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir const CodeEntity *
Search_Ce(Ce_id i_id) const319cdf0e10cSrcweir CeAdmin::Search_Ce(Ce_id i_id) const
320cdf0e10cSrcweir {
321cdf0e10cSrcweir return aStorage.Exists(i_id)
322cdf0e10cSrcweir ? & aStorage[i_id]
323cdf0e10cSrcweir : (const CodeEntity*)(0);
324cdf0e10cSrcweir }
325cdf0e10cSrcweir
326cdf0e10cSrcweir const CodeEntity *
Search_CeAbsolute(const CodeEntity & i_curScope,const QualifiedName & i_rSearchedName) const327cdf0e10cSrcweir CeAdmin::Search_CeAbsolute( const CodeEntity & i_curScope,
328cdf0e10cSrcweir const QualifiedName & i_rSearchedName ) const
329cdf0e10cSrcweir {
330cdf0e10cSrcweir const symtree::Node<CeNode_Traits> *
331cdf0e10cSrcweir cur_node = CeNode_Traits::NodeOf_(i_curScope);
332cdf0e10cSrcweir csv_assert(cur_node != 0);
333cdf0e10cSrcweir
334cdf0e10cSrcweir Ce_id
335cdf0e10cSrcweir ret(0);
336cdf0e10cSrcweir cur_node->SearchUp( ret,
337cdf0e10cSrcweir i_rSearchedName.first_namespace(),
338cdf0e10cSrcweir i_rSearchedName.end_namespace(),
339cdf0e10cSrcweir i_rSearchedName.LocalName() );
340cdf0e10cSrcweir return Search_Ce(ret);
341cdf0e10cSrcweir }
342cdf0e10cSrcweir
343cdf0e10cSrcweir const CodeEntity *
Search_CeLocal(const String & i_localName,bool i_bIsFunction,const Namespace & i_rCurNamespace,const Class * i_pCurClass) const344cdf0e10cSrcweir CeAdmin::Search_CeLocal( const String & i_localName,
345cdf0e10cSrcweir bool i_bIsFunction,
346cdf0e10cSrcweir const Namespace & i_rCurNamespace,
347cdf0e10cSrcweir const Class * i_pCurClass ) const
348cdf0e10cSrcweir {
349cdf0e10cSrcweir // KORR_FUTURE
350cdf0e10cSrcweir // See if this is correct.
351cdf0e10cSrcweir
352cdf0e10cSrcweir Ce_id
353cdf0e10cSrcweir ret(0);
354cdf0e10cSrcweir
355cdf0e10cSrcweir if ( NOT i_bIsFunction )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir CesResultList
358cdf0e10cSrcweir type_instances = aStorage.TypeIndex().SearchAll(i_localName);
359cdf0e10cSrcweir CesResultList
360cdf0e10cSrcweir data_instances = aStorage.DataIndex().SearchAll(i_localName);
361cdf0e10cSrcweir Ce_id
362cdf0e10cSrcweir ret1 = Search_MatchingInstance(
363cdf0e10cSrcweir type_instances,
364cdf0e10cSrcweir (i_pCurClass
365cdf0e10cSrcweir ? i_pCurClass->CeId()
366cdf0e10cSrcweir : i_rCurNamespace.CeId())
367cdf0e10cSrcweir );
368cdf0e10cSrcweir Ce_id
369cdf0e10cSrcweir ret2 = Search_MatchingInstance(
370cdf0e10cSrcweir data_instances,
371cdf0e10cSrcweir (i_pCurClass
372cdf0e10cSrcweir ? i_pCurClass->CeId()
373cdf0e10cSrcweir : i_rCurNamespace.CeId())
374cdf0e10cSrcweir );
375cdf0e10cSrcweir if (NOT ret2.IsValid())
376cdf0e10cSrcweir ret = ret1;
377cdf0e10cSrcweir else if (NOT ret1.IsValid())
378cdf0e10cSrcweir ret = ret2;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir else
381cdf0e10cSrcweir {
382cdf0e10cSrcweir CesResultList
383cdf0e10cSrcweir function_instances = aStorage.OperationIndex().SearchAll(i_localName);
384cdf0e10cSrcweir if ( function_instances.size() == 1 )
385cdf0e10cSrcweir ret = *function_instances.begin();
386cdf0e10cSrcweir else
387cdf0e10cSrcweir {
388cdf0e10cSrcweir ret = Search_MatchingInstance(
389cdf0e10cSrcweir function_instances,
390cdf0e10cSrcweir (i_pCurClass
391cdf0e10cSrcweir ? i_pCurClass->CeId()
392cdf0e10cSrcweir : i_rCurNamespace.CeId())
393cdf0e10cSrcweir );
394cdf0e10cSrcweir }
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir if ( ret.IsValid() )
398cdf0e10cSrcweir return & Find_Ce(ret);
399cdf0e10cSrcweir
400cdf0e10cSrcweir return 0;
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
403cdf0e10cSrcweir void
Get_QualifiedName(StreamStr & o_rOut,const String & i_localName,Ce_id i_nOwner,const char * i_sDelimiter) const404cdf0e10cSrcweir CeAdmin::Get_QualifiedName( StreamStr & o_rOut,
405cdf0e10cSrcweir const String & i_localName,
406cdf0e10cSrcweir Ce_id i_nOwner,
407cdf0e10cSrcweir const char * i_sDelimiter ) const
408cdf0e10cSrcweir {
409cdf0e10cSrcweir if ( i_localName.empty() OR NOT i_nOwner.IsValid() )
410cdf0e10cSrcweir return;
411cdf0e10cSrcweir
412cdf0e10cSrcweir const CodeEntity *
413cdf0e10cSrcweir pOwner = & Find_Ce( i_nOwner );
414cdf0e10cSrcweir if ( is_type<Enum>(*pOwner) )
415cdf0e10cSrcweir pOwner = &Find_Ce( Ce_id(pOwner->Owner()) );
416cdf0e10cSrcweir
417cdf0e10cSrcweir Get_QualifiedName( o_rOut,
418cdf0e10cSrcweir pOwner->LocalName(),
419cdf0e10cSrcweir Ce_id(pOwner->Owner()),
420cdf0e10cSrcweir i_sDelimiter );
421cdf0e10cSrcweir o_rOut
422cdf0e10cSrcweir << i_sDelimiter
423cdf0e10cSrcweir << i_localName;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir
426cdf0e10cSrcweir void
Get_SignatureText(StreamStr & o_rOut,const OperationSignature & i_signature,const StringVector * i_sParameterNames) const427cdf0e10cSrcweir CeAdmin::Get_SignatureText( StreamStr & o_rOut,
428cdf0e10cSrcweir const OperationSignature & i_signature,
429cdf0e10cSrcweir const StringVector * i_sParameterNames ) const
430cdf0e10cSrcweir {
431cdf0e10cSrcweir OperationSignature::ParameterTypeList::const_iterator
432cdf0e10cSrcweir it = i_signature.Parameters().begin();
433cdf0e10cSrcweir OperationSignature::ParameterTypeList::const_iterator
434cdf0e10cSrcweir it_end = i_signature.Parameters().end();
435cdf0e10cSrcweir
436cdf0e10cSrcweir const StringVector aDummy;
437cdf0e10cSrcweir StringVector::const_iterator
438cdf0e10cSrcweir itName = i_sParameterNames != 0
439cdf0e10cSrcweir ? i_sParameterNames->begin()
440cdf0e10cSrcweir : aDummy.begin();
441cdf0e10cSrcweir StringVector::const_iterator
442cdf0e10cSrcweir itName_end = i_sParameterNames != 0
443cdf0e10cSrcweir ? i_sParameterNames->end()
444cdf0e10cSrcweir : aDummy.end();
445cdf0e10cSrcweir
446cdf0e10cSrcweir bool
447cdf0e10cSrcweir bEmpty = (it == it_end);
448cdf0e10cSrcweir if (NOT bEmpty)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir o_rOut << "( ";
451cdf0e10cSrcweir Types().Get_TypeText(o_rOut, *it);
452cdf0e10cSrcweir if (itName != itName_end)
453cdf0e10cSrcweir o_rOut << " " << (*itName);
454cdf0e10cSrcweir
455cdf0e10cSrcweir for ( ++it; it != it_end; ++it )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir o_rOut << ", ";
458cdf0e10cSrcweir Types().Get_TypeText(o_rOut, *it);
459cdf0e10cSrcweir if (itName != itName_end)
460cdf0e10cSrcweir {
461cdf0e10cSrcweir ++itName;
462cdf0e10cSrcweir if (itName != itName_end)
463cdf0e10cSrcweir o_rOut << " " << (*itName);
464cdf0e10cSrcweir }
465cdf0e10cSrcweir }
466cdf0e10cSrcweir o_rOut << " )";
467cdf0e10cSrcweir }
468cdf0e10cSrcweir else
469cdf0e10cSrcweir {
470cdf0e10cSrcweir o_rOut << "( )";
471cdf0e10cSrcweir }
472cdf0e10cSrcweir
473cdf0e10cSrcweir if ( intt(i_signature.ConVol()) & intt(ary::cpp::CONVOL_const) )
474cdf0e10cSrcweir o_rOut << " const";
475cdf0e10cSrcweir if ( intt(i_signature.ConVol()) & intt(ary::cpp::CONVOL_volatile) )
476cdf0e10cSrcweir o_rOut << " volatile";
477cdf0e10cSrcweir }
478cdf0e10cSrcweir
479cdf0e10cSrcweir CesResultList
Search_TypeName(const String & i_sName) const480cdf0e10cSrcweir CeAdmin::Search_TypeName(const String & i_sName) const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir return aStorage.TypeIndex().SearchAll(i_sName);
483cdf0e10cSrcweir }
484cdf0e10cSrcweir
485cdf0e10cSrcweir Namespace &
GlobalNamespace()486cdf0e10cSrcweir CeAdmin::GlobalNamespace()
487cdf0e10cSrcweir {
488cdf0e10cSrcweir return ary_cast<Namespace>( aStorage[predefined::ce_GlobalNamespace] );
489cdf0e10cSrcweir }
490cdf0e10cSrcweir
491cdf0e10cSrcweir CeAdmin::E_DuplicateFunction
lhf_CheckAndHandle_DuplicateOperation(Ce_id & o_existentFunction,const InputContext & i_context,const Function & i_newFunction)492cdf0e10cSrcweir CeAdmin::lhf_CheckAndHandle_DuplicateOperation(
493cdf0e10cSrcweir Ce_id & o_existentFunction,
494cdf0e10cSrcweir const InputContext & i_context,
495cdf0e10cSrcweir const Function & i_newFunction )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir if (i_context.CurProtection() != PROTECT_global)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir // Assume, there will be no duplicates within the same class.
500cdf0e10cSrcweir
501cdf0e10cSrcweir // KORR_FUTURE
502cdf0e10cSrcweir // Assumption may be wrong in case of #defines providing different
503cdf0e10cSrcweir // versions for different compilers.
504cdf0e10cSrcweir return df_no;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir
507cdf0e10cSrcweir std::vector<Ce_id>
508cdf0e10cSrcweir aOperationsWithSameName;
509cdf0e10cSrcweir i_context.CurNamespace().Search_LocalOperations(
510cdf0e10cSrcweir aOperationsWithSameName,
511cdf0e10cSrcweir i_newFunction.LocalName() );
512cdf0e10cSrcweir
513cdf0e10cSrcweir for ( std::vector<Ce_id>::const_iterator
514cdf0e10cSrcweir it = aOperationsWithSameName.begin();
515cdf0e10cSrcweir it != aOperationsWithSameName.end();
516cdf0e10cSrcweir ++it )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir const Function &
519cdf0e10cSrcweir rFunction = ary_cast<Function>(aStorage[*it]);
520cdf0e10cSrcweir if ( rFunction.LocalName() == i_newFunction.LocalName()
521cdf0e10cSrcweir AND rFunction.Signature() == i_newFunction.Signature() )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir if (NOT rFunction.IsIdentical(i_newFunction))
524cdf0e10cSrcweir {
525cdf0e10cSrcweir // KORR_FUTURE Make this more detailed.
526cdf0e10cSrcweir Cerr() << "Non identical function with same signature "
527cdf0e10cSrcweir << "found: "
528cdf0e10cSrcweir << i_context.CurNamespace().LocalName()
529cdf0e10cSrcweir << "::"
530cdf0e10cSrcweir << i_newFunction.LocalName()
531cdf0e10cSrcweir << "(..)"
532cdf0e10cSrcweir << Endl();
533cdf0e10cSrcweir }
534cdf0e10cSrcweir o_existentFunction = rFunction.CeId();
535cdf0e10cSrcweir if (rFunction.Docu().Data() == 0)
536cdf0e10cSrcweir return df_replace;
537cdf0e10cSrcweir else
538cdf0e10cSrcweir return df_discard_new;
539cdf0e10cSrcweir }
540cdf0e10cSrcweir } // end for
541cdf0e10cSrcweir
542cdf0e10cSrcweir return df_no;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir
545cdf0e10cSrcweir Namespace &
Create_Namespace(Namespace & o_parent,const String & i_localName)546cdf0e10cSrcweir CeAdmin::Create_Namespace( Namespace & o_parent,
547cdf0e10cSrcweir const String & i_localName )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir DYN Namespace &
550cdf0e10cSrcweir ret = *new Namespace(i_localName, o_parent);
551cdf0e10cSrcweir aStorage.Store_Entity(ret);
552cdf0e10cSrcweir o_parent.Add_LocalNamespace(ret);
553cdf0e10cSrcweir return ret;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
556cdf0e10cSrcweir Ce_id
Search_MatchingInstance(CesResultList i_list,Ce_id i_owner) const557cdf0e10cSrcweir CeAdmin::Search_MatchingInstance( CesResultList i_list,
558cdf0e10cSrcweir Ce_id i_owner ) const
559cdf0e10cSrcweir {
560cdf0e10cSrcweir // KORR
561cdf0e10cSrcweir // Multiple results?
562cdf0e10cSrcweir
563cdf0e10cSrcweir for ( CesList::const_iterator it = i_list.begin();
564cdf0e10cSrcweir it != i_list.end();
565cdf0e10cSrcweir ++it )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir const CodeEntity &
568cdf0e10cSrcweir ce = aStorage[*it];
569cdf0e10cSrcweir if ( ce.Owner() == i_owner)
570cdf0e10cSrcweir {
571cdf0e10cSrcweir return *it;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir }
574cdf0e10cSrcweir return Ce_id(0);
575cdf0e10cSrcweir }
576cdf0e10cSrcweir
577cdf0e10cSrcweir
578cdf0e10cSrcweir
579cdf0e10cSrcweir } // namespace cpp
580cdf0e10cSrcweir } // namespace ary
581cdf0e10cSrcweir
582cdf0e10cSrcweir
583cdf0e10cSrcweir
584cdf0e10cSrcweir namespace
585cdf0e10cSrcweir {
586cdf0e10cSrcweir
587cdf0e10cSrcweir uintt G_nLastFreeAnonymousNamespaceNr = 0;
588cdf0e10cSrcweir uintt G_nLastFreeAnonymousEntityNr = 0;
589cdf0e10cSrcweir
590cdf0e10cSrcweir String
Get_NewAnonymousNamespaceName()591cdf0e10cSrcweir Get_NewAnonymousNamespaceName()
592cdf0e10cSrcweir {
593cdf0e10cSrcweir StreamLock
594cdf0e10cSrcweir sl(100);
595cdf0e10cSrcweir return String( sl()
596cdf0e10cSrcweir << "namespace_anonymous_"
597cdf0e10cSrcweir << ++G_nLastFreeAnonymousNamespaceNr
598cdf0e10cSrcweir << csv::c_str );
599cdf0e10cSrcweir
600cdf0e10cSrcweir }
601cdf0e10cSrcweir
602cdf0e10cSrcweir String
Get_NewAnonymousName(char i_cStart)603cdf0e10cSrcweir Get_NewAnonymousName(char i_cStart)
604cdf0e10cSrcweir {
605cdf0e10cSrcweir StreamLock
606cdf0e10cSrcweir sl(100);
607cdf0e10cSrcweir return String( sl()
608cdf0e10cSrcweir << i_cStart
609cdf0e10cSrcweir << "_Anonymous__"
610cdf0e10cSrcweir << ++G_nLastFreeAnonymousEntityNr
611cdf0e10cSrcweir << c_str );
612cdf0e10cSrcweir }
613cdf0e10cSrcweir
614cdf0e10cSrcweir
615cdf0e10cSrcweir
616cdf0e10cSrcweir } // namespace anonymous
617