1 20 21 package org.jacorb.idl; 22 23 29 30 31 import java.io.PrintWriter ; 32 33 class BaseType 34 extends SimpleTypeSpec 35 { 36 public BaseType( int num ) 37 { 38 super( num ); 39 } 40 41 44 45 public void setPackage( String s ) 46 { 47 s = parser.pack_replace( s ); 48 } 49 50 public TypeSpec typeSpec() 51 { 52 return type_spec.typeSpec(); 53 } 54 55 public boolean basic() 56 { 57 return type_spec.basic(); 58 } 59 60 public boolean isSwitchType() 61 { 62 return ( 63 type_spec instanceof SwitchTypeSpec && 64 ( (SwitchTypeSpec)type_spec ).isSwitchable() 65 ); 66 } 67 68 71 72 public void parse() 73 { 74 } 75 76 public static boolean isBasicName( String typeName ) 77 { 78 int index = typeName.indexOf ('['); 81 String toMatch = typeName.substring (0, (index == -1 ? typeName.length () : index)); 82 83 return 84 ( 85 toMatch.equals ("long") || 86 toMatch.equals ("int") || 87 toMatch.equals ("short") || 88 toMatch.equals ("float") || 89 toMatch.equals ("double") || 90 toMatch.equals ("byte") || 91 toMatch.equals ("boolean") || 92 toMatch.equals ("char") || 93 toMatch.equals ("java.lang.String") 94 ); 95 } 96 97 public void setEnclosingSymbol( IdlSymbol s ) 98 { 99 if( enclosing_symbol != null && enclosing_symbol != s ) 100 throw new RuntimeException ( "Compiler Error: trying to reassign container for " + name ); 101 enclosing_symbol = s; 102 } 103 104 105 106 public int getTCKind() 107 { 108 return ( (BaseType)type_spec ).getTCKind(); 109 } 110 111 protected String typeCodeExpressionSkeleton( int kind ) 112 { 113 return "org.omg.CORBA.ORB.init().get_primitive_tc(" 114 + "org.omg.CORBA.TCKind.from_int(" + kind + "))"; 115 } 116 117 public String getTypeCodeExpression() 118 { 119 return typeCodeExpressionSkeleton( getTCKind() ); 120 } 121 122 public String toString() 123 { 124 if( type_spec != null ) 125 return type_spec.toString(); 126 else 127 return "BaseType"; 128 } 129 130 public String typeName() 131 { 132 return type_spec.typeName(); 133 } 134 135 136 137 public String id() 138 { 139 return "IDL:*primitive*:1.0"; 140 } 141 142 145 146 public void print( PrintWriter ps ) 147 { 148 } 149 150 151 } 152 153 | Popular Tags |