1 2 package SOFA.SOFAnode.Made.CDL; 3 import java.rmi.RemoteException ; 4 5 import SOFA.SOFAnode.Made.TIR.AbsoluteName; 6 import SOFA.SOFAnode.Made.TIR.ArrayDef; 7 import SOFA.SOFAnode.Made.TIR.CDLType; 8 import SOFA.SOFAnode.Made.TIR.Contained; 9 import SOFA.SOFAnode.Made.TIR.Container; 10 import SOFA.SOFAnode.Made.TIR.DefinitionKind; 11 import SOFA.SOFAnode.Made.TIR.FrameDef; 12 import SOFA.SOFAnode.Made.TIR.Identification; 13 import SOFA.SOFAnode.Made.TIR.InterfaceDef; 14 import SOFA.SOFAnode.Made.TIR.ProtocolBinOperationDef; 15 import SOFA.SOFAnode.Made.TIR.ProtocolDef; 16 import SOFA.SOFAnode.Made.TIR.ProtocolMetaOperandDef; 17 import SOFA.SOFAnode.Made.TIR.ProtocolMode; 18 import SOFA.SOFAnode.Made.TIR.ProtocolNestedOperandDef; 19 import SOFA.SOFAnode.Made.TIR.ProtocolOperDef; 20 import SOFA.SOFAnode.Made.TIR.ProtocolOperKind; 21 import SOFA.SOFAnode.Made.TIR.ProtocolOperandDef; 22 import SOFA.SOFAnode.Made.TIR.ProtocolUnOperationDef; 23 import SOFA.SOFAnode.Made.TIR.ProvideDef; 24 import SOFA.SOFAnode.Made.TIR.RequireDef; 25 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 26 import SOFA.SOFAnode.Made.TIR.TypedefDef; 27 28 class CompInst extends CompContainedIm { 29 public static final int normal = 0; 30 public static final int auto = 1; 31 CompReffer subcom; 32 int mode; 33 String typeCode; 34 35 String protocol; java.util.ArrayList provOps; 38 public CompInst(ID id, CompContainer parent, CompRepository rep, CompReffer subcom, int mode, String tC) { 39 super(ObjectsKind.o_Inst, id, parent, rep); 40 id.version = ((CompContained)parent).getIdent().version; 41 this.mode = mode; 42 this.subcom = subcom; 43 typeCode = tC; 44 protocol = null; 45 provOps = new java.util.ArrayList (); 46 } 47 48 public boolean containsArray() { 49 if (typeCode.indexOf('a')!=-1) 50 return true; 51 return false; 52 } 53 54 public static CompReffer canBeInst(FullID idp, EnumList propNames, CompRepository inRep, StringBuffer typeCode) throws CDLExceptLock, CDLExceptRemote { 55 CompReffer what = null; 56 if ((what = inRep.searchReffer(idp))==null) { 57 return null; 58 } 59 if (System.getProperty("cdl.disableBindTests","no").compareTo("yes")==0) { 60 return what; 61 } 62 boolean ok = false; 64 int kind = what.what; 65 CompReffer r = what; 66 while (!ok) { 67 if (kind != ObjectsKind.o_Frame) { 68 if (kind == ObjectsKind.o_Typedef || kind == ObjectsKind.o_Array) { 69 int i,j; 70 FullID id = r.ref; 71 if (r.isNew) { CompContainer con = inRep; 73 id.sn.names.toFirst(); 74 for(i=0;i<id.sn.names.size();i++) { 75 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 76 if (a==null || a.length==0) { 77 inRep.searchError = "this can't be instantion"; 78 return null; 79 } 80 if (a.length==1) { 81 if (a[0].isContainer()) con = (CompContainer) a[0]; 82 else { 83 inRep.searchError = "this can't be instantion"; 84 return null; 85 } 86 } else { 87 inRep.searchError = "this can't be instantion"; 88 return null; 89 } 90 id.sn.names.toNext(); 91 } 92 CompContained sec = con.lookup(id.name, id.version); 93 if (sec!=null) { 94 CompType sectype = null; 95 if (sec.objectKind() == ObjectsKind.o_Typedef) 96 sectype = ((CompTypedef) sec).type; 97 else 98 sectype = ((CompArray) sec).type; 99 if (sectype.objectKind() != ObjectsKind.o_Frame) { 100 if (sectype.objectKind()==ObjectsKind.o_none) { r = (CompReffer) sectype; 102 kind = r.what; 103 } else { 104 if (sectype.objectKind()==ObjectsKind.o_Array) { 105 while (sectype.objectKind()==ObjectsKind.o_Array) { 106 typeCode.append('a'); 107 EnumList exprProp = ((CompArray) sectype).length.nameProp(inRep); 109 if (!CompExprOper.testPropInExpr(propNames,exprProp)) { 110 inRep.searchError = "unknown property"; 111 return null; 112 } 113 sectype = ((CompArray) sectype).type; 114 } 115 if (sectype.objectKind() != ObjectsKind.o_none) { 116 if (sectype.objectKind() == ObjectsKind.o_Frame) { 117 typeCode.append('f'); 118 ok = true; 120 } else { 121 inRep.searchError = "this can't be instantion"; 122 return null; 123 } 124 } else { 125 r = (CompReffer) sectype; 126 kind = r.what; 127 } 128 } else { 129 inRep.searchError = "this can't be instantion"; 130 return null; 131 } 132 } 133 } else { 134 typeCode.append('f'); 135 ok = true; 137 } 138 } else { 139 inRep.searchError = "this can't be instantion"; 140 return null; 141 } 142 } else { try { 144 Container con = inRep.cdlRepository; 145 id.sn.names.toFirst(); 146 for(i=0;i<id.sn.names.size();i++) { 147 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 148 if (a==null || a.length==0) { 149 inRep.searchError = "this can't be instantion"; 150 return null; 151 } 152 if (a.length==1) { 153 if (a[0] instanceof Container) con = (Container) a[0]; 154 else { 155 inRep.searchError = "this can't be instantion"; 156 return null; 157 } 158 } else { 159 boolean found = false; 160 for(j=0;j<a.length;j++) { 161 if (a[j].get_identification().version().compareTo(id.version)==0) { 162 if ( !(a[j] instanceof Container)) { 163 inRep.searchError = "this can't be instantion"; 164 return null; 165 } 166 found = true; 167 con = (Container) a[j]; 168 break; 169 } 170 } 171 if (!found) { 172 inRep.searchError = "this can't be instantion"; 173 return null; 174 } 175 } 176 id.sn.names.toNext(); 177 } 178 Contained sec = con.lookup(id.name, id.version); 179 if (sec!=null) { 180 CDLType sectype = null; 181 if (sec.get_def_kind().value() == DefinitionKind.dk_Typedef) 182 sectype = ((TypedefDef) sec).original_type(); 183 else 184 sectype = ((ArrayDef) sec).element_type(); 185 if (sectype.get_def_kind().value() != DefinitionKind.dk_Frame) { 186 if (sectype.get_def_kind().value() == DefinitionKind.dk_Typedef) { 187 CompReffer ret = new CompReffer(); 188 ret.what = sectype.get_def_kind().value(); 189 ret.ref = new FullID(true); 190 Identification idl; 191 ret.ref.name = new String ((idl = ((TypedefDef)sectype).get_identification()).name()); 192 ret.ref.version = new String (idl.version()); 193 ret.ref.isin = IDKind.version; 194 ret.isNew = false; 195 AbsoluteName abs = idl.absolute_name(); 196 for(j=0;j<abs.size();j++) { 197 ret.ref.sn.addScope(new String (abs.elementAt(j))); 198 } 199 r = ret; 200 kind = r.what; 201 } else { 202 if (sectype.get_def_kind().value()==DefinitionKind.dk_Array) { 203 while (sectype.get_def_kind().value()==DefinitionKind.dk_Array) { 204 typeCode.append('a'); 205 EnumList exprProp = CompExprOper.scanNormalExpr(((ArrayDef) sectype).length()); 207 if (!CompExprOper.testPropInExpr(propNames,exprProp)) { 208 inRep.searchError = "unknown property"; 209 return null; 210 } 211 sectype = ((ArrayDef) sectype).element_type(); 212 } 213 if (sectype.get_def_kind().value()!=DefinitionKind.dk_Typedef) { 214 if (sectype.get_def_kind().value()==DefinitionKind.dk_Frame) { 215 typeCode.append('f'); 216 ok = true; 217 } else { 218 inRep.searchError = "this can't be instantion"; 219 return null; 220 } 221 } else { 222 CompReffer ret = new CompReffer(); 223 ret.what = sectype.get_def_kind().value(); 224 ret.ref = new FullID(true); 225 Identification idl; 226 ret.ref.name = new String ((idl = ((TypedefDef)sectype).get_identification()).name()); 227 ret.ref.version = new String (idl.version()); 228 ret.ref.isin = IDKind.version; 229 ret.isNew = false; 230 AbsoluteName abs = idl.absolute_name(); 231 for(j=0;j<abs.size();j++) { 232 ret.ref.sn.addScope(new String (abs.elementAt(j))); 233 } 234 r = ret; 235 kind = r.what; 236 } 237 } else { 238 inRep.searchError = "this can't be instantion"; 239 return null; 240 } 241 } 242 } else { 243 typeCode.append('f'); 244 ok = true; 245 } 246 } else { 247 inRep.searchError = "this can't be instantion"; 248 return null; 249 } 250 } catch (TIRExceptLock e) { 251 throw new CDLExceptLock("Repository is locked."); 252 } catch (RemoteException e) { 253 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 254 } 255 } 256 } else { 257 inRep.searchError = "this can't be instantion"; 258 return null; 259 } 260 } else { 261 typeCode.append('f'); 262 ok = true; 263 } 264 } 265 return what; 266 } 267 268 public void checkConsist(EnumList props, CompRepository rep) throws CDLExceptCheck, CDLExceptLock, CDLExceptRemote { 269 subcom.checkConsist(props, rep); 270 if (rep.testProtocols) { 271 274 } 277 } 278 279 static class reProvReq { 280 String origSub; 281 String origName; 282 String rew; 283 int type; 284 public reProvReq(String os, String on, int t) { 285 origSub = os; 286 origName = on; 287 type = t; 288 } 289 290 public boolean compareTo(String s, String n) { 291 if (origSub.compareTo(s)==0 && origName.compareTo(n)==0) 292 return true; 293 return false; 294 } 295 296 public String toString() { 297 return origSub+"."+origName+"("+rew+")"; 298 } 299 } 300 301 static class provIfaceOperations { 303 String sub; 304 String provide; String rew; 306 String [] operations; 307 public provIfaceOperations(String s, String p, String [] op) { 308 sub = s; 309 provide = p; 310 operations = op; 311 } 312 public String toString() { 313 StringBuffer sb = new StringBuffer (); 314 for (int i=0;i<operations.length;i++) { 315 sb.append(rew+"."+operations[i]+", "); 316 } 317 return sb.toString(); 318 } 319 public boolean compareTo(String s, String p) { 320 return s.compareTo(sub)==0 && p.compareTo(provide)==0; 321 } 322 public String [] toRewOperations() { 323 String [] ret = new String [operations.length]; 324 for (int i=0; i<ret.length;i++) { 325 ret[i] = rew+"."+operations[i]; 326 } 327 return ret; 328 } 329 } 330 331 public String generateArchProtocol(DetectedConnectors dc) throws CDLExceptLock, CDLExceptRemote { 332 int i,j; 333 341 if (subcom.isNew) { 342 CompFrame fr = (CompFrame) getInstFrame(subcom, repository()).getRefferedObject(repository()); 343 java.util.ArrayList provReq = new java.util.ArrayList (); 344 CompContained[] cont = fr.contents(); 345 for (i=0;i<cont.length;i++) { 346 if (cont[i].objectKind() == ObjectsKind.o_Provides) { 347 350 provReq.add(new reProvReq(new String (this.getIdent().name), new String (cont[i].getIdent().name), ObjectsKind.o_Provides)); 351 } 353 if (cont[i].objectKind() == ObjectsKind.o_Requires) { 354 357 provReq.add(new reProvReq(new String (this.getIdent().name), new String (cont[i].getIdent().name), ObjectsKind.o_Requires)); 358 } 359 } 360 rewriteProt(provReq, dc); 362 return compFrameProtToArch(fr.protocol, provReq); 363 } else { 364 try { 365 FrameDef fr = (FrameDef) getInstFrame(subcom, repository()).getRefferedObject(repository()); 366 ProtocolDef protocol = fr.protocol(); 367 if (protocol == null) 368 return ""; 369 java.util.ArrayList provReq = new java.util.ArrayList (); 370 Contained[] contRep = fr.contents(null); 371 for (i=0;i<contRep.length;i++) { 372 if (contRep[i].get_def_kind().value() == DefinitionKind.dk_Provides) { 373 provReq.add(new reProvReq(new String (this.getIdent().name), new String (contRep[i].get_identification().name()), DefinitionKind.dk_Provides)); 374 } 376 if (contRep[i].get_def_kind().value() == DefinitionKind.dk_Requires) { 377 provReq.add(new reProvReq(new String (this.getIdent().name), new String (contRep[i].get_identification().name()), DefinitionKind.dk_Requires)); 378 } 379 } 380 rewriteProt(provReq, dc); 382 return normFrameProtToArch(protocol.protocol(), provReq); 383 } catch (RemoteException e) { 384 throw new CDLExceptRemote(e.getMessage()); 385 } catch (TIRExceptLock e) { 386 throw new CDLExceptLock(e.getMessage()); 387 } 388 } 389 } 390 391 void rewriteProt(java.util.ArrayList provReq, DetectedConnectors dc) { 393 int i,j; 394 CompContained[] cont = parent().contents(); 395 for(i=0;i<cont.length;i++) { 396 if (cont[i].objectKind() == ObjectsKind.o_Bind) { 397 CompBind bind = (CompBind) cont[i]; 398 String r1, r2, l1, l2; 399 int index; 400 DetectedConnector cn; 401 switch (bind.mode) { 402 case CompBind.m_delegate: 403 cn = dc.containsConnWithSRole(bind.rhs); 404 bind.rhs.subs.toFirst(); bind.rhs.elements.toFirst(); 405 r1 = ((CompBindType) bind.rhs.subs.aktual()).name; 406 r2 = ((CompBindType) bind.rhs.elements.aktual()).name; 407 for (j=0;j<provReq.size();j++) { 408 if ( ((reProvReq)provReq.get(j)).compareTo(r1,r2) ) { 409 bind.lhs.elements.toFirst(); 410 l1 = ((CompBindType) bind.lhs.elements.aktual()).name; 411 ((reProvReq)(provReq.get(j))).rew = "<"+l1+"-"+r1+":"+r2+">"; 412 413 break; 414 } 415 } 416 break; 417 case CompBind.m_subsume: 418 cn = dc.containsConnWithSRole(bind.rhs); 419 index = cn.indexOfCRole(bind.lhs); 420 bind.lhs.subs.toFirst(); bind.lhs.elements.toFirst(); 421 l1 = ((CompBindType) bind.lhs.subs.aktual()).name; 422 l2 = ((CompBindType) bind.lhs.elements.aktual()).name; 423 for (j=0;j<provReq.size();j++) { 424 if ( ((reProvReq)provReq.get(j)).compareTo(l1,l2) ) { 425 bind.rhs.elements.toFirst(); 426 r1 = ((CompBindType) bind.rhs.elements.aktual()).name; 427 ((reProvReq)(provReq.get(j))).rew = "<"+l1+":"+l2+"-"+r1+">"; 428 429 break; 430 } 431 } 432 break; 433 case CompBind.m_bind: 434 if (bind.rhs.kind==CompBindOper.b_sub && bind.lhs.kind==CompBindOper.b_sub) { 435 cn = dc.containsConnWithSRole(bind.rhs); 436 index = cn.indexOfCRole(bind.lhs); 437 bind.lhs.subs.toFirst(); bind.lhs.elements.toFirst(); 438 l1 = ((CompBindType) bind.lhs.subs.aktual()).name; 439 l2 = ((CompBindType) bind.lhs.elements.aktual()).name; 440 bind.rhs.subs.toFirst(); bind.rhs.elements.toFirst(); 441 r1 = ((CompBindType) bind.rhs.subs.aktual()).name; 442 r2 = ((CompBindType) bind.rhs.elements.aktual()).name; 443 for (j=0;j<provReq.size();j++) { 444 453 if (((reProvReq) provReq.get(j)).compareTo(l1,l2) && ((reProvReq) provReq.get(j)).type==ObjectsKind.o_Requires ) { 454 ((reProvReq)(provReq.get(j))).rew = "<"+l1+":"+l2+"-cRole"+Integer.toString(index)+">"; 455 } 456 if (((reProvReq) provReq.get(j)).compareTo(r1,r2) && ((reProvReq) provReq.get(j)).type==ObjectsKind.o_Provides ) { 457 ((reProvReq)(provReq.get(j))).rew = "<sRole0-"+r1+":"+r2+">"; 458 } 459 } 460 } 461 break; 462 } } 464 } } 466 467 public static String compFrameProtToArch(CompProtOper p, java.util.ArrayList names) { 468 StringBuffer sb = new StringBuffer (); 469 int i; 470 switch (p.type) { 471 case CompProtKind.p_operand: 472 CompProtOperand op = (CompProtOperand) p; 473 if (op.mode == CompProtMode.pm_in) 474 sb.append("?"); 475 else 476 sb.append("!"); 477 for (i=0;i<names.size();i++) { 478 if ( op.ifacename.compareTo(((reProvReq)(names.get(i))).origName) == 0 ) { 479 if (((reProvReq)(names.get(i))).rew != null) 480 sb.append(((reProvReq)(names.get(i))).rew); 481 else 482 sb.append("<"+((reProvReq)(names.get(i))).origName+">"); 483 } 484 } 485 sb.append("."); 486 sb.append(((CompProtOperand) p).operand); 487 break; 488 case CompProtKind.p_nulloperand: 489 sb.append("NULL"); 490 break; 491 case CompProtKind.p_metaoperand: 492 sb.append("["); 493 sb.append(((CompProtMetaOperand) p).name); 494 sb.append("]"); 495 break; 496 case CompProtKind.p_nestedoperand: 497 CompProtNestedOperand nop = (CompProtNestedOperand) p; 498 if (nop.mode == CompProtMode.pm_in) 499 sb.append("?"); 500 else 501 sb.append("!"); 502 for (i=0;i<names.size();i++) { 503 if ( nop.ifacename.compareTo(((reProvReq)(names.get(i))).origName) == 0 ) { 504 if (((reProvReq)(names.get(i))).rew != null) 505 sb.append(((reProvReq)(names.get(i))).rew); 506 else 507 sb.append("<"+((reProvReq)(names.get(i))).origName+">"); 508 break; 509 } 510 } 511 sb.append("."); 512 sb.append(nop.operand); 513 sb.append("{"); 514 sb.append(compFrameProtToArch(nop.nestOperand, names)); 515 sb.append("}"); 516 break; 517 case CompProtKind.p_repetition: 518 sb.append("("); 519 sb.append(compFrameProtToArch(((CompProtUnOper) p).operand, names)); 520 sb.append(")*"); 521 break; 522 case CompProtKind.p_andparallel: 523 sb.append("("); 524 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand1, names)); 525 sb.append(")|("); 526 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand2, names)); 527 sb.append(")"); 528 break; 529 case CompProtKind.p_orparallel: 530 sb.append("("); 531 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand1, names)); 532 sb.append(")||("); 533 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand2, names)); 534 sb.append(")"); 535 break; 536 case CompProtKind.p_alternative: 537 sb.append("("); 538 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand1, names)); 539 sb.append(")+("); 540 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand2, names)); 541 sb.append(")"); 542 break; 543 case CompProtKind.p_sequence: 544 sb.append("("); 545 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand1, names)); 546 sb.append(");("); 547 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand2, names)); 548 sb.append(")"); 549 break; 550 case CompProtKind.p_restriction: 551 sb.append("("); 552 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand1, names)); 553 sb.append(")/("); 554 sb.append(compFrameProtToArch(((CompProtBinOper) p).operand2, names)); 555 sb.append(")"); 556 break; 557 default: break; 558 } 559 return sb.toString(); 560 } 561 562 public static String normFrameProtToArch(ProtocolOperDef p, java.util.ArrayList names) throws RemoteException { 563 StringBuffer sb = new StringBuffer (); 564 int i; 565 String ifacename; 566 switch (p.get_po_kind().value()) { 567 case ProtocolOperKind.pok_operand: 568 ProtocolOperandDef op = (ProtocolOperandDef) p; 569 if (op.operand_mode().value() == ProtocolMode.pm_in) 570 sb.append("?"); 571 else 572 sb.append("!"); 573 ifacename = op.operand()[0]; 574 for (i=0;i<names.size();i++) { 575 if ( ifacename.compareTo(((reProvReq)(names.get(i))).origName) == 0 ) { 576 if (((reProvReq)(names.get(i))).rew != null) 577 sb.append(((reProvReq)(names.get(i))).rew); 578 else 579 sb.append("<"+((reProvReq)(names.get(i))).origName+">"); 580 } 581 } 582 sb.append("."); 583 sb.append(op.operand()[1]); 584 break; 585 case ProtocolOperKind.pok_nulloperand: 586 sb.append("NULL"); 587 break; 588 case ProtocolOperKind.pok_metaoperand: 589 sb.append("["); 590 sb.append(((ProtocolMetaOperandDef)p).name()); 591 sb.append("]"); 592 break; 593 case ProtocolOperKind.pok_nestedoperand: 594 ProtocolNestedOperandDef nop = (ProtocolNestedOperandDef) p; 595 if (nop.operand_mode().value() == ProtocolMode.pm_in) 596 sb.append("?"); 597 else 598 sb.append("!"); 599 ifacename = nop.operand()[0]; 600 for (i=0;i<names.size();i++) { 601 if ( ifacename.compareTo(((reProvReq)(names.get(i))).origName) == 0 ) { 602 if (((reProvReq)(names.get(i))).rew != null) 603 sb.append(((reProvReq)(names.get(i))).rew); 604 else 605 sb.append("<"+((reProvReq)(names.get(i))).origName+">"); 606 } 607 } 608 sb.append("."); 609 sb.append(nop.operand()[1]); 610 sb.append("{"); 611 sb.append(normFrameProtToArch(nop.nested_operand(), names)); 612 sb.append("}"); 613 break; 614 case ProtocolOperKind.pok_repetition: 615 sb.append("("); 616 sb.append(normFrameProtToArch(((ProtocolUnOperationDef) p).operand(), names)); 617 sb.append(")*"); 618 break; 619 case ProtocolOperKind.pok_andparallel: 620 sb.append("("); 621 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand1(), names)); 622 sb.append(")|("); 623 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand2(), names)); 624 sb.append(")"); 625 break; 626 case ProtocolOperKind.pok_orparallel: 627 sb.append("("); 628 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand1(), names)); 629 sb.append(")||("); 630 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand2(), names)); 631 sb.append(")"); 632 break; 633 case ProtocolOperKind.pok_alternative: 634 sb.append("("); 635 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand1(), names)); 636 sb.append(")+("); 637 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand2(), names)); 638 sb.append(")"); 639 break; 640 case ProtocolOperKind.pok_sequence: 641 sb.append("("); 642 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand1(), names)); 643 sb.append(");("); 644 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand2(), names)); 645 sb.append(")"); 646 break; 647 case ProtocolOperKind.pok_restriction: 648 sb.append("("); 649 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand1(), names)); 650 sb.append(")/("); 651 sb.append(normFrameProtToArch(((ProtocolBinOperationDef) p).operand2(), names)); 652 sb.append(")"); 653 break; 654 default: break; 655 } 656 return sb.toString(); 657 } 658 659 static String [] getNormFrameProvideOperations(ProvideDef provide, CompRepository repository) throws CDLExceptLock, CDLExceptRemote { 660 try { 661 InterfaceDef iface = (InterfaceDef) provide.provide(); 662 CompReffer ref = new CompReffer(); 663 ref.isNew = false; 664 ref.what = DefinitionKind.dk_Interface; 665 ref.ref = new FullID(true); 666 Identification idl; 667 ref.ref.name = new String ((idl = iface.get_identification()).name()); 668 ref.ref.version = new String (idl.version()); 669 ref.ref.isin = IDKind.version; 670 AbsoluteName abs = idl.absolute_name(); 671 for(int j=0;j<abs.size()-1;j++) { 672 ref.ref.sn.addScope(new String (abs.elementAt(j))); 673 } 674 EnumList ret = CompProvide.ifaceOperations(ref,repository); 675 if (ret==null) 676 return null; 677 else 678 return ret.toArray(); 679 } catch (RemoteException e) { 680 throw new CDLExceptRemote(e.getMessage()); 681 } 682 } 683 684 static String [] getNormFrameRequireOperations(RequireDef require, CompRepository repository) throws CDLExceptLock, CDLExceptRemote { 685 try { 686 InterfaceDef iface = (InterfaceDef) require.require(); 687 CompReffer ref = new CompReffer(); 688 ref.isNew = false; 689 ref.what = DefinitionKind.dk_Interface; 690 ref.ref = new FullID(true); 691 Identification idl; 692 ref.ref.name = new String ((idl = iface.get_identification()).name()); 693 ref.ref.version = new String (idl.version()); 694 ref.ref.isin = IDKind.version; 695 AbsoluteName abs = idl.absolute_name(); 696 for(int j=0;j<abs.size()-1;j++) { 697 ref.ref.sn.addScope(new String (abs.elementAt(j))); 698 } 699 EnumList ret = CompProvide.ifaceOperations(ref,repository); 700 if (ret==null) 701 return null; 702 else 703 return ret.toArray(); 704 } catch (RemoteException e) { 705 throw new CDLExceptRemote(e.getMessage()); 706 } 707 } 708 709 710 public static CompReffer getInstFrame(CompReffer what, CompRepository inRep) throws CDLExceptLock, CDLExceptRemote { 711 boolean ok = false; 712 int kind = what.what; 713 CompReffer r = what; 714 while (!ok) { 715 if (kind != ObjectsKind.o_Frame) { 716 if (kind == ObjectsKind.o_Typedef || kind == ObjectsKind.o_Array) { 717 int i,j; 718 FullID id = r.ref; 719 if (r.isNew) { CompContainer con = inRep; 721 id.sn.names.toFirst(); 722 for(i=0;i<id.sn.names.size();i++) { 723 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 724 if (a==null || a.length==0) { 725 return null; 726 } 727 if (a.length==1) { 728 if (a[0].isContainer()) con = (CompContainer) a[0]; 729 else { 730 return null; 731 } 732 } else { 733 return null; 734 } 735 id.sn.names.toNext(); 736 } 737 CompContained sec = con.lookup(id.name, id.version); 738 if (sec!=null) { 739 CompType sectype = ((CompTypedef) sec).type; 740 if (sectype.objectKind() != ObjectsKind.o_Frame) { 741 if (sectype.objectKind()==ObjectsKind.o_none) { r = (CompReffer) sectype; 743 kind = r.what; 744 } else { 745 if (sectype.objectKind()==ObjectsKind.o_Array) { 746 while (sectype.objectKind()==ObjectsKind.o_Array) { 747 sectype = ((CompArray) sectype).type; 748 } 749 if (sectype.objectKind() != ObjectsKind.o_none) { 750 if (sectype.objectKind() == ObjectsKind.o_Frame) { 751 r = (CompReffer) sectype; 752 ok = true; 753 } else { 754 return null; 755 } 756 } else { 757 r = (CompReffer) sectype; 758 kind = r.what; 759 } 760 } else { 761 return null; 762 } 763 } 764 } else { 765 r = (CompReffer) sectype; 766 ok = true; 767 } 768 } else { 769 return null; 770 } 771 } else { try { 773 Container con = inRep.cdlRepository; 774 id.sn.names.toFirst(); 775 for(i=0;i<id.sn.names.size();i++) { 776 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 777 if (a==null || a.length==0) { 778 return null; 779 } 780 if (a.length==1) { 781 if (a[0] instanceof Container) con = (Container) a[0]; 782 else { 783 return null; 784 } 785 } else { 786 boolean found = false; 787 for(j=0;j<a.length;j++) { 788 if (a[j].get_identification().version().compareTo(id.version)==0) { 789 if ( !(a[j] instanceof Container)) { 790 return null; 791 } 792 found = true; 793 con = (Container) a[j]; 794 break; 795 } 796 } 797 if (!found) { 798 return null; 799 } 800 } 801 id.sn.names.toNext(); 802 } 803 Contained sec = con.lookup(id.name, id.version); 804 if (sec!=null) { 805 CDLType sectype = ((TypedefDef) sec).original_type(); 806 if (sectype.get_def_kind().value() != DefinitionKind.dk_Interface) { 807 if (sectype.get_def_kind().value() == DefinitionKind.dk_Typedef) { 808 CompReffer ret = new CompReffer(); 809 ret.what = sectype.get_def_kind().value(); 810 ret.ref = new FullID(true); 811 Identification idl; 812 ret.ref.name = new String ((idl = ((TypedefDef)sectype).get_identification()).name()); 813 ret.ref.version = new String (idl.version()); 814 ret.ref.isin = IDKind.version; 815 ret.isNew = false; 816 AbsoluteName abs = idl.absolute_name(); 817 for(j=0;j<abs.size();j++) { 818 ret.ref.sn.addScope(new String (abs.elementAt(j))); 819 } 820 r = ret; 821 kind = r.what; 822 } else { 823 if (sectype.get_def_kind().value()==DefinitionKind.dk_Array) { 824 while (sectype.get_def_kind().value()==DefinitionKind.dk_Array) { 825 sectype = ((ArrayDef) sectype).element_type(); 826 } 827 if (sectype.get_def_kind().value()!=DefinitionKind.dk_Typedef) { 828 if (sectype.get_def_kind().value()==DefinitionKind.dk_Interface) { 829 CompReffer ret = new CompReffer(); 830 ret.what = sectype.get_def_kind().value(); 831 ret.ref = new FullID(true); 832 Identification idl; 833 ret.ref.name = new String ((idl = ((TypedefDef)sectype).get_identification()).name()); 834 ret.ref.version = new String (idl.version()); 835 ret.ref.isin = IDKind.version; 836 ret.isNew = false; 837 AbsoluteName abs = idl.absolute_name(); 838 for(j=0;j<abs.size();j++) { 839 ret.ref.sn.addScope(new String (abs.elementAt(j))); 840 } 841 r = ret; 842 ok = true; 843 } else { 844 return null; 845 } 846 } else { 847 CompReffer ret = new CompReffer(); 848 ret.what = sectype.get_def_kind().value(); 849 ret.ref = new FullID(true); 850 Identification idl; 851 ret.ref.name = new String ((idl = ((TypedefDef)sectype).get_identification()).name()); 852 ret.ref.version = new String (idl.version()); 853 ret.ref.isin = IDKind.version; 854 ret.isNew = false; 855 AbsoluteName abs = idl.absolute_name(); 856 for(j=0;j<abs.size();j++) { 857 ret.ref.sn.addScope(new String (abs.elementAt(j))); 858 } 859 r = ret; 860 kind = r.what; 861 } 862 } else { 863 return null; 864 } 865 } 866 } else { 867 CompReffer ret = new CompReffer(); 868 ret.what = sectype.get_def_kind().value(); 869 ret.ref = new FullID(true); 870 Identification idl; 871 ret.ref.name = new String ((idl = ((TypedefDef)sectype).get_identification()).name()); 872 ret.ref.version = new String (idl.version()); 873 ret.ref.isin = IDKind.version; 874 ret.isNew = false; 875 AbsoluteName abs = idl.absolute_name(); 876 for(j=0;j<abs.size();j++) { 877 ret.ref.sn.addScope(new String (abs.elementAt(j))); 878 } 879 r = ret; 880 ok = true; 881 } 882 } else { 883 return null; 884 } 885 } catch (TIRExceptLock e) { 886 throw new CDLExceptLock("Repository is locked."); 887 } catch (RemoteException e) { 888 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 889 } 890 } 891 } else { 892 return null; 893 } 894 } else { 895 ok = true; 896 } 897 } 898 return r; 899 } 900 } 901 | Popular Tags |