private void loadInterfaces(AbstractComponentFunctor absC) { if (unit != null) { int count = 0; // for each interface ... foreach (UnitType u in unit) { string uRef = u.uRef; string iRef = u.iRef; string uRefSuper = u.super == null || u.super.Length == 0 ? "" : u.super[0].uRef; if (u.super != null) { for (int j = 1; j < u.super.Length; j++) { uRefSuper += "+" + u.super[j].uRef; } } InterfaceType ui = lookForInterface(iRef); int nargs = ui.nArgsSpecified ? ui.nArgs : 0; Console.Error.WriteLine("STEP 5.3"); Interface i = new Interface(); i.Id_abstract = absC.Id_abstract; i.Id_interface = uRef; // i.Unit_replica = unit_replica; i.Facet = u.facet; i.Id_interface_super = uRefSuper; i.Class_name = xc.header.packagePath + "." + xc.header.name + "." + iRef; i.Class_nargs = nargs; // TODO i.Assembly_string = i.Class_name + ", Culture=neutral, Version=0.0.0.0"; // In the current implementation, the name of the dll is the name of the class of the unit. i.Order = ++count; i.Is_parallel = u.multiple; Console.Error.WriteLine("STEP 5.4"); if (ui.parameter != null) { Console.Error.WriteLine("STEP 5.4 - " + ui.parameter); foreach (InterfaceParameterType ipx in ui.parameter) { Console.Error.WriteLine("STEP 5.4 BEGIN 1- " + ipx.parid); InterfaceParameter ip = new InterfaceParameter(); Console.Error.WriteLine("STEP 5.4 BEGIN 2- " + ipx.parid); ip.Id_abstract = i.Id_abstract; ip.Id_interface = i.Id_interface; ip.ParId = ipx.parid; ip.VarId = ipx.varid; ip.Id_interface_parameter = ipx.iname; ip.Id_unit_parameter = ipx.uname; ip.ParOrder = ipx.order; br.ufc.pargo.hpe.backend.DGAC.BackEnd.ipdao.insert(ip); Console.Error.WriteLine("STEP 5.4 END - " + ipx.parid); } } Console.Error.WriteLine("BEFORE STEP 5.5 " + (ui == null)); Console.Error.WriteLine("STEP 5.5 --- " + (ui.sources[ui.sources.Length - 1].file == null)); int order = 0; foreach (SourceFileType sft in ui.sources[ui.sources.Length - 1].file) { Console.Error.WriteLine("STEP 5.5.0"); SourceCode ss = new SourceCode(); ss.Type_owner = 'i'; ss.Id_owner_container = i.Id_abstract; ss.Id_owner = i.Id_interface; ss.Contents = sft.contents; ss.File_name = sft.name; ss.File_type = "dll"; ss.Order = order++; Console.Error.WriteLine("STEP 5.5.1"); br.ufc.pargo.hpe.backend.DGAC.BackEnd.scdao.insert(ss); int size = (sft.externalDependency == null ? 0 : sft.externalDependency.Length) + (ui.externalReferences == null ? 0 : ui.externalReferences.Length); Console.Error.WriteLine("STEP 5.5.2"); if (size > 0) { string[] allRefs = new string[size]; if (ui.externalReferences != null) { ui.externalReferences.CopyTo(allRefs, 0); } if (sft.externalDependency != null) { sft.externalDependency.CopyTo(allRefs, ui.externalReferences == null ? 0 : ui.externalReferences.Length); } Console.Error.WriteLine("STEP 5.5.3"); foreach (string extRef in allRefs) { Console.WriteLine("external reference = " + extRef); SourceCodeReference ssr = new SourceCodeReference(); ssr.Type_owner = ss.Type_owner; ssr.Id_owner_container = ss.Id_owner_container; ssr.Id_owner = ss.Id_owner; ssr.File_name = ss.File_name; ssr.Reference = extRef; if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.scrdao.retrieve(ssr) == null) { br.ufc.pargo.hpe.backend.DGAC.BackEnd.scrdao.insert(ssr); } } Console.Error.WriteLine("STEP 5.5.4"); } } Console.Error.WriteLine("STEP 5.6"); br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.insert(i); if (u.slices != null) { IList <string> mS = new List <string>(); IList <String> mP = new List <string>(); IDictionary <string, UnitSliceType> m = new Dictionary <string, UnitSliceType>(); // 1st PASS: COLLECT ALL MAPPINGS SLICE/EXPOSED SLICES foreach (UnitSliceType uS in u.slices) { string sliceName = uS.sliceName; if (uS.port != null) { foreach (string portName in uS.port) { mS.Add(sliceName); mP.Add(portName); } } } // 2nd PASS: foreach (UnitSliceType uS in u.slices) { string sliceName = uS.sliceName; if (mP.Contains(sliceName) && !m.ContainsKey(sliceName)) { Console.Error.WriteLine("ADDING " + sliceName + " TO m"); m.Add(sliceName, uS); } } Console.Error.WriteLine("STEP 5.7"); // 3rd PASS: foreach (UnitSliceType uS in u.slices) { string sname = uS.sliceName; string cRefS = uS.cRef; string uRefS = uS.uRef; InnerComponentType innerC = lookForInnerComponent(cRefS); Console.Error.WriteLine("STEP 5.8"); InnerComponent inner = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(absC.Id_abstract, cRefS); Console.Error.WriteLine("STEP 5.9 ---" + absC.Id_abstract + "," + cRefS); Interface iii = br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.retrieveTop(inner.Id_abstract_inner, uRefS); Console.Error.WriteLine("STEP 5.9.5 ---" + (iii == null)); Slice s = new Slice(); s.Id_abstract = absC.Id_abstract; s.Id_inner = innerC.localRef; s.Id_interface_slice = iii == null ? uRefS : iii.Id_interface; s.Id_interface = uRef; s.Transitive = mP.Contains(sname); Console.Error.WriteLine("STEP 5.10"); string property_name = uS.sliceName; string fstletter = property_name.Substring(0, 1); property_name = fstletter.ToUpper() + property_name.Substring(1, property_name.Length - 1); Console.Error.WriteLine("STEP 5.11"); s.PortName = property_name; if (!s.Transitive && uS.port != null) { Console.Error.WriteLine("STEP 5.12"); foreach (string pname in uS.port) { Console.Error.WriteLine("STEP 5.12.1 -- " + pname + ", " + (m.Count)); UnitSliceType usPort = null; m.TryGetValue(pname, out usPort); Console.Error.WriteLine("STEP 5.12.2 -- " + pname + ", " + (usPort == null)); Console.Error.WriteLine("STEP 5.12.5 -- " + usPort.cRef); InnerComponentType innerCPort = lookForInnerComponent(usPort.cRef); Console.Error.WriteLine("STEP 5.13"); InnerComponent inner2 = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(absC.Id_abstract, usPort.cRef); Interface iii2 = br.ufc.pargo.hpe.backend.DGAC.BackEnd.idao.retrieveTop(inner2.Id_abstract_inner, usPort.uRef); SliceExposed se = new SliceExposed(); se.Id_abstract = s.Id_abstract; se.Id_inner = innerCPort.localRef; se.Id_inner_owner = s.Id_inner; se.Id_interface_slice_owner = s.Id_interface_slice_top; // mudado de s.Id_interface_slice em 28/06/2011 se.Id_interface_slice = iii2 == null ? usPort.uRef : iii2.Id_interface; // achar innerRenaming para cNewName = usPort.cRef e cRef = cRefS (uS.cRef) -- Id_inner_original = cOldName string id_inner_original = lookForRenamingOld(cRefS, usPort.cRef, usPort.inner_replica); se.Id_inner_original = id_inner_original != null ? id_inner_original : usPort.cRef; se.Id_interface_slice_original = usPort.uRef; // DEVE SER O TOP !!! if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.sedao.retrieve2(se.Id_inner, se.Id_interface_slice, se.Id_abstract, se.Id_interface_slice_owner, se.Id_inner_owner) == null) { br.ufc.pargo.hpe.backend.DGAC.BackEnd.sedao.insert(se); } } } if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.sdao.retrieve(s.Id_abstract, s.Id_inner, s.Id_interface_slice, s.Id_interface) == null) { br.ufc.pargo.hpe.backend.DGAC.BackEnd.sdao.insert(s); Console.WriteLine("SLICE REGISTERED " + s.Id_abstract + "/" + s.Id_inner + "/" + s.Id_interface_slice + " --- " + s.Id_interface); } else { Console.WriteLine("SLICE NOT REGISTERED " + s.Id_abstract + "/" + s.Id_inner + "/" + s.Id_interface_slice + " --- " + s.Id_interface); } } } //if (ui.protocol != null) readProtocol(i, ui); } } }
private InterfaceSignature calculateParameters(Interface i, IDictionary <string, int> closed_pars, IDictionary <string, string> open_pars) { // id_abstract, id_interface, partition_index, id_interface_super, partition_index_super, uri_source, class_nargs, id_interface_super_top, partition_index_super_top, order // '43', 'compute_rhs', '0', '', '0', 'adi.ComputeRHS.IComputeRHS', '', '2', 'compute_rhs', '0', '1' InterfaceSignature isig; AbstractComponentFunctor acf = (AbstractComponentFunctor)BackEnd.acfdao.retrieve(i.Id_abstract); isig.package_path = acf.Library_path; isig.the_interface = i; isig.parameters = new Dictionary <string, InterfaceSignature>(); isig.varId = new Dictionary <string, string>(); isig.slice_types = new Dictionary <string, InterfaceSignature>(); IList <Slice> slice_list = BackEnd.sdao.listByInterface(i.Id_abstract, i.Id_interface); // id_abstract, id_inner, id_interface_slice, partition_index, id_interface, property_name, transitive // '43', 'cells_info', 'cells', '0', 'compute_rhs', 'Cells', '0' // '43', 'problem_data', 'problem', '0', 'compute_rhs', 'Problem', '0' foreach (Slice s in slice_list) { InnerComponent ic = BackEnd.icdao.retrieve(s.Id_abstract, s.Id_inner); // id_abstract_owner, id_functor_app, id_inner, id_abstract_inner, parameter_top, transitive, public // 1st loop: // '43', '131', 'cells_info', '31', '', '0', '-1' // 2nd loop: // '43', '132', 'problem_data', '40', '', '0', '-1' int id_functor_app_actual = ic.Id_functor_app; // 1st loop: id_functor_app_actual = 131 // 2nd loop: id_functor_app_actual = 132 Interface i_ = BackEnd.idao.retrieve(ic.Id_abstract_inner, s.Id_interface_slice); // id_abstract, id_interface, partition_index, id_interface_super, partition_index_super, uri_source, class_nargs, id_interface_super_top, partition_index_super_top, order // 1st loop: // '31', 'cells', '0', '', '0', 'common.datapartition.MultiPartitionCells.ICells', '', '0', 'cells', '0', '1', NULL, NULL, NULL // 2nd loop: // '40', 'problem', '0', '', '0', 'adi.data.ProblemDefinition.IProblemDefinition', '', '2', 'problem', '0', '1', NULL, NULL, NULL if (!ic.Parameter_top.Equals("")) // 1st loop: FALSE 2nd loop: FALSE { if (closed_pars.ContainsKey(ic.Parameter_top)) { id_functor_app_actual = closed_pars[ic.Parameter_top]; } InterfaceParameter ip = BackEnd.ipdao.retrieve(i.Id_abstract, i.Id_interface, ic.Parameter_top); AbstractComponentFunctorApplication acfa = BackEnd.acfadao.retrieve(id_functor_app_actual); i_ = BackEnd.idao.retrieveTop(acfa.Id_abstract, ip.Id_unit_parameter); } IList <string> parameters = new List <string>(); IDictionary <string, int> closed_pars_ = new Dictionary <string, int>(); IDictionary <string, string> open_pars_ = new Dictionary <string, string>(); IList <SupplyParameter> sp_list = BackEnd.spdao.list(id_functor_app_actual); // id_parameter, id_functor_app, id_abstract // 1st loop: empty // 2nd loop: // 'class', '132', '40' // 'instance_type', '132', '40' foreach (SupplyParameter sp in sp_list) { if (sp is SupplyParameterComponent) // always false { SupplyParameterComponent spc = (SupplyParameterComponent)sp; if (!closed_pars_.ContainsKey(spc.Id_parameter)) { closed_pars_.Add(spc.Id_parameter, spc.Id_functor_app_actual); } } else if (sp is SupplyParameterParameter) { SupplyParameterParameter spp = (SupplyParameterParameter)sp; // id_parameter, id_functor_app, id_parameter_actual, freeVariable // 2nd outer loop / 1st inner loop: // 'class', '132', 'class', '0' // 2nd outer loop / 2nd inner loop // 'instance_type', '132', 'instance_type', '0' int id_functor_app_actual_parameter; if (closed_pars.ContainsKey(spp.Id_argument)) // ALWAYS FALSE { id_functor_app_actual_parameter = closed_pars[spp.Id_argument]; if (!closed_pars_.ContainsKey(spp.Id_parameter)) { closed_pars_.Add(spp.Id_parameter, id_functor_app_actual_parameter); } } else if (open_pars.ContainsKey(spp.Id_argument)) { if (!open_pars_.ContainsKey(spp.Id_parameter)) { open_pars_.Add(spp.Id_parameter, open_pars[spp.Id_argument]); } // 2nd outer loop / 1st inner loop: add 'class' -> 'C' // 2nd outer loop / 2nd inner loop: add 'instance_type' -> 'I' } else { // NEVER REACH THIS ARM ... } parameters.Add(spp.Id_parameter); // 2nd outer loop / 1st inner loop: add 'class' // 2nd outer loop / 2nd inner loop: add 'instance_type' } } InterfaceSignature par_ic = calculateParameters(i_, closed_pars_, open_pars_); if (!isig.slice_types.ContainsKey(s.PortName)) { isig.slice_types.Add(s.PortName, par_ic); } else { Console.WriteLine("EXISTENTE {0}", s.PortName); } // 1st loop: // InterfaceSignature [ // the_interface = ('31', 'cells', '0', '', '0', 'common.datapartition.MultiPartitionCells.ICells', '', '0', 'cells', '0', '1') // parameters = {} // parId = {} // ] // 2nd loop: // InterfaceSignature [ // the_interface = ('40', 'problem', '0', '', '0', 'adi.data.ProblemDefinition.IProblemDefinition', '', '2', 'problem', '0', '1') // parameters = {C -> InterfaceSignature [ IClass ... ] , I -> InterfaceSignature [ IInstance ... ]} // parId = {C -> class, I -> instance_type} // ] foreach (KeyValuePair <string, InterfaceSignature> is_par in par_ic.parameters) { string par_id = is_par.Key; // 2nd outer loop / 1st inner loop: var_id = C, par_id = class // 2nd outer loop / 2nd inner loop: var_id = I, par_id = instance_type if (parameters.Contains(par_id)) { if (!isig.parameters.ContainsKey(par_id)) { isig.parameters.Add(par_id, is_par.Value); } else { ; } // 2nd outer loop / 1st inner loop: add (class, InterfaceSignature [ IClass ... ]) // 2nd outer loop / 2nd inner loop: add (instance_type, InterfaceSignature [ IInstance[C] ... ]) if (open_pars_.ContainsKey(par_id) && !isig.varId.ContainsKey(par_id)) { isig.varId.Add(par_id, open_pars_[par_id]); } // 2nd outer loop / 1st inner loop: add (class, C) // 2nd outer loop / 2nd inner loop: add (instance_type, I) } } if (!ic.Parameter_top.Equals("")) // never { if (isig.parameters.ContainsKey(ic.Parameter_top)) { isig.parameters.Remove(ic.Parameter_top); } isig.parameters.Add(ic.Parameter_top, par_ic); if (open_pars.ContainsKey(ic.Parameter_top)) { if (isig.varId.ContainsKey(ic.Parameter_top)) { isig.varId.Remove(ic.Parameter_top); } isig.varId.Add(ic.Parameter_top, open_pars[ic.Parameter_top]); } } } return(isig); }