KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > idl > MemberList


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1997-2004 Gerald Brose.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */

20
21 /**
22  * @author Gerald Brose
23  * @version $Id: MemberList.java,v 1.17 2004/05/06 12:39:58 nicolas Exp $
24  *
25  */

26
27 package org.jacorb.idl;
28
29 import java.util.*;
30
31 public class MemberList
32     extends SymbolList
33 {
34     Vector extendVector = new Vector();
35     private TypeDeclaration containingType;
36     private boolean parsed = false;
37
38     public MemberList( int num )
39     {
40         super( num );
41     }
42
43     public void setContainingType( TypeDeclaration t )
44     {
45         containingType = t;
46         Enumeration e = v.elements();
47         for( ; e.hasMoreElements(); )
48         {
49             Member m = (Member)e.nextElement();
50             m.setContainingType( t );
51         }
52     }
53
54     public void parse()
55     {
56         if( parsed )
57             throw new RuntimeException JavaDoc( "Compiler error: MemberList already parsed!" );
58
59         Enumeration e = v.elements();
60         for( ; e.hasMoreElements(); )
61         {
62             Member m = (Member)e.nextElement();
63             m.setExtendVector( extendVector );
64             m.parse();
65         }
66
67         /* after all members are parsed, we have accumulated
68            a new member list in "normal form" in extendVector
69         */

70
71         v = extendVector;
72         parsed = true;
73
74     }
75
76     public void setEnclosingSymbol( IdlSymbol s )
77     {
78
79         if( enclosing_symbol != null && enclosing_symbol != s )
80         {
81             logger.error("was " + enclosing_symbol.getClass().getName() +
82                                 " now: " + s.getClass().getName() );
83
84             throw new RuntimeException JavaDoc( "Compiler Error: trying to reassign container" );
85         }
86
87         enclosing_symbol = s;
88
89         for( Enumeration e = v.elements(); e.hasMoreElements(); )
90         {
91             Member m = (Member)e.nextElement();
92             m.setEnclosingSymbol( s );
93         }
94     }
95
96 }
97
Popular Tags