1 20 21 package org.jacorb.idl; 22 23 27 28 import java.io.PrintWriter ; 29 30 public class NativeType 31 extends TypeDeclaration 32 { 33 SimpleDeclarator declarator; 34 35 public NativeType( int num ) 36 { 37 super( num ); 38 pack_name = ""; 39 } 40 41 public Object clone() 42 { 43 NativeType nt = new NativeType( new_num() ); 44 nt.declarator = this.declarator; 45 nt.pack_name = this.pack_name; 46 return nt; 47 } 48 49 public void setEnclosingSymbol( IdlSymbol s ) 50 { 51 if( enclosing_symbol != null && enclosing_symbol != s ) 52 throw new RuntimeException ( "Compiler Error: trying to reassign container for " + name ); 53 enclosing_symbol = s; 54 } 55 56 public TypeDeclaration declaration() 57 { 58 return this; 59 } 60 61 public String typeName() 62 { 63 if( pack_name.length() > 0 ) 64 return ScopedName.unPseudoName( pack_name + "." + name ); 65 else 66 return ScopedName.unPseudoName( name ); 67 } 68 69 70 public void setPackage( String s ) 71 { 72 s = parser.pack_replace( s ); 73 if( pack_name.length() > 0 ) 74 pack_name = s + "." + pack_name; 75 else 76 pack_name = s; 77 } 78 79 public boolean basic() 80 { 81 return true; 82 } 83 84 public String toString() 85 { 86 return typeName(); 87 } 88 89 public void set_included( boolean i ) 90 { 91 included = i; 92 } 93 94 public void parse() 95 96 { 97 100 name = declarator.name(); 101 is_pseudo = true; 102 103 ConstrTypeSpec ctspec = new ConstrTypeSpec( new_num() ); 104 try 105 { 106 ctspec.c_type_spec = this; 107 NameTable.define( full_name(), "native" ); 108 TypeMap.typedef( full_name(), ctspec ); 109 } 110 catch( NameAlreadyDefined n ) 111 { 112 parser.fatal_error( "Name already defined", token ); 113 } 114 } 115 116 public String holderName() 117 { 118 return typeName() + "Holder"; 119 } 120 121 122 public String printReadExpression( String Streamname ) 123 { 124 return full_name() + "Helper.read(" + Streamname + ")"; 125 } 126 127 public String printWriteStatement( String var_name, String Streamname ) 128 { 129 return full_name() + "Helper.write(" + Streamname + "," + var_name + ");"; 130 } 131 132 public void print( PrintWriter ps ) 133 { 134 } 135 136 138 139 public void accept( IDLTreeVisitor visitor ) 140 { 141 visitor.visitNative( this ); 142 } 143 144 145 } 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | Popular Tags |