1 2 package SOFA.SOFAnode.Made.CDL; 3 import java.io.IOException ; 4 import java.rmi.Naming ; 5 import java.rmi.RemoteException ; 6 7 import SOFA.SOFAnode.Made.TIR.ArchitectureDef; 8 import SOFA.SOFAnode.Made.TIR.CDLContainer; 9 import SOFA.SOFAnode.Made.TIR.CDLRepository; 10 import SOFA.SOFAnode.Made.TIR.ConstantDef; 11 import SOFA.SOFAnode.Made.TIR.Contained; 12 import SOFA.SOFAnode.Made.TIR.Container; 13 import SOFA.SOFAnode.Made.TIR.DefinitionKind; 14 import SOFA.SOFAnode.Made.TIR.EnumDef; 15 import SOFA.SOFAnode.Made.TIR.EnumMember; 16 import SOFA.SOFAnode.Made.TIR.ExceptionDef; 17 import SOFA.SOFAnode.Made.TIR.FrameDef; 18 import SOFA.SOFAnode.Made.TIR.Identification; 19 import SOFA.SOFAnode.Made.TIR.InterfaceDef; 20 import SOFA.SOFAnode.Made.TIR.ModuleDef; 21 import SOFA.SOFAnode.Made.TIR.ProfileDef; 22 import SOFA.SOFAnode.Made.TIR.ProviderDef; 23 import SOFA.SOFAnode.Made.TIR.Repository; 24 import SOFA.SOFAnode.Made.TIR.StructDef; 25 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit; 26 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate; 27 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 28 import SOFA.SOFAnode.Made.TIR.TypedefDef; 29 import SOFA.SOFAnode.Made.TIR.UnionDef; 30 import SOFA.SOFAnode.Made.TIR.WorkRepository; 31 32 class CompRepository extends CompContainerIm { 33 class CompRepExcept extends Exception { 34 public CompRepExcept() { super(); } 35 public CompRepExcept(String s) { super(s); } 36 } 37 38 public Repository defRepository; 39 public WorkRepository workRepository; 40 public CDLRepository cdlRepository; public ProfileDef profile; 42 43 public Scopename aktScope; 44 45 public List defaultTypes; 46 47 public String searchError; 48 49 public boolean useProtocols; public boolean testProtocols; 52 public SOFA.SOFAnode.Util.BehaviorProtocolChecker protocolChecker; 53 54 public CompRepository(Scopename aktScope) throws Exception { 55 super(ObjectsKind.o_Repository); 56 this.aktScope = aktScope; 57 58 String rmiport = System.getProperty("tir.rmiport","1099"); 59 String rmihost = System.getProperty("tir.rmihost","localhost"); 60 defRepository = (Repository) Naming.lookup("//"+rmihost+":"+rmiport+"/Repository"); 61 62 boolean ok = false; 63 int i = 0; 64 65 String profName = System.getProperty("cdl.profile",null); 66 while (!ok) { 67 try { 68 if (profName==null) 69 profile = null; 70 else { 71 profile = defRepository.getProfiles().lookup(profName); 72 if (profile == null) 73 throw new CDLExceptBadName("Profile with name "+profName+" doesn't exist."); 74 } 75 ok = true; 76 } catch (TIRExceptLock e) { 77 if (i == Consts.repeatCount) 78 throw new CDLExceptLock("Repository is locked."); 79 else { 80 i++; 81 System.err.println("Repository is locked. Waiting for next attempt."); 82 Thread.sleep(Consts.repeatDelay); 83 } 84 } 85 } 86 87 ok = false; 88 i = 0; 89 while (!ok) { 90 try { 91 if (System.getProperty("cdl.debug","no").compareTo("yes")==0) { 92 System.out.println(java.util.Calendar.getInstance().getTime().getTime()); 93 workRepository = defRepository.beginChanges(profile); 94 System.out.println(java.util.Calendar.getInstance().getTime().getTime()); 95 } else { 96 workRepository = defRepository.beginChanges(profile); 97 } 98 profile = workRepository.profile(); 99 ok = true; 100 } catch (TIRExceptLock e) { 101 if (i == Consts.repeatCount) 102 throw new CDLExceptLock("Repository is locked."); 103 else { 104 i++; 105 System.err.println("Repository is locked. Waiting for next attempt."); 106 Thread.sleep(Consts.repeatDelay); 107 } 108 } 109 } 110 111 cdlRepository = (CDLRepository) workRepository.lookup("cdl",""); 112 113 useProtocols = false; 114 testProtocols = false; 115 String prot = System.getProperty("cdl.protocols","no"); 116 if (prot.compareTo("yes")==0) 117 useProtocols = true; 118 prot = System.getProperty("cdl.testprotocols","no"); 119 if (prot.compareTo("yes")==0) { 120 useProtocols = true; 121 testProtocols = true; 122 } 123 124 defaultTypes = new List(); 125 searchError = null; 126 127 protocolChecker = SOFA.SOFAnode.Util.BehaviorProtocolCheckerFactory.getChecker(System.getProperty("cdl.protocolChecker",null)); 128 } 129 130 131 public CompRepository(Scopename aktScope, Repository defRep, WorkRepository workRep, boolean useProt, boolean testProt) throws Exception { 132 super(ObjectsKind.o_Repository); 133 this.aktScope = aktScope; 134 135 defRepository = defRep; 136 137 workRepository = workRep; 138 profile = workRepository.profile(); 139 cdlRepository = (CDLRepository) workRepository.lookup("cdl",""); 140 141 useProtocols = useProt; 142 testProtocols = testProt; 143 if (testProt) { 144 useProtocols = true; 145 System.setProperty("cdl.protocols","yes"); 146 System.setProperty("cdl.testprotocols","yes"); 147 } else { 148 System.setProperty("cdl.testprotocols","no"); 149 if (useProtocols) 150 System.setProperty("cdl.protocols","yes"); 151 else 152 System.setProperty("cdl.protocols","no"); 153 } 154 155 defaultTypes = new List(); 156 searchError = null; 157 158 protocolChecker = SOFA.SOFAnode.Util.BehaviorProtocolCheckerFactory.getChecker(System.getProperty("cdl.protocolChecker",null)); 159 } 160 161 public void checkConsist(EnumList props, CompRepository rep) throws CDLExceptCheck, CDLExceptLock, CDLExceptRemote { 162 CompContained[] cont = contents(); 163 for (int i=0;i<cont.length;i++) { 164 switch (cont[i].objectKind()) { 165 case ObjectsKind.o_Module: 166 cont[i].checkConsist(null,rep); 167 break; 168 case ObjectsKind.o_Interface: 169 cont[i].checkConsist(null,rep); 170 break; 171 case ObjectsKind.o_Frame: 172 try { 173 cont[i].checkConsist(null,rep); 174 } catch (CDLExceptCheck e) { 175 throw new CDLExceptCheck(e.getMessage()+" in frame "+cont[i].fullName()); 176 } 177 break; 178 case ObjectsKind.o_Provider: 179 cont[i].checkConsist(null,rep); 180 } 181 } 182 } 183 184 249 250 public CompReffer searchReffer(String name, String version) throws CDLExceptLock, CDLExceptRemote { 251 if (name!=null && name.length()!=0) { 252 FullID id = null; 254 if (name.charAt(0)==':') { 255 if (aktScope.length()==0) 256 id = new FullID ("::"+name , version); 257 else 258 id = new FullID (aktScope.toString()+"::"+name , version); 259 } else { 260 id = new FullID (name, version); 261 } 262 return searchReffer(id); 263 } else 264 return null; 265 } 266 267 279 280 292 293 public CompReffer searchReffer(FullID id) throws CDLExceptLock, CDLExceptRemote { 294 return searchReffer(id, 0); 295 } 296 297 300 public CompReffer searchReffer(FullID id, int cancelNameSpace) throws CDLExceptLock, CDLExceptRemote { 301 int i,j; 302 long numPath = 0; 303 if (!id.isAbsolute) { 305 FullID nid = new FullID(true); 307 aktScope.names.toFirst(); 308 for(i=0;i<aktScope.length()-cancelNameSpace;i++) { 309 nid.sn.addScope((String )aktScope.names.aktual()); 310 aktScope.names.toNext(); 311 } 312 numPath = aktScope.length(); 313 id.sn.names.toFirst(); 314 for(i=0;i<id.sn.length();i++) { 315 nid.sn.addScope((String )id.sn.names.aktual()); 316 id.sn.names.toNext(); 317 } 318 nid.name = id.name; 319 nid.setVersion(id.version); 320 id = nid; 321 } 322 325 switch (id.isin) { 326 case IDKind.none : return searchRefferDefault(id, numPath); 327 case IDKind.version : return searchRefferVersion(id, numPath); 328 case IDKind.tag : return searchRefferTag(id, numPath); 329 } 330 return null; 331 } 332 333 private CompReffer searchRefferVersion(FullID id, long numPath) throws CDLExceptLock, CDLExceptRemote { 334 int i,j; 335 336 try { 337 CompContainer con = this; 339 id.sn.names.toFirst(); 340 for(i=0;i<id.sn.names.size();i++) { 341 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 342 if (a==null || a.length==0) 343 throw new CompRepExcept(); 344 if (a.length==1) { 345 if (a[0].isContainer()) con = (CompContainer) a[0]; 346 else throw new CompRepExcept(); 347 } else { 348 boolean found = false; 349 for(j=0;j<a.length;j++) { 350 if (a[j].getIdent().version.compareTo(id.version)==0) { 351 if ( ! a[j].isContainer()) throw new CompRepExcept(); 352 found = true; 353 con = (CompContainer) a[j]; 354 break; 355 } 356 } 357 if (!found) throw new CompRepExcept(); 358 } 359 id.sn.names.toNext(); 360 } 361 CompContained sec = con.lookup(id.name, id.version); 362 if (sec!=null) { 363 CompReffer ret = new CompReffer(); 364 ret.what = sec.objectKind(); 365 ret.ref = new FullID(true); 366 ret.ref.name = new String (id.name); 367 ret.ref.version = new String (id.version); 368 ret.ref.isin = IDKind.version; 369 ret.isNew = true; 370 id.sn.names.toFirst(); 371 for(j=0;j<id.sn.names.size();j++) { 372 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 373 id.sn.names.toNext(); 374 } 375 if (ret.what == ObjectsKind.o_Frame) 376 ret.isSystem = ((CompFrame)sec).isSystem; 377 if (ret.what == ObjectsKind.o_Architecture) 378 ret.isSystem = ((CompArchitecture)sec).isSystem; 379 return ret; 380 } 381 } catch (CompRepExcept e) {;} 383 384 try { 386 Container con = cdlRepository; 387 id.sn.names.toFirst(); 388 for(i=0;i<id.sn.names.size();i++) { 389 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 390 if (a==null || a.length==0) 391 throw new CompRepExcept(); 392 if (a.length==1) { 393 if (a[0] instanceof Container) con = (Container) a[0]; 395 else throw new CompRepExcept(); 396 } else { 397 boolean found = false; 398 for(j=0;j<a.length;j++) { 399 if (a[j].get_identification().version().compareTo(id.version)==0) { 400 if ( !(a[j] instanceof Container)) throw new CompRepExcept(); 401 found = true; 402 con = (Container) a[j]; 403 break; 404 } 405 } 406 if (!found) throw new CompRepExcept(); 407 } 408 id.sn.names.toNext(); 409 } 410 Contained sec = con.lookup(id.name, id.version); 411 if (sec!=null) { 412 CompReffer ret = new CompReffer(); 413 ret.what = sec.get_def_kind().value(); 414 ret.ref = new FullID(true); 415 ret.ref.name = new String (id.name); 416 ret.ref.version = new String (id.version); 417 ret.ref.isin = IDKind.version; 418 ret.isNew = false; 419 id.sn.names.toFirst(); 420 for(j=0;j<id.sn.names.size();j++) { 421 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 422 id.sn.names.toNext(); 423 } 424 if (ret.what == DefinitionKind.dk_Frame) 425 ret.isSystem = ((FrameDef)sec).is_system(); 426 if (ret.what == DefinitionKind.dk_Architecture) 427 ret.isSystem = ((ArchitectureDef)sec).is_system(); 428 return ret; 429 } 430 431 } catch (TIRExceptLock e) { 432 throw new CDLExceptLock("Repository is locked."); 433 } catch (RemoteException e) { 434 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 435 } catch (CompRepExcept e) {;} 436 438 441 if (numPath > 0) { 443 id.sn.names.toFirst(); 444 for(i=1; i<numPath; i++) 445 id.sn.names.toNext(); 446 id.sn.names.removeAkt(); 447 return searchRefferVersion(id, numPath-1); 448 } else { 449 searchError = id.name + ":" + id.version + " doesn't exist"; 450 return null; 451 } 452 } 453 454 private CompReffer searchRefferTag(FullID id, long numPath) throws CDLExceptLock, CDLExceptRemote { 455 int i,j; 456 457 try { 458 CompContainer con = this; 460 id.sn.names.toFirst(); 461 for(i=0;i<id.sn.names.size();i++) { 462 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 463 if (a==null || a.length==0) 464 throw new CompRepExcept(); 465 if (a.length==1) { 466 if (a[0].isContainer()) con = (CompContainer) a[0]; 467 else throw new CompRepExcept(); 468 } else { 469 throw new CompRepExcept(); 470 } 471 id.sn.names.toNext(); 472 } 473 CompContained sec = con.lookupTag(id.name, id.tag); 474 if (sec!=null) { 475 CompReffer ret = new CompReffer(); 476 ret.what = sec.objectKind(); 477 ret.ref = new FullID(true); 478 ret.ref.name = new String (id.name); 479 ret.ref.version = new String (sec.getIdent().version); 480 ret.ref.isin = IDKind.version; 481 ret.isNew = true; 482 id.sn.names.toFirst(); 483 for(j=0;j<id.sn.names.size();j++) { 484 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 485 id.sn.names.toNext(); 486 } 487 if (ret.what == ObjectsKind.o_Frame) 488 ret.isSystem = ((CompFrame)sec).isSystem; 489 if (ret.what == ObjectsKind.o_Architecture) 490 ret.isSystem = ((CompArchitecture)sec).isSystem; 491 return ret; 492 } 493 } catch (CompRepExcept e) {;} 495 496 try { 498 Container con = cdlRepository; 499 id.sn.names.toFirst(); 500 for(i=0;i<id.sn.names.size();i++) { 501 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 502 if (a==null || a.length==0) 503 throw new CompRepExcept(); 504 if (a.length==1) { 505 if (a[0] instanceof Container) con = (Container) a[0]; 506 else throw new CompRepExcept(); 507 } else { 508 throw new CompRepExcept(); 509 } 510 id.sn.names.toNext(); 511 } 512 Contained sec = con.lookup_tag(id.name, id.tag); 513 if (sec!=null) { 514 CompReffer ret = new CompReffer(); 515 ret.what = sec.get_def_kind().value(); 516 ret.ref = new FullID(true); 517 ret.ref.name = new String (id.name); 518 ret.ref.version = new String (sec.get_identification().version()); 519 ret.ref.isin = IDKind.version; 520 ret.isNew = false; 521 id.sn.names.toFirst(); 522 for(j=0;j<id.sn.names.size();j++) { 523 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 524 id.sn.names.toNext(); 525 } 526 if (ret.what == DefinitionKind.dk_Frame) 527 ret.isSystem = ((FrameDef)sec).is_system(); 528 if (ret.what == DefinitionKind.dk_Architecture) 529 ret.isSystem = ((ArchitectureDef)sec).is_system(); 530 return ret; 531 } 532 533 } catch (TIRExceptLock e) { 534 throw new CDLExceptLock("Repository is locked."); 535 } catch (RemoteException e) { 536 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 537 } catch (CompRepExcept e) {;} 538 540 if (numPath > 0) { 544 id.sn.names.toFirst(); 545 for(i=1; i<numPath; i++) 546 id.sn.names.toNext(); 547 id.sn.names.removeAkt(); 548 return searchRefferTag(id, numPath-1); 549 } else { 550 searchError = id.name + ":" + id.version + " doesn't exist"; 551 return null; 552 } 553 } 554 555 private CompReffer searchRefferDefault(FullID id, long numPath) throws CDLExceptLock, CDLExceptRemote { 556 int i,j; 558 559 try { 561 562 CompContainer con = this; 563 id.sn.names.toFirst(); 564 for(i=0;i<id.sn.names.size();i++) { 565 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 566 if (a==null || a.length==0) 567 throw new CompRepExcept(); 568 if (a.length==1) { 569 if (a[0].isContainer()) con = (CompContainer) a[0]; 570 else throw new CompRepExcept(); 571 } else { 572 throw new CompRepExcept(); 573 } 574 id.sn.names.toNext(); 575 } 576 CompContained[] sec = con.lookup(id.name); 577 if (sec!=null && sec.length!=0) { 578 if (sec.length==1) { 579 CompReffer ret = new CompReffer(); 580 ret.what = sec[0].objectKind(); 581 ret.ref = new FullID(true); 582 ret.ref.name = new String (id.name); 583 ret.ref.version = new String (sec[0].getIdent().version); 584 ret.ref.isin = IDKind.version; 585 ret.isNew = true; 586 id.sn.names.toFirst(); 587 for(j=0;j<id.sn.names.size();j++) { 588 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 589 id.sn.names.toNext(); 590 } 591 if (ret.what == ObjectsKind.o_Frame) 592 ret.isSystem = ((CompFrame)sec[0]).isSystem; 593 if (ret.what == ObjectsKind.o_Architecture) 594 ret.isSystem = ((CompArchitecture)sec[0]).isSystem; 595 596 return ret; 597 } else { 598 searchError = "it never should be here"; 599 return null; 600 } 601 } 602 } catch (CompRepExcept e) {;} 604 605 try { 607 if (profile != null) { 608 Identification idl = profile.lookup(id.langToString()); 609 if (idl != null) { 610 CompReffer ret = new CompReffer(); 611 ret.ref = new FullID(true); 612 ret.ref.name = new String (idl.name()); 613 ret.ref.version = new String (idl.version()); 614 ret.ref.isin = IDKind.version; 615 ret.isNew = false; 616 id.sn.names.toFirst(); 617 for(j=0;j<id.sn.names.size();j++) { 618 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 619 id.sn.names.toNext(); 620 } 621 try { Container con = cdlRepository; 623 id.sn.names.toFirst(); 624 for(i=0;i<id.sn.names.size();i++) { 625 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 626 if (a==null || a.length==0) { 627 throw new CompRepExcept(); 628 } 629 if (a.length==1) { 630 if (a[0] instanceof Container) con = (Container) a[0]; 631 else { 632 throw new CompRepExcept(); 633 } 634 } else { 635 boolean found = false; 636 for(j=0;j<a.length;j++) { 637 if (a[j].get_identification().version().compareTo(idl.version())==0) { 638 if ( !(a[j] instanceof Container)) { 639 throw new CompRepExcept(); 640 } 641 found = true; 642 con = (Container) a[j]; 643 break; 644 } 645 } 646 if (!found) { 647 throw new CompRepExcept(); 648 } 649 } 650 id.sn.names.toNext(); 651 } 652 Contained sec = con.lookup_lastinbranch(id.name, ""); 653 if (sec!=null) { 654 ret.what = sec.get_def_kind().value(); 655 } 656 if (ret.what == DefinitionKind.dk_Frame) 657 ret.isSystem = ((FrameDef)sec).is_system(); 658 if (ret.what == DefinitionKind.dk_Architecture) 659 ret.isSystem = ((ArchitectureDef)sec).is_system(); 660 } catch (TIRExceptLock e) { 661 throw new CDLExceptLock("Repository is locked."); 662 } catch (RemoteException e) { 663 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 664 } catch (CompRepExcept e) { 665 searchError = "error in profile"; 666 return null; 667 } 668 return ret; 669 } 670 } 671 } catch (TIRExceptLock e) { 672 throw new CDLExceptLock("Repository is locked."); 673 } catch (RemoteException e) { 674 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 675 } 676 678 try { 680 Container con = cdlRepository; 681 id.sn.names.toFirst(); 682 for(i=0;i<id.sn.names.size();i++) { 683 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 684 if (a==null || a.length==0) 685 throw new CompRepExcept(); 686 if (a.length==1) { 687 if (a[0] instanceof Container) con = (Container) a[0]; 688 else throw new CompRepExcept(); 689 } else { 690 Contained last = con.lookup_lastinbranch((String ) id.sn.names.aktual(),""); 691 if (last == null) 692 throw new CompRepExcept(); 693 else 694 con = (Container) last; 695 705 } 706 id.sn.names.toNext(); 707 } 708 Contained sec = con.lookup_lastinbranch(id.name, ""); 709 if (sec!=null) { 710 CompReffer ret = new CompReffer(); 711 ret.what = sec.get_def_kind().value(); 712 ret.ref = new FullID(true); 713 ret.ref.name = new String (id.name); 714 ret.ref.version = new String (sec.get_identification().version()); 715 ret.ref.isin = IDKind.version; 716 ret.isNew = false; 717 id.sn.names.toFirst(); 718 for(j=0;j<id.sn.names.size();j++) { 719 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 720 id.sn.names.toNext(); 721 } 722 if (ret.what == DefinitionKind.dk_Frame) 723 ret.isSystem = ((FrameDef)sec).is_system(); 724 if (ret.what == DefinitionKind.dk_Architecture) 725 ret.isSystem = ((ArchitectureDef)sec).is_system(); 726 return ret; 727 } 728 729 } catch (TIRExceptLock e) { 730 throw new CDLExceptLock("Repository is locked."); 731 } catch (RemoteException e) { 732 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 733 } catch (CompRepExcept e) {;} 734 735 if (numPath > 0) { 737 id.sn.names.toFirst(); 738 for(i=1; i<numPath; i++) 739 id.sn.names.toNext(); 740 id.sn.names.removeAkt(); 741 742 CompReffer ret = searchRefferDefault(id, numPath-1); 743 744 747 return ret; 748 } else { 749 searchError = id.name + ":" + id.version + " doesn't exist"; 750 return null; 751 } 752 } 753 754 public CompModule searchExistNewMod(String name) { 755 Scopename fullname = new Scopename(); 756 int i; 757 aktScope.names.toFirst(); 758 for (i=0;i<aktScope.length();i++) { 759 fullname.addScope((String )aktScope.names.aktual()); 760 aktScope.names.toNext(); 761 } 762 fullname.addScope(name); 763 764 CompContainer con = this; 765 fullname.names.toFirst(); 766 for(i=0;i<fullname.names.size()-1;i++) { 767 CompContained[] a = con.lookup((String ) fullname.names.aktual()); 768 if (a==null || a.length==0) 769 return null; 770 if (a.length==1) { 771 if (a[0].isContainer()) con = (CompContainer) a[0]; 772 else { 773 return null; 774 } 775 } else { 776 return null; 777 } 778 fullname.names.toNext(); 779 } 780 CompContained sec[] = con.lookup((String ) fullname.names.aktual()); 781 if (sec!=null && sec.length!=0) { 782 if (sec[0].objectKind() == ObjectsKind.o_Module) { 783 return (CompModule) sec[0]; 784 } else { 785 return null; 786 } 787 } 788 return null; 789 } 790 791 public ID searchForNewMod(String name) throws CDLExceptLock, CDLExceptRemote { 793 searchError = null; 794 Scopename fullname = new Scopename(); 795 int i; 796 aktScope.names.toFirst(); 797 for (i=0;i<aktScope.length();i++) { 798 fullname.addScope((String )aktScope.names.aktual()); 799 aktScope.names.toNext(); 800 } 801 fullname.addScope(name); 802 803 try { 804 CompContainer con = this; 806 fullname.names.toFirst(); 807 for(i=0;i<fullname.names.size()-1;i++) { 808 CompContained[] a = con.lookup((String ) fullname.names.aktual()); 809 if (a==null || a.length==0) 810 throw new CompRepExcept(); 811 if (a.length==1) { 812 if (a[0].isContainer()) con = (CompContainer) a[0]; 813 else { 814 searchError = "This absolute name can not be module"; 815 return null; 816 } 817 } else { 818 searchError = "This absolute name can not be module"; 819 return null; 820 } 821 fullname.names.toNext(); 822 } 823 CompContained sec[] = con.lookup((String ) fullname.names.aktual()); 824 if (sec!=null && sec.length!=0) { 825 if (sec[0].objectKind() != ObjectsKind.o_Module) { 826 searchError = "Object with this name and other kind exists"; 827 return null; 828 } else { return null; 830 } 831 } else { sec = con.contents(); 833 for (i=0;i<sec.length;i++) { if (sec[i].objectKind()==ObjectsKind.o_Enum) { 835 if (((CompEnum) sec[i]).members.isIn((String ) fullname.names.aktual())) { 836 searchError = "Object with this name and other kind exists"; 837 return null; 838 } 839 } 840 } 841 } 842 } catch (CompRepExcept e) {;} 844 845 try { 847 Container con = cdlRepository; 848 fullname.names.toFirst(); 849 for(i=0;i<fullname.names.size()-1;i++) { 850 Contained[] a = con.lookup_name((String ) fullname.names.aktual()); 851 if (a==null || a.length==0) 852 throw new CompRepExcept(); 853 if (a.length==1) { 854 if (a[0] instanceof Container) con = (Container) a[0]; 855 else { 856 searchError = "This absolute name can not be module"; 857 return null; 858 } 859 } else { 860 searchError = "This absolute name can not be module"; 861 return null; 862 } 863 fullname.names.toNext(); 864 } 865 Contained[] sec = con.lookup_name((String ) fullname.names.aktual()); 866 if (sec!=null && sec.length!=0) { 867 if (sec[0].get_def_kind().value() == DefinitionKind.dk_Module) { 868 ID ret = null; 869 try { 870 Identification idl = sec[0].get_identification(); 871 ret = new ID (idl.name(), idl.version()); 872 } catch (RemoteException e) { 873 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 874 } 875 ret.exist = true; 876 ret.id = null; 877 ret.what = ObjectsKind.o_Module; 878 return ret; 879 } else { 880 searchError = "Object with this name exists in the repository."; 881 return null; 882 } 883 } else { DefinitionKind endk = workRepository.get_spec_def_kind(DefinitionKind.dk_Enum); 885 sec = con.contents(endk); 886 for (i=0;i<sec.length;i++) { 887 EnumMember[] membs = ((EnumDef) sec[i]).members(); 888 for (int j=0;j<membs.length;j++) { 889 if (membs[j].name().compareTo((String ) fullname.names.aktual())==0) { 890 searchError = "Object with this name exists in the repository."; 891 return null; 892 } 893 } 894 } 895 } 896 897 } catch (TIRExceptLock e) { 898 throw new CDLExceptLock("Repository is locked."); 899 } catch (RemoteException e) { 900 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 901 } catch (CompRepExcept e) {;} 902 904 Identification newVer = null; 905 try { 906 newVer = workRepository.create_identification(ID.lang, fullname.toString(),""); 907 } catch (TIRExceptCreate e) { 908 searchError = "Can't create identification"; 909 return null; 910 } catch (RemoteException e) { 911 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 912 } 913 ID ret = null; 914 try { 915 ret = new ID (newVer.name(), newVer.version()); 916 } catch (RemoteException e) { 917 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 918 } 919 ret.id = newVer; 920 ret.what = ObjectsKind.o_Module; 921 return ret; 922 } 923 924 public ID searchForNewName(ID id) throws CDLExceptLock, CDLExceptRemote { 925 int i,j; 926 FullID nid = new FullID(true); 928 aktScope.names.toFirst(); 929 for(i=0;i<aktScope.length();i++) { 930 nid.sn.addScope((String )aktScope.names.aktual()); 931 aktScope.names.toNext(); 932 } 933 nid.name = id.name; 934 nid.setVersion(id.version); 935 if (id.tag != null) { 936 nid.tag = id.tag; 937 nid.isin = IDKind.tag; 938 } 939 940 switch (id.isin) { 941 case IDKind.none : return searchForNewDefault(nid, id.what); 942 case IDKind.tag : return searchForNewTag(nid, id.what); 943 case IDKind.version : 944 searchError = "Specify tag or nothing for default."; 945 return null; 946 } 947 return null; 948 } 949 950 public ID searchForNewArch(FullID id) throws CDLExceptLock, CDLExceptRemote { 951 switch (id.isin) { 952 case IDKind.none : return searchForNewDefault(id, ObjectsKind.o_Architecture); 953 case IDKind.tag : return searchForNewTag(id, ObjectsKind.o_Architecture); 954 case IDKind.version : 955 searchError = "Specify tag or nothing for default."; 956 return null; 957 } 958 return null; 959 } 960 961 private ID searchForNewDefault(FullID id, int kind) throws CDLExceptLock, CDLExceptRemote { 962 int i,j; 963 964 try { 965 CompContainer con = this; 967 id.sn.names.toFirst(); 968 for(i=0;i<id.sn.names.size();i++) { 969 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 970 if (a==null || a.length==0) 971 throw new CompRepExcept(); 972 if (a.length==1) { 973 if (a[0].isContainer()) con = (CompContainer) a[0]; 974 else throw new CompRepExcept(); 975 } else { 976 searchError = "It never would be here."; 977 return null; 978 } 979 id.sn.names.toNext(); 980 } 981 CompContained sec[] = con.lookup(id.name); 982 if (sec!=null && sec.length!=0) { 983 searchError = "Object with this name was added in this session."; 984 return null; 985 } else { sec = con.contents(); 987 for (i=0;i<sec.length;i++) { if (sec[i].objectKind()==ObjectsKind.o_Enum) { 989 if (((CompEnum) sec[i]).members.isIn(id.name)) { 990 searchError = "Object with this name and other kind exists"; 991 return null; 992 } 993 } 994 } 995 } 996 } catch (CompRepExcept e) {;} 998 999 try { 1001 if (profile!=null) { 1002 Identification idl = profile.lookup(id.langToString()); 1003 if (idl != null) { 1004 id.sn.names.toFirst(); 1006 try { 1007 Container con = cdlRepository; 1008 for(i=0;i<id.sn.names.size();i++) { 1009 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 1010 if (a==null || a.length==0) 1011 throw new CompRepExcept(); 1012 if (a.length==1) { 1013 if (a[0] instanceof Container) con = (Container) a[0]; 1014 else throw new CompRepExcept(); 1015 } else { 1016 boolean found = false; 1017 for(j=0;j<a.length;j++) { 1018 if (a[j].get_identification().version().compareTo(idl.version())==0) { 1019 if ( !(a[j] instanceof Container)) throw new CompRepExcept(); 1020 found = true; 1021 con = (Container) a[j]; 1022 break; 1023 } 1024 } 1025 if (!found) { 1026 searchError = "Error in profiles."; 1027 return null; 1028 } 1029 } 1030 id.sn.names.toNext(); 1031 } 1032 Contained sec = con.lookup(idl.name(), idl.version()); 1033 if (sec==null) { 1034 searchError = "Error in profiles."; 1035 return null; 1036 } 1037 if (sec.get_def_kind().value() != kind) { 1038 searchError = "Object with other kind with same name exists in repository."; 1039 return null; 1040 } 1041 Contained lst = con.lookup_lastfromversion(idl.name(), idl.version()); 1042 if (lst.get_identification().is_equal(idl)) { Identification newVer = null; 1044 try { 1045 newVer = workRepository.create_nextversion(idl); 1046 } catch (TIRExceptCreate e) { 1047 searchError = "Can't create next version"; 1048 return null; 1049 } 1050 switch (kind) { case DefinitionKind.dk_Struct: 1052 case DefinitionKind.dk_Union: 1053 case DefinitionKind.dk_Enum: 1054 case DefinitionKind.dk_Interface: 1055 case DefinitionKind.dk_Frame: 1056 case DefinitionKind.dk_Exception: 1057 case DefinitionKind.dk_Typedef: 1058 case DefinitionKind.dk_Constant: 1059 case DefinitionKind.dk_Architecture: 1060 try { 1061 profile.remove(idl.lang_absolute_name().name()); 1062 profile.add(newVer); 1063 } catch (TIRExceptCreate e) { 1064 searchError = "Error in work with profile"; 1065 return null; 1066 } 1067 } 1068 ID ret = new ID(newVer.name(), newVer.version()); 1069 ret.id = newVer; 1070 ret.what = kind; 1071 return ret; 1072 } else { Identification newVer = null; 1074 try { 1075 Interactive.writeLine("Input branchtag for "+idl.absolute_name().name()+":"); 1077 String br = Interactive.readLine(); 1078 newVer = workRepository.create_branch(idl, br); } catch (TIRExceptCreate e) { 1080 searchError = "Can't create branch version"; 1081 return null; 1082 } catch (IOException e) { 1083 searchError = "IO error"; 1084 return null; 1085 } 1086 switch (kind) { case DefinitionKind.dk_Struct: 1088 case DefinitionKind.dk_Union: 1089 case DefinitionKind.dk_Enum: 1090 case DefinitionKind.dk_Interface: 1091 case DefinitionKind.dk_Frame: 1092 case DefinitionKind.dk_Exception: 1093 case DefinitionKind.dk_Typedef: 1094 case DefinitionKind.dk_Constant: 1095 case DefinitionKind.dk_Architecture: 1096 try { 1097 profile.remove(idl.lang_absolute_name().name()); 1098 profile.add(newVer); 1099 } catch (TIRExceptCreate e) { 1100 searchError = "Error in work with profile"; 1101 return null; 1102 } 1103 } 1104 ID ret = new ID(newVer.name(), newVer.version()); 1105 ret.id = newVer; 1106 ret.what = kind; 1107 return ret; 1108 } 1109 } catch (TIRExceptLock e) { 1110 throw new CDLExceptLock("Repository is locked."); 1111 } catch (RemoteException e) { 1112 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1113 } catch (CompRepExcept e) {;} 1114 } 1115 } 1116 } catch (TIRExceptLock e) { 1117 throw new CDLExceptLock("Repository is locked."); 1118 } catch (RemoteException e) { 1119 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1120 } 1121 1122 try { 1124 Container con = cdlRepository; 1125 id.sn.names.toFirst(); 1126 for(i=0;i<id.sn.names.size();i++) { 1127 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 1128 if (a==null || a.length==0) 1129 throw new CompRepExcept(); 1130 if (a.length==1) { 1131 if (a[0] instanceof Container) con = (Container) a[0]; 1132 else throw new CompRepExcept(); 1133 } else { 1134 Contained last = con.lookup_lastinbranch((String ) id.sn.names.aktual(),""); 1136 if (last==null) throw new CompRepExcept(); 1137 if (last instanceof Container) con = (Container) last; 1138 else throw new CompRepExcept(); 1139 } 1140 id.sn.names.toNext(); 1141 } 1142 Contained[] sec = con.lookup_name(id.name); 1143 if (sec!=null && sec.length!=0) { 1144 if (sec[0].get_def_kind().value() != kind) { 1145 searchError = "Object with other kind with same name exists in repository."; 1146 return null; 1147 } 1148 searchError = "Object with this name exists in the repository.\nYou must set default version."; 1149 return null; 1150 } else { DefinitionKind endk = workRepository.get_spec_def_kind(DefinitionKind.dk_Enum); 1152 sec = con.contents(endk); 1153 for (i=0;i<sec.length;i++) { 1154 EnumMember[] membs = ((EnumDef) sec[i]).members(); 1155 for (j=0;j<membs.length;j++) { 1156 if (membs[j].name().compareTo(id.name)==0) { 1157 searchError = "Object with this name exists in the repository."; 1158 return null; 1159 } 1160 } 1161 } 1162 } 1163 1164 } catch (TIRExceptLock e) { 1165 throw new CDLExceptLock("Repository is locked."); 1166 } catch (RemoteException e) { 1167 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1168 } catch (CompRepExcept e) {;} 1169 1171 Identification newVer = null; 1172 try { 1173 newVer = workRepository.create_initialversion(ID.lang, id.toString()); 1174 } catch (TIRExceptCreate e) { 1175 searchError = "Can't create initial version"; 1176 return null; 1177 } catch (RemoteException e) { 1178 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1179 } 1180 switch (kind) { case DefinitionKind.dk_Struct: 1182 case DefinitionKind.dk_Union: 1183 case DefinitionKind.dk_Enum: 1184 case DefinitionKind.dk_Interface: 1185 case DefinitionKind.dk_Frame: 1186 case DefinitionKind.dk_Exception: 1187 case DefinitionKind.dk_Typedef: 1188 case DefinitionKind.dk_Constant: 1189 case DefinitionKind.dk_Architecture: 1190 try { 1191 if (profile!=null) 1192 profile.add(newVer); 1193 } catch (TIRExceptCreate e) { 1194 searchError = "Error in work with profile\n"+e.getMessage(); 1195 return null; 1196 } catch (RemoteException e) { 1197 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1198 } catch (TIRExceptLock e) { 1199 throw new CDLExceptLock("Repository is locked."); 1201 } 1202 } 1203 ID ret = null; 1204 try { 1205 ret = new ID (newVer.name(), newVer.version()); 1206 } catch (RemoteException e) { 1207 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1208 } 1209 ret.id = newVer; 1210 ret.what = kind; 1211 return ret; 1212 } 1213 1214 private ID searchForNewTag(FullID id, int kind) throws CDLExceptLock, CDLExceptRemote { 1215 int i,j; 1216 1217 try { 1218 CompContainer con = this; 1220 id.sn.names.toFirst(); 1221 for(i=0;i<id.sn.names.size();i++) { 1222 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 1223 if (a==null || a.length==0) 1224 throw new CompRepExcept(); 1225 if (a.length==1) { 1226 if (a[0].isContainer()) con = (CompContainer) a[0]; 1227 else throw new CompRepExcept(); 1228 } else { 1229 searchError = "It never would be here."; 1230 return null; 1231 } 1232 id.sn.names.toNext(); 1233 } 1234 CompContained sec[] = con.lookup(id.name); 1235 if (sec!=null && sec.length!=0) { 1236 searchError = "Object with this name was added in this session."; 1237 return null; 1238 } else { sec = con.contents(); 1240 for (i=0;i<sec.length;i++) { if (sec[i].objectKind()==ObjectsKind.o_Enum) { 1242 if (((CompEnum) sec[i]).members.isIn(id.name)) { 1243 searchError = "Object with this name and other kind exists"; 1244 return null; 1245 } 1246 } 1247 } 1248 } 1249 } catch (CompRepExcept e) {;} 1251 1252 try { 1254 if (profile!=null) { 1255 Identification idl = profile.lookup(id.langToString()); 1256 if (idl != null) { 1257 id.sn.names.toFirst(); 1259 try { 1260 Container con = cdlRepository; 1261 for(i=0;i<id.sn.names.size();i++) { 1262 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 1263 if (a==null || a.length==0) 1264 throw new CompRepExcept(); 1265 if (a.length==1) { 1266 if (a[0] instanceof Container) con = (Container) a[0]; 1267 else throw new CompRepExcept(); 1268 } else { 1269 boolean found = false; 1270 for(j=0;j<a.length;j++) { 1271 if (a[j].get_identification().version().compareTo(idl.version())==0) { 1272 if ( !(a[j] instanceof Container)) throw new CompRepExcept(); 1273 found = true; 1274 con = (Container) a[j]; 1275 break; 1276 } 1277 } 1278 if (!found) { 1279 searchError = "Error in profiles."; 1280 return null; 1281 } 1282 } 1283 id.sn.names.toNext(); 1284 } 1285 Contained sec = con.lookup(idl.name(), idl.version()); 1286 if (sec==null) { 1287 searchError = "Error in profiles."; 1288 return null; 1289 } 1290 if (sec.get_def_kind().value() != kind) { 1291 searchError = "Object with other kind with same name exists in repository."; 1292 return null; 1293 } 1294 if (con.lookup_tag(id.name, id.tag) != null) { 1295 searchError = "Object with with same tag exists in repository."; 1296 return null; 1297 } 1298 Contained lst = con.lookup_lastfromversion(idl.name(), idl.version()); 1299 if (lst.get_identification().is_equal(idl)) { Identification newVer = null; 1301 try { 1302 newVer = workRepository.create_nextversion(idl); 1303 } catch (TIRExceptCreate e) { 1304 searchError = "Can't create next version"; 1305 return null; 1306 } 1307 switch (kind) { case DefinitionKind.dk_Struct: 1309 case DefinitionKind.dk_Union: 1310 case DefinitionKind.dk_Enum: 1311 case DefinitionKind.dk_Interface: 1312 case DefinitionKind.dk_Frame: 1313 case DefinitionKind.dk_Exception: 1314 case DefinitionKind.dk_Typedef: 1315 case DefinitionKind.dk_Constant: 1316 case DefinitionKind.dk_Architecture: 1317 try { 1318 profile.remove(idl.lang_absolute_name().name()); 1319 profile.add(newVer); 1320 } catch (TIRExceptCreate e) { 1321 searchError = "Error in work with profile"; 1322 return null; 1323 } 1324 } 1325 ID ret = new ID(newVer.name(), newVer.version()); 1326 ret.id = newVer; 1327 ret.what = kind; 1328 ret.tag = new String (id.tag); 1329 ret.isin = IDKind.versiontag; 1330 return ret; 1331 } else { Identification newVer = null; 1333 try { 1334 Interactive.writeLine("Input branchtag for "+idl.absolute_name().name()+":"); 1336 String br = Interactive.readLine(); 1337 newVer = workRepository.create_branch(idl, ""); 1338 } catch (TIRExceptCreate e) { 1339 searchError = "Can't create branch version"; 1340 return null; 1341 } catch (IOException e) { 1342 searchError = "IO error"; 1343 return null; 1344 } 1345 switch (kind) { case DefinitionKind.dk_Struct: 1347 case DefinitionKind.dk_Union: 1348 case DefinitionKind.dk_Enum: 1349 case DefinitionKind.dk_Interface: 1350 case DefinitionKind.dk_Frame: 1351 case DefinitionKind.dk_Exception: 1352 case DefinitionKind.dk_Typedef: 1353 case DefinitionKind.dk_Constant: 1354 case DefinitionKind.dk_Architecture: 1355 try { 1356 profile.remove(idl.lang_absolute_name().name()); 1357 profile.add(newVer); 1358 } catch (TIRExceptCreate e) { 1359 searchError = "Error in work with profile"; 1360 return null; 1361 } 1362 } 1363 ID ret = new ID(newVer.name(), newVer.version()); 1364 ret.id = newVer; 1365 ret.what = kind; 1366 ret.tag = new String (id.tag); 1367 ret.isin = IDKind.versiontag; 1368 return ret; 1369 } 1370 } catch (TIRExceptLock e) { 1371 throw new CDLExceptLock("Repository is locked."); 1372 } catch (RemoteException e) { 1373 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1374 } catch (CompRepExcept e) {;} 1375 } 1376 } 1377 } catch (TIRExceptLock e) { 1378 throw new CDLExceptLock("Repository is locked."); 1379 } catch (RemoteException e) { 1380 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1381 } 1382 1383 try { 1385 Container con = cdlRepository; 1386 id.sn.names.toFirst(); 1387 for(i=0;i<id.sn.names.size();i++) { 1388 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 1389 if (a==null || a.length==0) 1390 throw new CompRepExcept(); 1391 if (a.length==1) { 1392 if (a[0] instanceof Container) con = (Container) a[0]; 1393 else throw new CompRepExcept(); 1394 } else { 1395 Contained last = con.lookup_lastinbranch((String ) id.sn.names.aktual(),""); 1397 if (last==null) throw new CompRepExcept(); 1398 if (last instanceof Container) con = (Container) last; 1399 else throw new CompRepExcept(); 1400 } 1401 id.sn.names.toNext(); 1402 } 1403 Contained[] sec = con.lookup_name(id.name); 1404 if (sec!=null && sec.length!=0) { 1405 if (sec[0].get_def_kind().value() != kind) { 1406 searchError = "Object with other kind with same name exists in repository."; 1407 return null; 1408 } 1409 searchError = "Object with this name exists in the repository.\nYou must set default version."; 1410 return null; 1411 } else { DefinitionKind endk = workRepository.get_spec_def_kind(DefinitionKind.dk_Enum); 1413 sec = con.contents(endk); 1414 for (i=0;i<sec.length;i++) { 1415 EnumMember[] membs = ((EnumDef) sec[i]).members(); 1416 for (j=0;j<membs.length;j++) { 1417 if (membs[j].name().compareTo(id.name)==0) { 1418 searchError = "Object with this name exists in the repository."; 1419 return null; 1420 } 1421 } 1422 } 1423 } 1424 1425 } catch (TIRExceptLock e) { 1426 throw new CDLExceptLock("Repository is locked."); 1427 } catch (RemoteException e) { 1428 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1429 } catch (CompRepExcept e) {;} 1430 1432 Identification newVer = null; 1433 try { 1434 newVer = workRepository.create_initialversion(ID.lang, id.toString()); 1435 } catch (TIRExceptCreate e) { 1436 searchError = "Can't create initial version"; 1437 return null; 1438 } catch (RemoteException e) { 1439 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1440 } 1441 switch (kind) { case DefinitionKind.dk_Struct: 1443 case DefinitionKind.dk_Union: 1444 case DefinitionKind.dk_Enum: 1445 case DefinitionKind.dk_Interface: 1446 case DefinitionKind.dk_Frame: 1447 case DefinitionKind.dk_Exception: 1448 case DefinitionKind.dk_Typedef: 1449 case DefinitionKind.dk_Constant: 1450 case DefinitionKind.dk_Architecture: 1451 try { 1452 if (profile!=null) 1453 profile.add(newVer); 1454 } catch (TIRExceptCreate e) { 1455 searchError = "Error in work with profile\n"+e.getMessage(); 1456 return null; 1457 } catch (RemoteException e) { 1458 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1459 } catch (TIRExceptLock e) { 1460 throw new CDLExceptLock("Repository is locked."); 1461 } 1462 } 1463 ID ret = null; 1464 try { 1465 ret = new ID (newVer.name(), newVer.version()); 1466 } catch (RemoteException e) { 1467 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1468 } 1469 ret.id = newVer; 1470 ret.what = kind; 1471 ret.tag = new String (id.tag); 1472 ret.isin = IDKind.versiontag; 1473 return ret; 1474 } 1475 1476 public ID searchForNewInner(ID id, CompContained aktual) throws CDLExceptLock, CDLExceptRemote { 1477 int i,j; 1478 int kind = id.what; 1479 FullID nid = new FullID(true); 1481 aktScope.names.toFirst(); 1482 for(i=0;i<aktScope.length();i++) { 1483 nid.sn.addScope((String )aktScope.names.aktual()); 1484 aktScope.names.toNext(); 1485 } 1486 nid.name = id.name; 1487 nid.setVersion(aktual.getIdent().version); 1488 1489 try { 1490 CompContainer con = this; 1492 nid.sn.names.toFirst(); 1493 for(i=0;i<nid.sn.names.size();i++) { 1494 CompContained[] a = con.lookup((String ) nid.sn.names.aktual()); 1495 if (a==null || a.length==0) 1496 throw new CompRepExcept(); 1497 if (a.length==1) { 1498 if (a[0].isContainer()) con = (CompContainer) a[0]; 1499 else throw new CompRepExcept(); 1500 } else { 1501 boolean found = false; 1502 for(j=0;j<a.length;j++) { 1503 if (a[j].getIdent().version.compareTo(nid.version)==0) { 1504 if ( ! a[j].isContainer()) throw new CompRepExcept(); 1505 found = true; 1506 con = (CompContainer) a[j]; 1507 break; 1508 } 1509 } 1510 if (!found) throw new CompRepExcept(); 1511 } 1512 nid.sn.names.toNext(); 1513 } 1514 CompContained sec[] = con.lookup(nid.name); 1515 if (sec!=null && sec.length!=0) { 1516 searchError = "Object with this name was added in this session."; 1517 return null; 1518 } 1519 } catch (CompRepExcept e) { 1520 searchError = "Unexpected error in the objects added in this session"; 1521 return null; 1522 } 1523 1524 try { 1526 if (profile!=null) { 1527 Identification idl = profile.lookup(nid.langToString()); 1528 if (idl != null) { 1529 nid.sn.names.toFirst(); 1531 try { 1532 Container con = cdlRepository; 1533 for(i=0;i<nid.sn.names.size();i++) { 1534 Contained[] a = con.lookup_name((String ) nid.sn.names.aktual()); 1535 if (a==null || a.length==0) 1536 throw new CompRepExcept(); 1537 if (a.length==1) { 1538 if (a[0] instanceof Container) con = (Container) a[0]; 1539 else throw new CompRepExcept(); 1540 } else { 1541 boolean found = false; 1542 for(j=0;j<a.length;j++) { 1543 if (a[j].get_identification().version().compareTo(idl.version())==0) { 1544 if ( !(a[j] instanceof Container)) throw new CompRepExcept(); 1545 found = true; 1546 con = (Container) a[j]; 1547 break; 1548 } 1549 } 1550 if (!found) { 1551 searchError = "Error in profiles."; 1552 return null; 1553 } 1554 } 1555 nid.sn.names.toNext(); 1556 } 1557 Contained sec = con.lookup(idl.name(), idl.version()); 1558 if (sec==null) { 1559 searchError = "Error in profiles."; 1560 return null; 1561 } 1562 Identification newVer = null; 1563 try { 1564 newVer = workRepository.create_identification(ID.lang, nid.toString(), nid.version); 1565 } catch (TIRExceptCreate e) { 1566 searchError = "Can't create version"; 1567 return null; 1568 } catch (RemoteException e) { 1569 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1570 } 1571 switch (kind) { case DefinitionKind.dk_Struct: 1573 case DefinitionKind.dk_Union: 1574 case DefinitionKind.dk_Enum: 1575 case DefinitionKind.dk_Interface: 1576 case DefinitionKind.dk_Frame: 1577 case DefinitionKind.dk_Exception: 1578 case DefinitionKind.dk_Typedef: 1579 case DefinitionKind.dk_Constant: 1580 case DefinitionKind.dk_Architecture: 1581 try { 1582 profile.remove(idl.lang_absolute_name().name()); 1583 profile.add(newVer); 1584 } catch (TIRExceptCreate e) { 1585 searchError = "Error in work with profile"; 1586 return null; 1587 } 1588 } 1589 ID ret = null; 1590 try { 1591 ret = new ID (newVer.name(), newVer.version()); 1592 } catch (RemoteException e) { 1593 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1594 } 1595 ret.id = newVer; 1596 ret.what = kind; 1597 ret.isin = IDKind.version; 1598 return ret; 1599 } catch (TIRExceptLock e) { 1600 throw new CDLExceptLock("Repository is locked."); 1601 } catch (RemoteException e) { 1602 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1603 } catch (CompRepExcept e) {;} 1604 } 1605 } 1606 } catch (TIRExceptLock e) { 1607 throw new CDLExceptLock("Repository is locked."); 1608 } catch (RemoteException e) { 1609 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1610 } 1611 1612 Identification newVer = null; 1613 try { 1614 newVer = workRepository.create_identification(ID.lang, nid.toString(), nid.version); 1615 } catch (TIRExceptCreate e) { 1616 searchError = "Can't create version"; 1617 return null; 1618 } catch (RemoteException e) { 1619 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1620 } 1621 switch (kind) { case DefinitionKind.dk_Struct: 1623 case DefinitionKind.dk_Union: 1624 case DefinitionKind.dk_Enum: 1625 case DefinitionKind.dk_Interface: 1626 case DefinitionKind.dk_Frame: 1627 case DefinitionKind.dk_Exception: 1628 case DefinitionKind.dk_Typedef: 1629 case DefinitionKind.dk_Constant: 1630 case DefinitionKind.dk_Architecture: 1631 try { 1632 if (profile!=null) 1633 profile.add(newVer); 1634 } catch (TIRExceptCreate e) { 1635 searchError = "Error in work with profile\n"+e.getMessage(); 1636 return null; 1637 } catch (RemoteException e) { 1638 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1639 } catch (TIRExceptLock e) { 1640 throw new CDLExceptLock("Repository is locked."); 1641 } 1642 } 1643 ID ret = null; 1644 try { 1645 ret = new ID (newVer.name(), newVer.version()); 1646 } catch (RemoteException e) { 1647 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1648 } 1649 ret.id = newVer; 1650 ret.what = kind; 1651 ret.isin = IDKind.version; 1652 return ret; 1653 } 1654 1655 private ID searchForNewVersion(FullID id, int kind) throws CDLExceptLock, CDLExceptRemote { 1657 int i,j; 1658 1659 try { 1660 CompContainer con = this; 1662 id.sn.names.toFirst(); 1663 for(i=0;i<id.sn.names.size();i++) { 1664 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 1665 if (a==null || a.length==0) 1666 throw new CompRepExcept(); 1667 if (a.length==1) { 1668 if (a[0].isContainer()) con = (CompContainer) a[0]; 1669 else throw new CompRepExcept(); 1670 } else { 1671 boolean found = false; 1672 for(j=0;j<a.length;j++) { 1673 if (a[j].getIdent().version.compareTo(id.version)==0) { 1674 if ( ! a[j].isContainer()) throw new CompRepExcept(); 1675 found = true; 1676 con = (CompContainer) a[j]; 1677 break; 1678 } 1679 } 1680 if (!found) throw new CompRepExcept(); 1681 } 1682 id.sn.names.toNext(); 1683 } 1684 CompContained sec[] = con.lookup(id.name); 1685 if (sec!=null && sec.length!=0) { 1686 searchError = "Object with this name was added in this session."; 1687 return null; 1688 } 1689 } catch (CompRepExcept e) {;} 1691 1692 try { 1694 Container con = cdlRepository; 1695 id.sn.names.toFirst(); 1696 for(i=0;i<id.sn.names.size();i++) { 1697 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 1698 if (a==null || a.length==0) 1699 throw new CompRepExcept(); 1700 if (a.length==1) { 1701 if (a[0] instanceof Container) con = (Container) a[0]; 1702 else throw new CompRepExcept(); 1703 } else { 1704 searchError = "It never would be here."; 1705 return null; 1706 } 1707 id.sn.names.toNext(); 1708 } 1709 Contained sec = con.lookup(id.name, id.version); 1710 if (sec!=null) { 1711 searchError = "Object with this name exists in the repository."; 1712 return null; 1713 } 1714 1715 } catch (TIRExceptLock e) { 1716 throw new CDLExceptLock("Repository is locked."); 1717 } catch (RemoteException e) { 1718 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1719 } catch (CompRepExcept e) {;} 1720 1722 1723 return new ID(id.name, id.version); 1724 } 1725 1726 public CompInterface searchFwdIface(ID id) { 1727 int i; 1728 FullID nid = new FullID(true); 1730 aktScope.names.toFirst(); 1731 for(i=0;i<aktScope.length();i++) { 1732 nid.sn.addScope((String )aktScope.names.aktual()); 1733 aktScope.names.toNext(); 1734 } 1735 nid.name = id.name; 1736 nid.setVersion(id.version); 1737 1738 CompContainer con = this; 1739 nid.sn.names.toFirst(); 1740 for(i=0;i<nid.sn.names.size();i++) { 1741 CompContained[] a = con.lookup((String ) nid.sn.names.aktual()); 1742 if (a==null || a.length==0) 1743 return null; 1744 if (a.length==1) { 1745 if (a[0].isContainer()) con = (CompContainer) a[0]; 1746 else return null; 1747 } else { 1748 searchError = "It never would be here."; 1749 return null; 1750 } 1751 nid.sn.names.toNext(); 1752 } 1753 CompContained sec[] = con.lookup(nid.name); 1754 if (sec!=null && sec.length!=0) { if (sec[0].objectKind() == ObjectsKind.o_Interface) { 1756 if (((CompInterface) sec[0]).forwarddcl) { ((CompInterface) sec[0]).forwarddcl = false; 1758 ((CompInterface) sec[0]).wasforwarddcl = true; 1759 if (id.isin==IDKind.tag) { 1760 sec[0].getIdent().tag = new String (id.tag); 1761 sec[0].getIdent().isin = IDKind.versiontag; 1762 } 1763 return (CompInterface) sec[0]; 1764 } 1765 searchError = "Interface with this name was allready added."; 1766 return null; 1767 } 1768 searchError = "Object with this name was allready added."; 1769 return null; 1770 } 1771 return null; 1772 } 1773 1774 1775 1817 1818 public boolean searchForEnumMember(String name, CompContainer aktual) throws CDLExceptRemote, CDLExceptLock { 1819 int i; 1820 CompContained[] aktsec = aktual.contents(); 1822 for (i=0;i<aktsec.length;i++) { 1823 if (aktsec[i].getIdent().name.compareTo(name)==0) 1824 return false; 1825 if (aktsec[i].objectKind()==ObjectsKind.o_Enum) { 1826 if (((CompEnum) aktsec[i]).members.isIn(name)) { 1827 return false; 1828 } 1829 } 1830 } 1831 1832 FullID nid = new FullID(true); 1834 aktScope.names.toFirst(); 1835 for(i=0;i<aktScope.length();i++) { 1836 nid.sn.addScope((String ) aktScope.names.aktual()); 1837 aktScope.names.toNext(); 1838 } 1839 nid.name = name; 1840 nid.setVersion(null); 1841 try { 1842 Container con = cdlRepository; 1843 nid.sn.names.toFirst(); 1844 for(i=0;i<nid.sn.names.size();i++) { 1845 Contained[] a = con.lookup_name((String ) nid.sn.names.aktual()); 1846 if (a==null || a.length==0) 1847 throw new CompRepExcept(); 1848 if (a.length==1) { 1849 if (a[0] instanceof Container) con = (Container) a[0]; 1850 else { 1851 return true; 1852 } 1853 } else { 1854 return true; 1855 } 1856 nid.sn.names.toNext(); 1857 } 1858 Contained[] sec = con.lookup_name(nid.name); 1859 if (sec!=null && sec.length!=0) { 1860 return false; 1861 } else { DefinitionKind endk = workRepository.get_spec_def_kind(DefinitionKind.dk_Enum); 1863 sec = con.contents(endk); 1864 for (i=0;i<sec.length;i++) { 1865 EnumMember[] membs = ((EnumDef) sec[i]).members(); 1866 for (int j=0;j<membs.length;j++) { 1867 if (membs[j].name().compareTo(nid.name)==0) { 1868 return false; 1869 } 1870 } 1871 } 1872 } 1873 1874 } catch (TIRExceptLock e) { 1875 throw new CDLExceptLock("Repository is locked."); 1876 } catch (RemoteException e) { 1877 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 1878 } catch (CompRepExcept e) {;} 1879 1881 return true; 1882 } 1883 1884 public CompReffer searchConstant(FullID id) throws CDLExceptRemote, CDLExceptLock { 1885 int i; 1887 long numPath = 0; 1888 1889 if (!id.isAbsolute) { 1890 FullID nid = new FullID(true); 1892 aktScope.names.toFirst(); 1893 for(i=0;i<aktScope.length();i++) { 1894 nid.sn.addScope((String )aktScope.names.aktual()); 1895 aktScope.names.toNext(); 1896 } 1897 numPath = aktScope.length(); 1898 id.sn.names.toFirst(); 1899 for(i=0;i<id.sn.length();i++) { 1900 nid.sn.addScope((String )id.sn.names.aktual()); 1901 id.sn.names.toNext(); 1902 } 1903 nid.name = id.name; 1904 nid.setVersion(id.version); 1905 id = nid; 1906 } 1907 return searchConstantPriv(id, numPath); 1908 1909 } 1910 1911 1912 private CompReffer searchConstantPriv(FullID id, long numPath) throws CDLExceptRemote, CDLExceptLock { 1913 int i,j; 1914 try { 1915 1916 CompContainer con = this; 1917 id.sn.names.toFirst(); 1918 for(i=0;i<id.sn.names.size();i++) { 1919 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 1920 if (a==null || a.length==0) 1921 throw new CompRepExcept(); 1922 if (a.length==1) { 1923 if (a[0].isContainer()) con = (CompContainer) a[0]; 1924 else throw new CompRepExcept(); 1925 } else { 1926 throw new CompRepExcept(); 1927 } 1928 id.sn.names.toNext(); 1929 } 1930 CompContained[] sec = con.lookup(id.name); 1931 if (sec!=null && sec.length!=0) { 1932 if (sec.length==1) { 1933 if (sec[0].objectKind() != ObjectsKind.o_Constant) { 1934 searchError = id + " isn't constant."; 1935 return null; 1936 } 1937 CompReffer ret = new CompReffer(); 1938 ret.what = ObjectsKind.o_Constant; 1939 ret.ref = new FullID(true); 1940 ret.ref.name = new String (id.name); 1941 ret.ref.version = new String (sec[0].getIdent().version); 1942 ret.ref.isin = IDKind.version; 1943 ret.isNew = true; 1944 id.sn.names.toFirst(); 1945 for(j=0;j<id.sn.names.size();j++) { 1946 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 1947 id.sn.names.toNext(); 1948 } 1949 CompConstant cnst = (CompConstant) sec[0]; 1950 switch (cnst.type.objectKind()) { 1951 case ObjectsKind.o_Primitive: 1952 ret.basereffer = ObjectsKind.o_Primitive; 1953 ret.baserefferprim = ((CompPrimitive) cnst.type).kind; 1954 break; 1955 case ObjectsKind.o_none: ret.basereffer = ((CompReffer) cnst.type).basereffer; 1957 ret.baserefferprim = ((CompReffer) cnst.type).baserefferprim; 1958 break; 1959 default: 1960 ret.basereffer = cnst.type.objectKind(); 1961 } 1962 return ret; 1963 } else { 1964 searchError = id + " isn't constant."; 1965 return null; 1966 } 1967 } 1968 } catch (CompRepExcept e) {;} 1970 1971 try { 1973 if (profile != null) { 1974 Identification idl = profile.lookup(id.langToString()); 1975 if (idl != null) { 1976 CompReffer ret = new CompReffer(); 1977 ret.ref = new FullID(true); 1978 ret.ref.name = new String (idl.name()); 1979 ret.ref.version = new String (idl.version()); 1980 ret.ref.isin = IDKind.version; 1981 ret.isNew = false; 1982 id.sn.names.toFirst(); 1983 for(j=0;j<id.sn.names.size();j++) { 1984 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 1985 id.sn.names.toNext(); 1986 } 1987 try { Container con = cdlRepository; 1989 id.sn.names.toFirst(); 1990 for(i=0;i<id.sn.names.size();i++) { 1991 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 1992 if (a==null || a.length==0) 1993 throw new CompRepExcept(); 1994 if (a.length==1) { 1995 if (a[0] instanceof Container) con = (Container) a[0]; 1996 else throw new CompRepExcept(); 1997 } else { 1998 boolean found = false; 1999 for(j=0;j<a.length;j++) { 2000 if (a[j].get_identification().version().compareTo(idl.version())==0) { 2001 if ( !(a[j] instanceof Container)) throw new CompRepExcept(); 2002 found = true; 2003 con = (Container) a[j]; 2004 break; 2005 } 2006 } 2007 if (!found) throw new CompRepExcept(); 2008 } 2009 id.sn.names.toNext(); 2010 } 2011 Contained sec = con.lookup_lastinbranch(id.name, ""); 2012 if (sec!=null) { 2013 if (sec.get_def_kind().value() != DefinitionKind.dk_Constant) { 2014 searchError = id + " isn't constant."; 2015 return null; 2016 } 2017 CompReffer.isConstType(ret, this); ret.what = sec.get_def_kind().value(); 2019 } 2020 } catch (TIRExceptLock e) { 2021 throw new CDLExceptLock("Repository is locked."); 2022 } catch (RemoteException e) { 2023 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2024 } catch (CompRepExcept e) { 2025 searchError = "error in profile"; 2026 return null; 2027 } 2028 return ret; 2029 } 2030 } 2031 } catch (TIRExceptLock e) { 2032 throw new CDLExceptLock("Repository is locked."); 2033 } catch (RemoteException e) { 2034 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2035 } 2036 2038 try { 2040 Container con = cdlRepository; 2041 id.sn.names.toFirst(); 2042 for(i=0;i<id.sn.names.size();i++) { 2043 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 2044 if (a==null || a.length==0) 2045 throw new CompRepExcept(); 2046 if (a.length==1) { 2047 if (a[0] instanceof Container) con = (Container) a[0]; 2048 else throw new CompRepExcept(); 2049 } else { 2050 searchError = "More versions of this constant, use profiles."; 2051 return null; 2052 } 2053 id.sn.names.toNext(); 2054 } 2055 Contained sec = con.lookup_lastinbranch(id.name, ""); 2056 if (sec!=null) { 2057 if (sec.get_def_kind().value() != DefinitionKind.dk_Constant) { 2058 searchError = id + " isn't constant."; 2059 return null; 2060 } 2061 CompReffer ret = new CompReffer(); 2062 ret.what = sec.get_def_kind().value(); 2063 ret.ref = new FullID(true); 2064 ret.ref.name = new String (id.name); 2065 ret.ref.version = new String (sec.get_identification().version()); 2066 ret.ref.isin = IDKind.version; 2067 ret.isNew = false; 2068 id.sn.names.toFirst(); 2069 for(j=0;j<id.sn.names.size();j++) { 2070 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 2071 id.sn.names.toNext(); 2072 } 2073 CompReffer.isConstType(ret, this); return ret; 2075 } 2076 2077 } catch (TIRExceptLock e) { 2078 throw new CDLExceptLock("Repository is locked."); 2079 } catch (RemoteException e) { 2080 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2081 } catch (CompRepExcept e) {;} 2082 2083 if (numPath > 0) { 2085 id.sn.names.toFirst(); 2086 for (i=1; i<numPath; i++); 2087 id.sn.names.toNext(); 2088 id.sn.names.removeAkt(); 2089 return searchConstantPriv(id, numPath-1); 2090 } else { 2091 searchError = id.name + ":" + id.version + " doesn't exist"; 2092 return null; 2093 } 2094 } 2095 2096 public CompReffer searchEnumName(FullID id, FullID enumType) throws CDLExceptRemote, CDLExceptLock { 2097 int i; 2098 long numPath = 0; 2099 if (!id.isAbsolute) { 2100 FullID nid = new FullID(true); 2102 aktScope.names.toFirst(); 2103 for(i=0;i<aktScope.length();i++) { 2104 nid.sn.addScope((String )aktScope.names.aktual()); 2105 aktScope.names.toNext(); 2106 } 2107 numPath = aktScope.length(); 2108 id.sn.names.toFirst(); 2109 for(i=0;i<id.sn.length();i++) { 2110 nid.sn.addScope((String )id.sn.names.aktual()); 2111 id.sn.names.toNext(); 2112 } 2113 nid.name = id.name; 2114 nid.setVersion(id.version); 2115 id = nid; 2116 } 2117 return searchEnumNamePriv(id, enumType, numPath); 2118 2119 } 2120 2121 private CompReffer searchEnumNamePriv(FullID id, FullID enumType, long numPath) throws CDLExceptRemote, CDLExceptLock { 2122 int i, j; 2123 try { 2126 2127 CompContainer con = this; 2128 id.sn.names.toFirst(); 2129 for(i=0;i<id.sn.names.size();i++) { 2130 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 2131 if (a==null || a.length==0) 2132 throw new CompRepExcept(); 2133 if (a.length==1) { 2134 if (a[0].isContainer()) con = (CompContainer) a[0]; 2135 else throw new CompRepExcept(); 2136 } else { 2137 throw new CompRepExcept(); 2138 } 2139 id.sn.names.toNext(); 2140 } 2141 CompContained[] sec = con.lookup(id.name); 2142 if (sec!=null && sec.length!=0) { 2143 if (sec.length==1) { 2144 if (sec[0].objectKind() != ObjectsKind.o_Constant) { 2145 searchError = id + " isn't suitable object."; 2146 return null; 2147 } 2148 CompReffer ret = new CompReffer(); 2149 ret.what = ObjectsKind.o_Constant; 2150 ret.ref = new FullID(true); 2151 ret.ref.name = new String (id.name); 2152 ret.ref.version = new String (sec[0].getIdent().version); 2153 ret.ref.isin = IDKind.version; 2154 ret.isNew = true; 2155 id.sn.names.toFirst(); 2156 for(j=0;j<id.sn.names.size();j++) { 2157 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 2158 id.sn.names.toNext(); 2159 } 2160 CompConstant cnst = (CompConstant) sec[0]; 2161 switch (cnst.type.objectKind()) { 2162 case ObjectsKind.o_Primitive: 2163 ret.basereffer = ObjectsKind.o_Primitive; 2164 ret.baserefferprim = ((CompPrimitive) cnst.type).kind; 2165 break; 2166 case ObjectsKind.o_none: ret.basereffer = ((CompReffer) cnst.type).basereffer; 2168 ret.baserefferprim = ((CompReffer) cnst.type).baserefferprim; 2169 break; 2170 default: 2171 ret.basereffer = cnst.type.objectKind(); 2172 } 2173 return ret; 2174 } else { 2175 searchError = id + " isn't suitable object."; 2176 return null; 2177 } 2178 } 2179 } catch (CompRepExcept e) {;} 2181 2182 try { 2184 if (profile != null) { 2185 Identification idl = profile.lookup(id.langToString()); 2186 if (idl != null) { 2187 CompReffer ret = new CompReffer(); 2188 ret.ref = new FullID(true); 2189 ret.ref.name = new String (idl.name()); 2190 ret.ref.version = new String (idl.version()); 2191 ret.ref.isin = IDKind.version; 2192 ret.isNew = false; 2193 id.sn.names.toFirst(); 2194 for(j=0;j<id.sn.names.size();j++) { 2195 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 2196 id.sn.names.toNext(); 2197 } 2198 try { Container con = cdlRepository; 2200 id.sn.names.toFirst(); 2201 for(i=0;i<id.sn.names.size();i++) { 2202 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 2203 if (a==null || a.length==0) 2204 throw new CompRepExcept(); 2205 if (a.length==1) { 2206 if (a[0] instanceof Container) con = (Container) a[0]; 2207 else throw new CompRepExcept(); 2208 } else { 2209 boolean found = false; 2210 for(j=0;j<a.length;j++) { 2211 if (a[j].get_identification().version().compareTo(idl.version())==0) { 2212 if ( !(a[j] instanceof Container)) throw new CompRepExcept(); 2213 found = true; 2214 con = (Container) a[j]; 2215 break; 2216 } 2217 } 2218 if (!found) throw new CompRepExcept(); 2219 } 2220 id.sn.names.toNext(); 2221 } 2222 Contained sec = con.lookup_lastinbranch(id.name, ""); 2223 if (sec!=null) { 2224 if (sec.get_def_kind().value() != DefinitionKind.dk_Constant) { 2225 searchError = id + " isn't suitable object."; 2226 return null; 2227 } 2228 CompReffer.isConstType(ret, this); ret.what = sec.get_def_kind().value(); 2230 } 2231 } catch (TIRExceptLock e) { 2232 throw new CDLExceptLock("Repository is locked."); 2233 } catch (RemoteException e) { 2234 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2235 } catch (CompRepExcept e) { 2236 searchError = "error in profile"; 2237 return null; 2238 } 2239 return ret; 2240 } 2241 } 2242 } catch (TIRExceptLock e) { 2243 throw new CDLExceptLock("Repository is locked."); 2244 } catch (RemoteException e) { 2245 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2246 } 2247 2249 try { 2251 Container con = cdlRepository; 2252 id.sn.names.toFirst(); 2253 for(i=0;i<id.sn.names.size();i++) { 2254 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 2255 if (a==null || a.length==0) 2256 throw new CompRepExcept(); 2257 if (a.length==1) { 2258 if (a[0] instanceof Container) con = (Container) a[0]; 2259 else throw new CompRepExcept(); 2260 } else { 2261 searchError = "More versions, use profiles."; 2262 return null; 2263 } 2264 id.sn.names.toNext(); 2265 } 2266 Contained sec = con.lookup_lastinbranch(id.name, ""); 2267 if (sec!=null) { 2268 if (sec.get_def_kind().value() != DefinitionKind.dk_Constant) { 2269 searchError = id + " isn't suitable object."; 2270 return null; 2271 } 2272 CompReffer ret = new CompReffer(); 2273 ret.what = sec.get_def_kind().value(); 2274 ret.ref = new FullID(true); 2275 ret.ref.name = new String (id.name); 2276 ret.ref.version = new String (sec.get_identification().version()); 2277 ret.ref.isin = IDKind.version; 2278 ret.isNew = false; 2279 id.sn.names.toFirst(); 2280 for(j=0;j<id.sn.names.size();j++) { 2281 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 2282 id.sn.names.toNext(); 2283 } 2284 CompReffer.isConstType(ret, this); return ret; 2286 } 2287 2288 } catch (TIRExceptLock e) { 2289 throw new CDLExceptLock("Repository is locked."); 2290 } catch (RemoteException e) { 2291 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2292 } catch (CompRepExcept e) {;} 2293 2294 try { 2297 2298 CompContainer con = this; 2299 id.sn.names.toFirst(); 2300 for(i=0;i<id.sn.names.size();i++) { 2301 CompContained[] a = con.lookup((String ) id.sn.names.aktual()); 2302 if (a==null || a.length==0) 2303 throw new CompRepExcept(); 2304 if (a.length==1) { 2305 if (a[0].isContainer()) con = (CompContainer) a[0]; 2306 else throw new CompRepExcept(); 2307 } else { 2308 throw new CompRepExcept(); 2309 } 2310 id.sn.names.toNext(); 2311 } 2312 CompContained[] sec = con.lookup(enumType.name); 2313 if (sec!=null && sec.length!=0) { 2314 if (sec.length==1) { 2315 if (sec[0].objectKind() != ObjectsKind.o_Enum) { 2316 searchError = id + " isn't suitable object."; 2317 return null; 2318 } 2319 if (!((CompEnum) sec[0]).members.isIn(id.name)) { 2320 searchError = id + " isn't member of enum."; 2321 return null; 2322 } 2323 CompReffer ret = new CompReffer(); 2324 ret.what = ObjectsKind.o_Enum; 2325 ret.ref = new FullID(true); 2326 ret.ref.name = new String (enumType.name); 2327 ret.ref.version = new String (sec[0].getIdent().version); 2328 ret.ref.isin = IDKind.version; 2329 ret.isNew = true; 2330 id.sn.names.toFirst(); 2331 for(j=0;j<id.sn.names.size();j++) { 2332 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 2333 id.sn.names.toNext(); 2334 } 2335 ret.basereffer = ObjectsKind.o_Enum; 2336 return ret; 2337 } else { 2338 searchError = id + " isn't suitable object."; 2339 return null; 2340 } 2341 } 2342 } catch (CompRepExcept e) {;} 2344 2345 try { 2347 if (profile != null) { 2348 Identification idl = profile.lookup(enumType.langToString()); 2349 if (idl != null) { 2350 CompReffer ret = new CompReffer(); 2351 ret.ref = new FullID(true); 2352 ret.ref.name = new String (idl.name()); 2353 ret.ref.version = new String (idl.version()); 2354 ret.ref.isin = IDKind.version; 2355 ret.isNew = false; 2356 id.sn.names.toFirst(); 2357 for(j=0;j<id.sn.names.size();j++) { 2358 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 2359 id.sn.names.toNext(); 2360 } 2361 try { Container con = cdlRepository; 2363 id.sn.names.toFirst(); 2364 for(i=0;i<id.sn.names.size();i++) { 2365 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 2366 if (a==null || a.length==0) 2367 throw new CompRepExcept(); 2368 if (a.length==1) { 2369 if (a[0] instanceof Container) con = (Container) a[0]; 2370 else throw new CompRepExcept(); 2371 } else { 2372 boolean found = false; 2373 for(j=0;j<a.length;j++) { 2374 if (a[j].get_identification().version().compareTo(idl.version())==0) { 2375 if ( !(a[j] instanceof Container)) throw new CompRepExcept(); 2376 found = true; 2377 con = (Container) a[j]; 2378 break; 2379 } 2380 } 2381 if (!found) throw new CompRepExcept(); 2382 } 2383 id.sn.names.toNext(); 2384 } 2385 Contained sec = con.lookup_lastinbranch(enumType.name, ""); 2386 if (sec!=null) { 2387 if (sec.get_def_kind().value() != DefinitionKind.dk_Enum) { 2388 searchError = id + " isn't suitable object."; 2389 return null; 2390 } 2391 boolean found = false; 2392 EnumMember[] membs = ((EnumDef) sec).members(); 2393 for (i=0;i<membs.length;i++) { 2394 if (membs[i].name().compareTo(id.name)==0) { 2395 found = true; 2396 break; 2397 } 2398 } 2399 if (!found) { 2400 searchError = id + " isn't member of enum."; 2401 return null; 2402 } 2403 ret.what = sec.get_def_kind().value(); 2404 } 2405 } catch (TIRExceptLock e) { 2406 throw new CDLExceptLock("Repository is locked."); 2407 } catch (RemoteException e) { 2408 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2409 } catch (CompRepExcept e) { 2410 searchError = "error in profile"; 2411 return null; 2412 } 2413 return ret; 2414 } 2415 } 2416 } catch (TIRExceptLock e) { 2417 throw new CDLExceptLock("Repository is locked."); 2418 } catch (RemoteException e) { 2419 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2420 } 2421 2423 try { 2425 Container con = cdlRepository; 2426 id.sn.names.toFirst(); 2427 for(i=0;i<id.sn.names.size();i++) { 2428 Contained[] a = con.lookup_name((String ) id.sn.names.aktual()); 2429 if (a==null || a.length==0) 2430 throw new CompRepExcept(); 2431 if (a.length==1) { 2432 if (a[0] instanceof Container) con = (Container) a[0]; 2433 else throw new CompRepExcept(); 2434 } else { 2435 searchError = "More versions, use profiles."; 2436 return null; 2437 } 2438 id.sn.names.toNext(); 2439 } 2440 Contained sec = con.lookup_lastinbranch(enumType.name, ""); 2441 if (sec!=null) { 2442 if (sec.get_def_kind().value() != DefinitionKind.dk_Enum) { 2443 searchError = id + " isn't suitable object."; 2444 return null; 2445 } 2446 boolean found = false; 2447 EnumMember[] membs = ((EnumDef) sec).members(); 2448 for (i=0;i<membs.length;i++) { 2449 if (membs[i].name().compareTo(id.name)==0) { 2450 found = true; 2451 break; 2452 } 2453 } 2454 if (!found) { 2455 searchError = id + " isn't member of enum."; 2456 return null; 2457 } 2458 CompReffer ret = new CompReffer(); 2459 ret.what = sec.get_def_kind().value(); 2460 ret.ref = new FullID(true); 2461 ret.ref.name = new String (enumType.name); 2462 ret.ref.version = new String (sec.get_identification().version()); 2463 ret.ref.isin = IDKind.version; 2464 ret.isNew = false; 2465 id.sn.names.toFirst(); 2466 for(j=0;j<id.sn.names.size();j++) { 2467 ret.ref.sn.addScope(new String ((String )id.sn.names.aktual())); 2468 id.sn.names.toNext(); 2469 } 2470 CompReffer.isConstType(ret, this); return ret; 2472 } 2473 2474 } catch (TIRExceptLock e) { 2475 throw new CDLExceptLock("Repository is locked."); 2476 } catch (RemoteException e) { 2477 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2478 } catch (CompRepExcept e) {;} 2479 2480 if (numPath > 0) { 2482 id.sn.names.toFirst(); 2483 for(i=1;i<numPath;i++) 2484 id.sn.names.toNext(); 2485 id.sn.names.removeAkt(); 2486 return searchEnumName(id, enumType); 2487 } else { 2488 searchError = id.name + ":" + id.version + " doesn't exist"; 2489 return null; 2490 } 2491 } 2492 2493 public CompProvider searchExistNewProvider(String name) { 2494 Scopename fullname = new Scopename(); 2495 int i; 2496 aktScope.names.toFirst(); 2497 for (i=0;i<aktScope.length();i++) { 2498 fullname.addScope((String )aktScope.names.aktual()); 2499 aktScope.names.toNext(); 2500 } 2501 fullname.addScope(name); 2502 2503 CompContainer con = this; 2504 fullname.names.toFirst(); 2505 for(i=0;i<fullname.names.size()-1;i++) { 2506 CompContained[] a = con.lookup((String ) fullname.names.aktual()); 2507 if (a==null || a.length==0) 2508 return null; 2509 if (a.length==1) { 2510 if (a[0].isContainer()) con = (CompContainer) a[0]; 2511 else { 2512 return null; 2513 } 2514 } else { 2515 return null; 2516 } 2517 fullname.names.toNext(); 2518 } 2519 CompContained sec[] = con.lookup((String ) fullname.names.aktual()); 2520 if (sec!=null && sec.length!=0) { 2521 if (sec[0].objectKind() == ObjectsKind.o_Provider) { 2522 return (CompProvider) sec[0]; 2523 } else { 2524 return null; 2525 } 2526 } 2527 return null; 2528 } 2529 2530 public ID searchForNewProvider(String name) throws CDLExceptLock, CDLExceptRemote { 2531 CompContained[] con = this.lookup(name); 2533 if (con==null || con.length == 0) { 2534 ; } else { searchError = "Other objects with this name exist"; 2537 return null; 2538 } 2539 2540 try { 2541 Contained[] dcon = cdlRepository.lookup_name(name); 2542 if (dcon == null || dcon.length==0) { Identification newVer = null; 2544 try { 2545 newVer = workRepository.create_identification(ID.lang, "::"+name,""); 2546 } catch (TIRExceptCreate e) { 2547 searchError = "Can't create identification"; 2548 return null; 2549 } catch (RemoteException e) { 2550 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2551 } 2552 ID ret = null; 2553 try { 2554 ret = new ID (newVer.name(), newVer.version()); 2555 } catch (RemoteException e) { 2556 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2557 } 2558 ret.id = newVer; 2559 ret.what = ObjectsKind.o_Provider; 2560 return ret; 2561 } else { 2562 if (dcon.length == 1) { 2563 if (dcon[0].get_def_kind().value() == DefinitionKind.dk_Provider) { 2564 ID ret = null; 2565 try { 2566 Identification idl = dcon[0].get_identification(); 2567 ret = new ID (idl.name(), idl.version()); 2568 } catch (RemoteException e) { 2569 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2570 } 2571 ret.exist = true; 2572 ret.id = null; 2573 ret.what = ObjectsKind.o_Provider; 2574 return ret; 2575 } else { 2576 searchError = "Other object with this name exists"; 2577 return null; 2578 } 2579 } else { 2580 searchError = "Other objects with this name exist"; 2581 return null; 2582 } 2583 } 2584 } catch (TIRExceptLock e) { 2585 throw new CDLExceptLock("Repository is locked."); 2586 } catch (RemoteException e) { 2587 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2588 } 2589 } 2590 2591 public CompAModule searchExistNewAMod(String name) { 2592 Scopename fullname = new Scopename(); 2593 int i; 2594 aktScope.names.toFirst(); 2595 for (i=0;i<aktScope.length();i++) { 2596 fullname.addScope((String )aktScope.names.aktual()); 2597 aktScope.names.toNext(); 2598 } 2599 fullname.addScope(name); 2600 2601 CompContainer con = this; 2602 fullname.names.toFirst(); 2603 for(i=0;i<fullname.names.size()-1;i++) { 2604 CompContained[] a = con.lookup((String ) fullname.names.aktual()); 2605 if (a==null || a.length==0) 2606 return null; 2607 if (a.length==1) { 2608 if (a[0].isContainer()) con = (CompContainer) a[0]; 2609 else { 2610 return null; 2611 } 2612 } else { 2613 return null; 2614 } 2615 fullname.names.toNext(); 2616 } 2617 CompContained sec[] = con.lookup((String ) fullname.names.aktual()); 2618 if (sec!=null && sec.length!=0) { 2619 if (sec[0].objectKind() == ObjectsKind.o_AModule) { 2620 return (CompAModule) sec[0]; 2621 } else { 2622 return null; 2623 } 2624 } 2625 return null; 2626 } 2627 2628 public ID searchForNewAModule(String name) throws CDLExceptLock, CDLExceptRemote { 2629 Scopename fullname = new Scopename(); 2630 int i; 2631 aktScope.names.toFirst(); 2632 for (i=0;i<aktScope.length();i++) { 2633 fullname.addScope((String )aktScope.names.aktual()); 2634 aktScope.names.toNext(); 2635 } 2636 fullname.addScope(name); 2637 2638 try { 2639 CompContainer con = this; 2641 fullname.names.toFirst(); 2642 for(i=0;i<fullname.names.size()-1;i++) { 2643 CompContained[] a = con.lookup((String ) fullname.names.aktual()); 2644 if (a==null || a.length==0) 2645 throw new CompRepExcept(); 2646 if (a.length==1) { 2647 if (a[0].isContainer()) con = (CompContainer) a[0]; 2648 else { 2649 searchError = "This name can not be amodule"; 2650 return null; 2651 } 2652 } else { 2653 searchError = "This name can not be amodule"; 2654 return null; 2655 } 2656 fullname.names.toNext(); 2657 } 2658 CompContained sec[] = con.lookup((String ) fullname.names.aktual()); 2659 if (sec!=null && sec.length!=0) { 2660 searchError = "Object with this name and other kind exists"; 2661 return null; 2662 } else { sec = con.contents(); 2664 for (i=0;i<sec.length;i++) { if (sec[i].objectKind()==ObjectsKind.o_Enum) { 2666 if (((CompEnum) sec[i]).members.isIn((String ) fullname.names.aktual())) { 2667 searchError = "Object with this name and other kind exists"; 2668 return null; 2669 } 2670 } 2671 } 2672 } 2673 } catch (CompRepExcept e) {;} 2675 2676 try { 2678 Container con = cdlRepository; 2679 fullname.names.toFirst(); 2680 for(i=0;i<fullname.names.size()-1;i++) { 2681 Contained[] a = con.lookup_name((String ) fullname.names.aktual()); 2682 if (a==null || a.length==0) 2683 throw new CompRepExcept(); 2684 if (a.length==1) { 2685 if (a[0] instanceof Container) con = (Container) a[0]; 2686 else { 2687 searchError = "This name can not be amodule"; 2688 return null; 2689 } 2690 } else { 2691 searchError = "This name can not be amodule"; 2692 return null; 2693 } 2694 fullname.names.toNext(); 2695 } 2696 Contained[] sec = con.lookup_name((String ) fullname.names.aktual()); 2697 if (sec!=null && sec.length!=0) { 2698 if (sec[0].get_def_kind().value() == DefinitionKind.dk_AModule) { 2699 ID ret = null; 2700 try { 2701 Identification idl = sec[0].get_identification(); 2702 ret = new ID (idl.name(), idl.version()); 2703 } catch (RemoteException e) { 2704 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2705 } 2706 ret.exist = true; 2707 ret.id = null; 2708 ret.what = ObjectsKind.o_Module; 2709 return ret; 2710 } else { 2711 searchError = "Object with this name exists in the repository."; 2712 return null; 2713 } 2714 } else { DefinitionKind endk = workRepository.get_spec_def_kind(DefinitionKind.dk_Enum); 2716 sec = con.contents(endk); 2717 for (i=0;i<sec.length;i++) { 2718 EnumMember[] membs = ((EnumDef) sec[i]).members(); 2719 for (int j=0;j<membs.length;j++) { 2720 if (membs[j].name().compareTo((String ) fullname.names.aktual())==0) { 2721 searchError = "Object with this name exists in the repository."; 2722 return null; 2723 } 2724 } 2725 } 2726 } 2727 2728 } catch (TIRExceptLock e) { 2729 throw new CDLExceptLock("Repository is locked."); 2730 } catch (RemoteException e) { 2731 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2732 } catch (CompRepExcept e) {;} 2733 2735 Identification newVer = null; 2736 try { 2737 newVer = workRepository.create_identification(ID.lang, fullname.toString(),""); 2738 } catch (TIRExceptCreate e) { 2739 searchError = "Can't create identification"; 2740 return null; 2741 } catch (RemoteException e) { 2742 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2743 } 2744 ID ret = null; 2745 try { 2746 ret = new ID (newVer.name(), newVer.version()); 2747 } catch (RemoteException e) { 2748 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 2749 } 2750 ret.id = newVer; 2751 ret.what = ObjectsKind.o_AModule; 2752 return ret; 2753 } 2754 2755 public boolean abort() { 2756 boolean ret = false; 2757 try { 2758 ret = workRepository.abort(); 2759 } catch (RemoteException e) { 2760 Output.out.println("Remote exception: "+e.getMessage()); 2761 System.exit(0); 2762 } 2763 return ret; 2764 } 2765 2766 public boolean commit() { 2767 boolean ret = false; 2768 try { 2769 ret = workRepository.commit(); 2770 } catch (RemoteException e) { 2771 Output.out.println("Remote exception: "+e.getMessage()); 2772 System.exit(0); 2773 } catch (TIRExceptCommit e) { 2774 Output.out.println(e.getMessage()); 2775 e.printStackTrace(); 2776 System.exit(0); 2777 } 2778 return ret; 2779 } 2780 2781 2782 public void printContent() { 2783 scanContainer(this,0); 2784 } 2785 2786 2787 private void scanContainer(CompContainer what, int ind) { 2788 CompContained con[] = what.contents(); 2789 ID id; 2790 for (int i=0;i<con.length;i++) { 2791 intend(ind); 2792 Output.out.print("+--"); 2793 if (con[i]==null) 2794 Output.out.println("! not implemented !"); 2795 else { 2796 printKind(con[i].objectKind()); 2797 id = con[i].getIdent(); 2798 Output.out.println(" \""+id.name+"\" "+id.version); 2799 if ((con[i]) instanceof CompInterface) { 2800 intend(ind); 2801 Output.out.println(((CompInterface) con[i]).protocolToText()); 2802 } 2803 if ((con[i]) instanceof CompFrame) { 2804 intend(ind); 2805 Output.out.println(((CompFrame) con[i]).protocolToText()); 2806 } 2807 if ((con[i]) instanceof CompContainer) 2808 scanContainer((CompContainer) con[i], ind+1); 2809 } 2810 } 2811 } 2812 2813 2814 private static void intend(int in) { 2815 for(int i=0;i<in;i++) 2816 Output.out.print("| "); 2817 } 2818 2819 2820 private static void printKind(int ok) { 2821 switch (ok) { 2822 case ObjectsKind.o_Attribute : Output.out.print("Attribute"); break; 2823 case ObjectsKind.o_Constant : Output.out.print("Constant"); break; 2824 case ObjectsKind.o_Exception : Output.out.print("Exception"); break; 2825 case ObjectsKind.o_Interface : Output.out.print("Interface"); break; 2826 case ObjectsKind.o_Module : Output.out.print("Module"); break; 2827 case ObjectsKind.o_Operation : Output.out.print("Operation"); break; 2828 case ObjectsKind.o_Typedef : Output.out.print("Typedef"); break; 2829 case ObjectsKind.o_Struct : Output.out.print("Struct"); break; 2830 case ObjectsKind.o_Union : Output.out.print("Union"); break; 2831 case ObjectsKind.o_Enum : Output.out.print("Enum"); break; 2832 case ObjectsKind.o_Primitive : Output.out.print("Primitive"); break; 2833 case ObjectsKind.o_String : Output.out.print("String"); break; 2834 case ObjectsKind.o_Sequence : Output.out.print("Sequence"); break; 2835 case ObjectsKind.o_Array : Output.out.print("Array"); break; 2836 case ObjectsKind.o_Repository : Output.out.print("Repository"); break; 2837 case ObjectsKind.o_Frame : Output.out.print("Frame"); break; 2838 case ObjectsKind.o_Architecture : Output.out.print("Architecture"); break; 2839 case ObjectsKind.o_Provides : Output.out.print("Provides"); break; 2840 case ObjectsKind.o_Requires : Output.out.print("Requires"); break; 2841 case ObjectsKind.o_Property : Output.out.print("Property"); break; 2842 case ObjectsKind.o_Implements : Output.out.print("Implements"); break; 2843 case ObjectsKind.o_Inst : Output.out.print("Inst"); break; 2844 case ObjectsKind.o_Bind : Output.out.print("Bind"); break; 2845 case ObjectsKind.o_Protocol : Output.out.print("Protocol"); break; 2846 case ObjectsKind.o_StructMember : Output.out.print("StructMember"); break; 2847 case ObjectsKind.o_EnumMember : Output.out.print("EnumMember"); break; 2848 case ObjectsKind.o_UnionMember : Output.out.print("UnionMember"); break; 2849 case ObjectsKind.o_Expression : Output.out.print("Expression"); break; 2850 case ObjectsKind.o_ProtocolOper : Output.out.print("ProtocolOper"); break; 2851 case ObjectsKind.o_ValueGen : Output.out.print("ValueGen"); break; 2852 case ObjectsKind.o_ValueGenElem : Output.out.print("ValueGenOper"); break; 2853 case ObjectsKind.o_BindOper : Output.out.print("BindOper"); break; 2854 case ObjectsKind.o_Provider : Output.out.print("Provider"); break; 2855 case ObjectsKind.o_AModule : Output.out.print("AModule"); break; 2856 case ObjectsKind.o_Wstring : Output.out.print("Wstring"); break; 2857 case ObjectsKind.o_Fixed : Output.out.print("Fixed"); break; 2858 } 2859 } 2860 2861 public void toNormal() throws CDLExceptRemote, CDLExceptToNormal, CDLExceptLock { 2862 java.util.ArrayList delayed = new java.util.ArrayList (); 2863 addToNormal(cdlRepository, cdlRepository, delayed); 2864 for (int i=0; i<delayed.size();i+=2) { 2865 CompInterface ci = (CompInterface) delayed.get(i); 2866 Container obj = (Container) delayed.get(i+1); 2867 ci.addToNormalDelayed(obj, cdlRepository, delayed); 2868 } 2869 } 2870 2871 public void addToNormal(Container obj, CDLRepository normRep, java.util.ArrayList delayed) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock { 2872 cont.toFirst(); 2873 try { 2874 for (int i=0;i<cont.size(); i++) { 2875 CompContained akt = (CompContained) cont.aktual(); 2876 switch (akt.objectKind()) { 2877 case ObjectsKind.o_Module: 2879 Contained[] cmod = obj.lookup_name(akt.getIdent().name); 2880 if ((cmod == null) || (cmod.length == 0)) { ModuleDef mod = null; 2882 try { 2883 mod = ((CDLContainer) obj).create_module(akt.getIdent().id); 2884 } catch (TIRExceptCreate ecr) { 2885 throw new CDLExceptToNormal("Can't create module "+((CompContained)akt).fullName()); 2886 } 2887 if (mod==null) 2888 throw new CDLExceptToNormal("Can't create module "+((CompContained)akt).fullName()); 2889 ((CompContainer) akt).addToNormal(mod, normRep, delayed); 2890 } else { if (cmod.length!=1) 2892 throw new CDLExceptToNormal("Unexpected error"); 2893 ((CompContainer) akt).addToNormal((Container) cmod[0], normRep, delayed); 2894 } 2895 break; 2896 case ObjectsKind.o_Typedef: 2898 try { 2899 TypedefDef td = ((CDLContainer) obj).create_typedef(akt.getIdent().id, ((CompTypedef) akt).type.toNormal(normRep)); 2900 if (td == null) 2901 throw new CDLExceptToNormal("Can't create typedef "+((CompContained)akt).fullName()); 2902 } catch (TIRExceptCreate ecr) { 2903 throw new CDLExceptToNormal("Can't create typedef "+((CompContained)akt).fullName()); 2904 } 2905 break; 2906 case ObjectsKind.o_Enum: 2908 try { 2909 EnumDef en = ((CDLContainer) obj).create_enum(akt.getIdent().id); 2910 if (en == null) 2911 throw new CDLExceptToNormal("Can't create enum "+((CompContained)akt).fullName()); 2912 ((CompEnum) akt).addToNormal(en); 2913 } catch (TIRExceptCreate ecr) { 2914 throw new CDLExceptToNormal("Can't create enum "+((CompContained)akt).fullName()); 2915 } 2916 break; 2917 case ObjectsKind.o_Struct: 2919 try { 2920 StructDef str = ((CDLContainer) obj).create_struct(akt.getIdent().id); 2921 if (str == null) 2922 throw new CDLExceptToNormal("Can't create struct "+((CompContained)akt).fullName()); 2923 ((CompStruct) akt).addToNormal(str, normRep, delayed); 2924 } catch (TIRExceptCreate ecr) { 2925 throw new CDLExceptToNormal("Can't create struct "+((CompContained)akt).fullName()); 2926 } 2927 break; 2928 case ObjectsKind.o_Union: 2930 try { 2931 UnionDef un = ((CDLContainer) obj).create_union(akt.getIdent().id, ((CompUnion) akt).switch_type.toNormal(normRep)); 2932 if (un == null) 2933 throw new CDLExceptToNormal("Can't create union "+((CompContained)akt).fullName()); 2934 ((CompUnion) akt).addToNormal(un, normRep, delayed); 2935 } catch (TIRExceptCreate ecr) { 2936 throw new CDLExceptToNormal("Can't create union "+((CompContained)akt).fullName()); 2937 } 2938 break; 2939 case ObjectsKind.o_Exception: 2941 try { 2942 ExceptionDef str = ((CDLContainer) obj).create_exception(akt.getIdent().id); 2943 if (str == null) 2944 throw new CDLExceptToNormal("Can't create exception "+((CompContained)akt).fullName()); 2945 ((CompException) akt).addToNormal(str, normRep, delayed); 2946 } catch (TIRExceptCreate ecr) { 2947 throw new CDLExceptToNormal("Can't create exception "+((CompContained)akt).fullName()); 2948 } 2949 break; 2950 case ObjectsKind.o_Constant: 2952 try { 2953 ConstantDef cnst = ((CDLContainer) obj).create_constant(akt.getIdent().id, ((CompConstant) akt).type.toNormal(normRep), ((CompExprOper) ((CompConstant)akt).expr).toNormal(normRep)); 2954 if (cnst == null) 2955 throw new CDLExceptToNormal("Can't create constant "+((CompContained)akt).fullName()); 2956 } catch (TIRExceptCreate ecr) { 2957 throw new CDLExceptToNormal("Can't create constant "+((CompContained)akt).fullName()); 2958 } 2959 break; 2960 case ObjectsKind.o_Interface: 2962 try { 2963 2974 InterfaceDef iface = ((CDLContainer) obj).create_interface(akt.getIdent().id ); 2975 if (iface == null) 2976 throw new CDLExceptToNormal("Can't create interface "+((CompContained)akt).fullName()); 2977 ((CompInterface) akt).addToNormal(iface, normRep, delayed); 2978 } catch (TIRExceptCreate ecr) { 2979 throw new CDLExceptToNormal("Can't create interface "+((CompContained)akt).fullName()); 2980 } 2981 break; 2982 case ObjectsKind.o_Frame: 2984 try { 2985 FrameDef frm = ((CDLContainer) obj).create_frame(akt.getIdent().id, ((CompFrame)akt).isSystem); 2986 if (frm == null) 2987 throw new CDLExceptToNormal("Can't create frame "+((CompContained)akt).fullName()); 2988 ((CompFrame) akt).addToNormal(frm, normRep, delayed); 2989 } catch (TIRExceptCreate ecr) { 2990 throw new CDLExceptToNormal("Can't create frame "+((CompContained)akt).fullName()); 2991 } 2992 break; 2993 case ObjectsKind.o_Provider: 2995 Contained[] cprov = obj.lookup_name(akt.getIdent().name); 2996 if ((cprov == null) || (cprov.length == 0)) { ProviderDef prov = null; 2998 try { 2999 prov = ((CDLRepository) obj).create_provider(akt.getIdent().id); 3000 } catch (TIRExceptCreate ecr) { 3001 throw new CDLExceptToNormal("Can't create provider "+((CompContained)akt).fullName()); 3002 } 3003 if (prov==null) 3004 throw new CDLExceptToNormal("Can't create provider "+((CompContained)akt).fullName()); 3005 ((CompContainer) akt).addToNormal(prov, normRep, delayed); 3006 } else { if (cprov.length!=1) 3008 throw new CDLExceptToNormal("Unexpected error"); 3009 ((CompContainer) akt).addToNormal((Container) cprov[0], normRep, delayed); 3010 } 3011 break; 3012 default: 3013 throw new CDLExceptToNormal("Unexcepted kind of object"); 3014 } 3015 cont.toNext(); 3016 } 3017 } catch (RemoteException e) { 3018 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 3019 } catch (TIRExceptLock e) { 3020 throw new CDLExceptLock("Repository is locked."); 3021 } 3022 } 3023} 3024 3025 3107 | Popular Tags |