1 20 21 package org.jacorb.idl; 22 23 27 28 import java.io.PrintWriter ; 29 import java.util.*; 30 31 class ArrayDeclarator 32 extends Declarator 33 { 34 public SymbolList fixed_array_size_list; 35 private int[] dimensions = null; 36 37 public ArrayDeclarator( int num ) 38 { 39 super( num ); 40 } 41 42 public String name() 43 { 44 return name; 45 } 46 47 49 50 public void escapeName() 51 { 52 if( !name.startsWith( "_" ) && 53 lexer.strictJavaEscapeCheck( name ) ) 54 { 55 name = "_" + name; 56 } 57 } 58 59 public void setPackage( String s ) 60 { 61 s = parser.pack_replace( s ); 62 if( pack_name.length() > 0 ) 63 pack_name = s + "." + pack_name; 64 else 65 pack_name = s; 66 67 for( Enumeration e = fixed_array_size_list.v.elements(); 68 e.hasMoreElements(); 69 ( (FixedArraySize)e.nextElement() ).setPackage( s ) ) ; 70 71 } 72 73 78 79 String full_name() 80 { 81 if( name.length() == 0 ) 82 return null; 83 if( pack_name.length() > 0 ) 84 return pack_name + "." + name; 85 else 86 return name; 87 } 88 89 public void parse() 90 { 91 for( Enumeration e = fixed_array_size_list.v.elements(); 92 e.hasMoreElements(); 93 ( (FixedArraySize)e.nextElement() ).parse() 94 ) 95 ; 96 97 for( Enumeration e = fixed_array_size_list.v.elements(); 98 e.hasMoreElements(); 99 ) 100 ( (FixedArraySize)e.nextElement() ).parse(); 101 } 102 103 public void setEnclosingSymbol( IdlSymbol s ) 104 { 105 if( enclosing_symbol != null && enclosing_symbol != s ) 106 throw new RuntimeException ( "Compiler Error: trying to reassign container for " + name ); 107 enclosing_symbol = s; 108 } 109 110 public IdlSymbol getEnclosingSymbol() 111 { 112 return enclosing_symbol; 113 } 114 115 public int[] dimensions() 116 { 117 if( dimensions == null ) 118 { 119 Vector dynlist = new Vector(); 120 for( Enumeration e = fixed_array_size_list.v.elements(); e.hasMoreElements(); ) 121 dynlist.addElement( new Integer ( ( (FixedArraySize)e.nextElement() ).value() ) ); 122 dimensions = new int[ dynlist.size() ]; 123 for( int i = 0; i < dimensions.length; i++ ) 124 dimensions[ i ] = ( (Integer )dynlist.elementAt( i ) ).intValue(); 125 126 } 127 return dimensions; 128 } 129 130 public String toString() 131 { 132 return name(); 133 } 134 135 public void print( PrintWriter ps ) 136 { 137 } 138 139 } 140 | Popular Tags |