1*78bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*78bc99aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*78bc99aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*78bc99aaSAndrew Rist  * distributed with this work for additional information
6*78bc99aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*78bc99aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*78bc99aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*78bc99aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*78bc99aaSAndrew Rist  *
11*78bc99aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*78bc99aaSAndrew Rist  *
13*78bc99aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*78bc99aaSAndrew Rist  * software distributed under the License is distributed on an
15*78bc99aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*78bc99aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*78bc99aaSAndrew Rist  * specific language governing permissions and limitations
18*78bc99aaSAndrew Rist  * under the License.
19*78bc99aaSAndrew Rist  *
20*78bc99aaSAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include "cxt2ary.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <ary/entity.hxx>
28cdf0e10cSrcweir #include <ary/cpp/c_class.hxx>
29cdf0e10cSrcweir #include <ary/cpp/c_define.hxx>
30cdf0e10cSrcweir #include <ary/cpp/c_enum.hxx>
31cdf0e10cSrcweir #include <ary/cpp/c_enuval.hxx>
32cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx>
33cdf0e10cSrcweir #include <ary/cpp/c_macro.hxx>
34cdf0e10cSrcweir #include <ary/cpp/c_tydef.hxx>
35cdf0e10cSrcweir #include <ary/cpp/c_vari.hxx>
36cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx>
37cdf0e10cSrcweir #include <ary/cpp/cp_ce.hxx>
38cdf0e10cSrcweir #include <ary/loc/loc_file.hxx>
39cdf0e10cSrcweir #include <ary/doc/d_oldcppdocu.hxx>
40cdf0e10cSrcweir #include <ary/info/docstore.hxx>
41cdf0e10cSrcweir #include "icprivow.hxx"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // Implementationheaders, only to be used in this file!
44cdf0e10cSrcweir #include "sfscope.hxx"
45cdf0e10cSrcweir #include "sownstck.hxx"
46cdf0e10cSrcweir #include "sdocdist.hxx"
47cdf0e10cSrcweir #include "srecover.hxx"
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace cpp
54cdf0e10cSrcweir {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir using ary::cpp::E_Protection;
57cdf0e10cSrcweir 
ContextForAry(ary::cpp::Gate & io_rAryGate)58cdf0e10cSrcweir ContextForAry::ContextForAry( ary::cpp::Gate &  io_rAryGate )
59cdf0e10cSrcweir     :   pGate(&io_rAryGate),
60cdf0e10cSrcweir         aTokenResult(),
61cdf0e10cSrcweir         pFileScopeInfo( new S_FileScopeInfo ),
62cdf0e10cSrcweir         pOwnerStack( new S_OwnerStack ),
63cdf0e10cSrcweir         pDocuDistributor( new S_DocuDistributor ),
64cdf0e10cSrcweir         pRecoveryGuard( new S_RecoveryGuard )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     OpenNamespace( pGate->Ces().GlobalNamespace() );
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
~ContextForAry()69cdf0e10cSrcweir ContextForAry::~ContextForAry()
70cdf0e10cSrcweir {
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir ary::loc::File &
inq_CurFile() const74cdf0e10cSrcweir ContextForAry::inq_CurFile() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     csv_assert(pFileScopeInfo->pCurFile != 0);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     return *pFileScopeInfo->pCurFile;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir ary::cpp::Namespace &
inq_CurNamespace() const82cdf0e10cSrcweir ContextForAry::inq_CurNamespace() const
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     return pOwnerStack->CurNamespace();
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir ary::cpp::Class *
inq_CurClass() const88cdf0e10cSrcweir ContextForAry::inq_CurClass() const
89cdf0e10cSrcweir {
90cdf0e10cSrcweir     return pOwnerStack->CurClass();
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir ary::cpp::Enum *
inq_CurEnum() const94cdf0e10cSrcweir ContextForAry::inq_CurEnum() const
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     return pOwnerStack->CurEnum();
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir ary::cpp::InputContext::Owner &
inq_CurOwner() const101cdf0e10cSrcweir ContextForAry::inq_CurOwner() const
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     return pOwnerStack->CurOwner();
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir E_Protection
inq_CurProtection() const107cdf0e10cSrcweir ContextForAry::inq_CurProtection() const
108cdf0e10cSrcweir {
109cdf0e10cSrcweir     return pOwnerStack->CurProtection();
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir void
do_SetTokenResult(E_TokenDone i_eDone,E_EnvStackAction i_eWhat2DoWithEnvStack,ParseEnvironment * i_pParseEnv2Push)113cdf0e10cSrcweir ContextForAry::do_SetTokenResult( E_TokenDone			i_eDone,
114cdf0e10cSrcweir 							      E_EnvStackAction	    i_eWhat2DoWithEnvStack,
115cdf0e10cSrcweir 							      ParseEnvironment *	i_pParseEnv2Push )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir     aTokenResult.eDone = i_eDone;
118cdf0e10cSrcweir     aTokenResult.eStackAction = i_eWhat2DoWithEnvStack;
119cdf0e10cSrcweir     aTokenResult.pEnv2Push = i_pParseEnv2Push;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir void
do_OpenNamespace(ary::cpp::Namespace & io_rOpenedNamespace)123cdf0e10cSrcweir ContextForAry::do_OpenNamespace( ary::cpp::Namespace & io_rOpenedNamespace )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     pOwnerStack->OpenNamespace( io_rOpenedNamespace );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir void
do_OpenExternC(bool)129cdf0e10cSrcweir ContextForAry::do_OpenExternC( bool )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	pOwnerStack->OpenExternC();
132cdf0e10cSrcweir 	// KORR_FUTURE
133cdf0e10cSrcweir 	// use i_bOnlyForOneDeclaration
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir void
do_OpenClass(ary::cpp::Class & io_rOpenedClass)137cdf0e10cSrcweir ContextForAry::do_OpenClass( ary::cpp::Class & io_rOpenedClass )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     pOwnerStack->OpenClass(io_rOpenedClass);
140cdf0e10cSrcweir     pDocuDistributor->SetCurrentlyStoredRe(io_rOpenedClass);
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir void
do_OpenEnum(ary::cpp::Enum & io_rOpenedEnum)144cdf0e10cSrcweir ContextForAry::do_OpenEnum(	ary::cpp::Enum & io_rOpenedEnum )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     pOwnerStack->OpenEnum(io_rOpenedEnum);
147cdf0e10cSrcweir     pDocuDistributor->SetCurrentlyStoredRe(io_rOpenedEnum);
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir void
do_CloseBlock()151cdf0e10cSrcweir ContextForAry::do_CloseBlock()
152cdf0e10cSrcweir {
153cdf0e10cSrcweir     pOwnerStack->CloseBlock();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir void
do_CloseClass()157cdf0e10cSrcweir ContextForAry::do_CloseClass()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     pOwnerStack->CloseClass();
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir void
do_CloseEnum()163cdf0e10cSrcweir ContextForAry::do_CloseEnum()
164cdf0e10cSrcweir {
165cdf0e10cSrcweir     pOwnerStack->CloseEnum();
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir void
do_SetCurProtection(ary::cpp::E_Protection i_eProtection)169cdf0e10cSrcweir ContextForAry::do_SetCurProtection( ary::cpp::E_Protection i_eProtection )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     pOwnerStack->SetCurProtection(i_eProtection);
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir void
do_OpenTemplate(const StringVector & i_rParameters)175cdf0e10cSrcweir ContextForAry::do_OpenTemplate( const StringVector & i_rParameters )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     pFileScopeInfo->pCurTemplateParameters = new StringVector(i_rParameters);
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir DYN StringVector *
do_Get_CurTemplateParameters()181cdf0e10cSrcweir ContextForAry::do_Get_CurTemplateParameters()
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     return pFileScopeInfo->pCurTemplateParameters.Release();
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir void
do_Close_OpenTemplate()187cdf0e10cSrcweir ContextForAry::do_Close_OpenTemplate()
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     if (pFileScopeInfo->pCurTemplateParameters)
190cdf0e10cSrcweir         delete pFileScopeInfo->pCurTemplateParameters.Release();
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir void
do_Event_Class_FinishedBase(const String &)194cdf0e10cSrcweir ContextForAry::do_Event_Class_FinishedBase( const String & )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     // KORR_FUTURE
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir void
do_Event_Store_Typedef(ary::cpp::Typedef & io_rTypedef)200cdf0e10cSrcweir ContextForAry::do_Event_Store_Typedef( ary::cpp::Typedef & io_rTypedef )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     pDocuDistributor->SetCurrentlyStoredRe(io_rTypedef);
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir void
do_Event_Store_EnumValue(ary::cpp::EnumValue & io_rEnumValue)206cdf0e10cSrcweir ContextForAry::do_Event_Store_EnumValue( ary::cpp::EnumValue & io_rEnumValue )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir     pDocuDistributor->SetCurrentlyStoredRe(io_rEnumValue);
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir void
do_Event_Store_CppDefinition(ary::cpp::DefineEntity & io_rDefinition)212cdf0e10cSrcweir ContextForAry::do_Event_Store_CppDefinition( ary::cpp::DefineEntity & io_rDefinition )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     pDocuDistributor->SetCurrentlyStoredRe(io_rDefinition);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir void
do_Event_EnterFunction_ParameterList()218cdf0e10cSrcweir ContextForAry::do_Event_EnterFunction_ParameterList()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     // KORR_FUTURE
221cdf0e10cSrcweir     // Inform pDocuDistributor about possibility of parameters' inline documentation.
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir void
do_Event_Function_FinishedParameter(const String &)225cdf0e10cSrcweir ContextForAry::do_Event_Function_FinishedParameter( const String & )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir     // KORR_FUTURE
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir void
do_Event_LeaveFunction_ParameterList()231cdf0e10cSrcweir ContextForAry::do_Event_LeaveFunction_ParameterList()
232cdf0e10cSrcweir {
233cdf0e10cSrcweir     // KORR_FUTURE
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir void
do_Event_EnterFunction_Implementation()237cdf0e10cSrcweir ContextForAry::do_Event_EnterFunction_Implementation()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     // KORR_FUTURE
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir void
do_Event_LeaveFunction_Implementation()243cdf0e10cSrcweir ContextForAry::do_Event_LeaveFunction_Implementation()
244cdf0e10cSrcweir {
245cdf0e10cSrcweir     // KORR_FUTURE
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir void
do_Event_Store_Function(ary::cpp::Function & io_rFunction)249cdf0e10cSrcweir ContextForAry::do_Event_Store_Function( ary::cpp::Function & io_rFunction )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir     pDocuDistributor->SetCurrentlyStoredRe(io_rFunction);
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 
255cdf0e10cSrcweir void
do_Event_Store_Variable(ary::cpp::Variable & io_rVariable)256cdf0e10cSrcweir ContextForAry::do_Event_Store_Variable( ary::cpp::Variable & io_rVariable )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir     pDocuDistributor->SetCurrentlyStoredRe(io_rVariable);
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir void
do_TakeDocu(DYN ary::doc::OldCppDocu & let_drInfo)262cdf0e10cSrcweir ContextForAry::do_TakeDocu( DYN ary::doc::OldCppDocu & let_drInfo )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     let_drInfo.Store2(*pDocuDistributor);
265cdf0e10cSrcweir }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir void
do_StartWaitingFor_Recovery()268cdf0e10cSrcweir ContextForAry::do_StartWaitingFor_Recovery()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir     pRecoveryGuard->StartWaitingFor_Recovery();
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir ary::cpp::Gate &
inq_AryGate() const274cdf0e10cSrcweir ContextForAry::inq_AryGate() const
275cdf0e10cSrcweir {
276cdf0e10cSrcweir  	return * const_cast< ary::cpp::Gate* >(pGate);
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir const ary::cpp::InputContext &
inq_Context() const280cdf0e10cSrcweir ContextForAry::inq_Context() const
281cdf0e10cSrcweir {
282cdf0e10cSrcweir     return *this;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir String
inq_CurFileName() const286cdf0e10cSrcweir ContextForAry::inq_CurFileName() const
287cdf0e10cSrcweir {
288cdf0e10cSrcweir     return pFileScopeInfo->pCurFile != 0
289cdf0e10cSrcweir             ?   pFileScopeInfo->pCurFile->LocalName()
290cdf0e10cSrcweir             :   String::Null_();
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir uintt
inq_LineCount() const294cdf0e10cSrcweir ContextForAry::inq_LineCount() const
295cdf0e10cSrcweir {
296cdf0e10cSrcweir     return pFileScopeInfo->nLineCount;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir bool
inq_IsWaitingFor_Recovery() const300cdf0e10cSrcweir ContextForAry::inq_IsWaitingFor_Recovery() const
301cdf0e10cSrcweir {
302cdf0e10cSrcweir     return pRecoveryGuard->IsWithinRecovery();
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
305cdf0e10cSrcweir bool
inq_IsExternC() const306cdf0e10cSrcweir ContextForAry::inq_IsExternC() const
307cdf0e10cSrcweir {
308cdf0e10cSrcweir  	return pOwnerStack->IsExternC();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir void
do_SetCurFile(ary::loc::File & io_rCurFile)312cdf0e10cSrcweir ContextForAry::do_SetCurFile( ary::loc::File &  io_rCurFile )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir     pFileScopeInfo->pCurFile = &io_rCurFile;
315cdf0e10cSrcweir     pFileScopeInfo->nLineCount = 0;
316cdf0e10cSrcweir     pFileScopeInfo->pCurTemplateParameters = 0;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     pOwnerStack->Reset();
319cdf0e10cSrcweir     pDocuDistributor->Reset();
320cdf0e10cSrcweir     pRecoveryGuard->Reset();
321cdf0e10cSrcweir }
322cdf0e10cSrcweir 
323cdf0e10cSrcweir void
do_Event_IncrLineCount()324cdf0e10cSrcweir ContextForAry::do_Event_IncrLineCount()
325cdf0e10cSrcweir {
326cdf0e10cSrcweir     ++pFileScopeInfo->nLineCount;
327cdf0e10cSrcweir     pDocuDistributor->Event_LineBreak();
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir void
do_Event_SwBracketOpen()331cdf0e10cSrcweir ContextForAry::do_Event_SwBracketOpen()
332cdf0e10cSrcweir {
333cdf0e10cSrcweir     pRecoveryGuard->Hdl_SwBracketOpen();
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir void
do_Event_SwBracketClose()337cdf0e10cSrcweir ContextForAry::do_Event_SwBracketClose()
338cdf0e10cSrcweir {
339cdf0e10cSrcweir     pRecoveryGuard->Hdl_SwBracketClose();
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir void
do_Event_Semicolon()343cdf0e10cSrcweir ContextForAry::do_Event_Semicolon()
344cdf0e10cSrcweir {
345cdf0e10cSrcweir 	pRecoveryGuard->Hdl_Semicolon();
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 
351cdf0e10cSrcweir }   // namespace cpp
352