1 2 package SOFA.SOFAnode.Made.CDL; 3 import java.rmi.RemoteException ; 4 5 import SOFA.SOFAnode.Made.TIR.CDLRepository; 6 import SOFA.SOFAnode.Made.TIR.ExprBinOperationDef; 7 import SOFA.SOFAnode.Made.TIR.ExprConstant; 8 import SOFA.SOFAnode.Made.TIR.ExprOperDef; 9 import SOFA.SOFAnode.Made.TIR.ExprOperKind; 10 import SOFA.SOFAnode.Made.TIR.ExprProperty; 11 import SOFA.SOFAnode.Made.TIR.ExprUnOperationDef; 12 13 14 abstract class CompExprOper { 15 public int kind; 16 17 public CompExprOper(int t) { kind = t; } 18 19 20 public abstract int type(); 21 22 23 public abstract boolean isProp(); 24 25 26 public abstract EnumList nameProp(CompRepository rep) throws CDLExceptRemote, CDLExceptLock; 27 28 31 33 public abstract ExprOperDef toNormal(CDLRepository rep) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock; 34 35 36 public static boolean testPropInExpr(EnumList prop, EnumList exprProp) { 37 if (prop==null || exprProp==null) 38 return true; 39 exprProp.toFirst(); 40 for (int i=0;i<exprProp.size();i++) { 41 if (!prop.isIn((String ) exprProp.aktual())) 42 return false; 43 exprProp.toNext(); 44 } 45 return true; 46 } 47 48 49 public static boolean isExprType(CompType t, CompExprOper e) { 50 if (e.type()==CompExprKind.e_default) 51 return true; 52 int ttype; 53 switch (t.objectKind()) { 54 case ObjectsKind.o_none: 55 if (((CompReffer) t).basereffer == ObjectsKind.o_Primitive) { 56 ttype = ((CompReffer) t).baserefferprim; 57 switch (ttype) { 58 case CompPrimKind.p_short: 59 case CompPrimKind.p_long: 60 case CompPrimKind.p_longlong: 61 case CompPrimKind.p_ushort: 62 case CompPrimKind.p_ulong: 63 case CompPrimKind.p_ulonglong: 64 if (e.type() == CompExprKind.e_int || e.type() == CompExprKind.e_all) 65 return true; 66 else 67 return false; 68 case CompPrimKind.p_float: 69 case CompPrimKind.p_double: 70 case CompPrimKind.p_longdouble: 71 if (e.type() == CompExprKind.e_float || e.type() == CompExprKind.e_all) 72 return true; 73 else 74 return false; 75 case CompPrimKind.p_string: 76 if (e.type() == CompExprKind.e_string || e.type() == CompExprKind.e_all) 77 return true; 78 else 79 return false; 80 case CompPrimKind.p_wstring: 81 if (e.type() == CompExprKind.e_wstring || e.type() == CompExprKind.e_all) 82 return true; 83 else 84 return false; 85 case CompPrimKind.p_char: 86 if (e.type() == CompExprKind.e_char || e.type() == CompExprKind.e_all) 87 return true; 88 else 89 return false; 90 case CompPrimKind.p_wchar: 91 if (e.type() == CompExprKind.e_wchar || e.type() == CompExprKind.e_all) 92 return true; 93 else 94 return false; 95 case CompPrimKind.p_boolean: 96 if (e.type() == CompExprKind.e_boolean || e.type() == CompExprKind.e_all) 97 return true; 98 else 99 return false; 100 } 101 } else { 102 switch (((CompReffer) t).basereffer) { 103 case ObjectsKind.o_String: 104 if (e.type() == CompExprKind.e_string || e.type() == CompExprKind.e_all) 105 return true; 106 else 107 return false; 108 case ObjectsKind.o_Wstring: 109 if (e.type() == CompExprKind.e_wstring || e.type() == CompExprKind.e_all) 110 return true; 111 else 112 return false; 113 case ObjectsKind.o_Enum: 114 if (e.type() == CompExprKind.e_enum || e.type() == CompExprKind.e_all) 115 return true; 116 else 117 return false; 118 case ObjectsKind.o_Fixed: 119 if (e.type() == CompExprKind.e_fixed || e.type() == CompExprKind.e_all) 120 return true; 121 else 122 return false; 123 } 124 } 125 break; 126 case ObjectsKind.o_Primitive: 127 ttype = ((CompPrimitive) t).kind; 128 switch (ttype) { 129 case CompPrimKind.p_short: 130 case CompPrimKind.p_long: 131 case CompPrimKind.p_longlong: 132 case CompPrimKind.p_ushort: 133 case CompPrimKind.p_ulong: 134 case CompPrimKind.p_ulonglong: 135 if (e.type() == CompExprKind.e_int || e.type() == CompExprKind.e_all) 136 return true; 137 else 138 return false; 139 case CompPrimKind.p_float: 140 case CompPrimKind.p_double: 141 case CompPrimKind.p_longdouble: 142 if (e.type() == CompExprKind.e_float || e.type() == CompExprKind.e_all) 143 return true; 144 else 145 return false; 146 case CompPrimKind.p_string: 147 if (e.type() == CompExprKind.e_string || e.type() == CompExprKind.e_all) 148 return true; 149 else 150 return false; 151 case CompPrimKind.p_wstring: 152 if (e.type() == CompExprKind.e_wstring || e.type() == CompExprKind.e_all) 153 return true; 154 else 155 return false; 156 case CompPrimKind.p_char: 157 if (e.type() == CompExprKind.e_char || e.type() == CompExprKind.e_all) 158 return true; 159 else 160 return false; 161 case CompPrimKind.p_wchar: 162 if (e.type() == CompExprKind.e_wchar || e.type() == CompExprKind.e_all) 163 return true; 164 else 165 return false; 166 case CompPrimKind.p_boolean: 167 if (e.type() == CompExprKind.e_boolean || e.type() == CompExprKind.e_all) 168 return true; 169 else 170 return false; 171 } 172 break; 173 case ObjectsKind.o_Enum: 174 if (e.type() == CompExprKind.e_enum) 175 return true; 176 else 177 return false; 178 case ObjectsKind.o_String: 179 if (e.type() == CompExprKind.e_string) 180 return true; 181 else 182 return false; 183 case ObjectsKind.o_Wstring: 184 if (e.type() == CompExprKind.e_wstring) 185 return true; 186 else 187 return false; 188 case ObjectsKind.o_Fixed: 189 if (e.type() == CompExprKind.e_fixed) 190 return true; 191 else 192 return false; 193 default: 194 return false; 195 } 196 return false; 197 } 198 199 200 public static EnumList scanNormalExpr(ExprOperDef e) throws CDLExceptRemote { 201 try { 202 int i; 203 switch (e.get_eok_kind().value()) { 204 case ExprOperKind.eok_or: 205 case ExprOperKind.eok_xor: 206 case ExprOperKind.eok_and: 207 case ExprOperKind.eok_shr: 208 case ExprOperKind.eok_shl: 209 case ExprOperKind.eok_plus: 210 case ExprOperKind.eok_minus: 211 case ExprOperKind.eok_mul: 212 case ExprOperKind.eok_div: 213 case ExprOperKind.eok_mod: 214 EnumList l1 = scanNormalExpr(((ExprBinOperationDef) e).operand1()); 215 EnumList l2 = scanNormalExpr(((ExprBinOperationDef) e).operand2()); 216 for (i=0;i<l2.size();i++) { 217 l1.addName((String ) l2.aktual()); 218 l2.toNext(); 219 } 220 return l1; 221 case ExprOperKind.eok_unminus: 222 case ExprOperKind.eok_unplus: 223 case ExprOperKind.eok_untilde: 224 return scanNormalExpr(((ExprUnOperationDef) e).operand()); 225 case ExprOperKind.eok_short: 226 case ExprOperKind.eok_long: 227 case ExprOperKind.eok_longlong: 228 case ExprOperKind.eok_unsigshort: 229 case ExprOperKind.eok_unsiglong: 230 case ExprOperKind.eok_unsiglonglong: 231 case ExprOperKind.eok_float: 232 case ExprOperKind.eok_double: 233 case ExprOperKind.eok_longdouble: 234 case ExprOperKind.eok_fixed: 235 case ExprOperKind.eok_valuegen: 236 case ExprOperKind.eok_enum: 237 case ExprOperKind.eok_octet: 238 case ExprOperKind.eok_char: 239 case ExprOperKind.eok_wchar: 240 case ExprOperKind.eok_string: 241 case ExprOperKind.eok_wstring: 242 case ExprOperKind.eok_default: 243 return new EnumList(); 244 case ExprOperKind.eok_constant: 245 return scanNormalExpr(((ExprConstant) e).ref_const().value()); 246 case ExprOperKind.eok_property: 247 EnumList l = new EnumList(); 248 l.addName(((ExprProperty) e).ref_prop()); 249 return l; 250 } 251 } catch (RemoteException ex) { 252 throw new CDLExceptRemote(ex.getMessage()); 253 } 254 return new EnumList(); 255 } 256 } 257 | Popular Tags |