1 package org.jacorb.idl; 2 3 22 23 27 28 class ElementSpec 29 extends IdlSymbol 30 { 31 public TypeSpec t = new TypeSpec( new_num() ); 32 public Declarator d = null; 33 private UnionType containingUnion; 34 35 public ElementSpec( int num ) 36 { 37 super( num ); 38 } 39 40 public void setPackage( String s ) 41 { 42 s = parser.pack_replace( s ); 43 if( pack_name.length() > 0 ) 44 pack_name = s + "." + pack_name; 45 else 46 pack_name = s; 47 t.setPackage( s ); 48 d.setPackage( s ); 49 } 50 51 public void setUnion( UnionType ut ) 52 { 53 containingUnion = ut; 54 55 if (t.typeSpec () instanceof ConstrTypeSpec) 57 { 58 String tmpRef = ((ConstrTypeSpec)t.typeSpec ()).c_type_spec.pack_name; 59 60 if (tmpRef.endsWith ("PackagePackage") || ! tmpRef.startsWith ("_") && tmpRef.endsWith ("Package")) 61 { 62 tmpRef = tmpRef.substring( 0, tmpRef.lastIndexOf( "Package" ) ); 63 } 64 if (ScopedName.isPseudoScope (tmpRef)) 65 { 66 ((ConstrTypeSpec)t.typeSpec ()).c_type_spec.pack_name = 67 ((ConstrTypeSpec)t.typeSpec ()).c_type_spec.pack_name + "." + ut.name + "Package"; 68 } 69 } 70 } 71 72 public void setEnclosingSymbol( IdlSymbol s ) 73 { 74 t.setEnclosingSymbol( s ); 75 d.setEnclosingSymbol( s ); 76 } 77 78 public void parse() 79 { 80 81 if( logger.isDebugEnabled() ) 82 { 83 logger.debug("EelementSpec.parse(): element_spec is " + t.typeSpec().getClass().getName()); 84 } 85 86 if( t.typeSpec() instanceof TemplateTypeSpec || 87 t.typeSpec() instanceof ConstrTypeSpec ) 88 { 89 t.parse(); 90 if( t.typeSpec() instanceof SequenceType ) 91 { 92 TypeSpec ts = ( (SequenceType)t.typeSpec() ).elementTypeSpec().typeSpec(); 93 SequenceType seqTs = (SequenceType)t.typeSpec(); 94 while( ts instanceof SequenceType ) 95 { 96 seqTs = (SequenceType)ts; 97 ts = ( (SequenceType)ts.typeSpec() ).elementTypeSpec().typeSpec(); 98 } 99 100 if( ScopedName.isRecursionScope( ts.typeName() ) ) 102 { 103 ( (SequenceType)seqTs.typeSpec() ).setRecursive(); 104 } 105 } 106 } 107 else if( t.typeSpec() instanceof ScopedName ) 108 { 109 TypeSpec ts = ( (ScopedName)t.typeSpec() ).resolvedTypeSpec(); 110 if( ts.typeName().equals( containingUnion.typeName() ) ) 111 { 112 parser.error( "Illegal recursion in union " + containingUnion.full_name(), token ); 113 } 114 115 containingUnion.addImportedName( ts.typeName() ); 116 117 119 if( ! ( ts instanceof ConstrTypeSpec && 122 ((ConstrTypeSpec)ts).declaration() instanceof Interface) ) 123 { 124 t = ts; 125 } 126 } 127 128 try 129 { 130 NameTable.define( containingUnion.full_name() + "." + d.name(), "declarator" ); 131 } 132 catch( NameAlreadyDefined nad ) 133 { 134 parser.error( "Declarator " + d.name() + 135 " already defined in union " + containingUnion.full_name(), token ); 136 } 137 138 if( logger.isDebugEnabled() ) 139 { 140 logger.debug("ElementSpec.parse-end(): element_spec is " + t.typeSpec().getClass().getName()); 141 } 142 } 143 144 public void print( java.io.PrintWriter ps ) 145 { 146 if( t.typeSpec() instanceof TemplateTypeSpec || 147 t.typeSpec() instanceof ConstrTypeSpec ) 148 { 149 t.print( ps ); 150 } 151 } 152 153 154 } 155 | Popular Tags |