@@ -900,44 +900,6 @@ algorithm
900900 args := getApiFunctionArgs(inStatement);
901901
902902 outResult := match(fn_name)
903- // case "setComponentProperties"
904- // algorithm
905- // {Absyn.CREF(componentRef = class_),
906- // Absyn.CREF(componentRef = cr),
907- // Absyn.ARRAY(arrayExp = expl),
908- // // Absyn.ARRAY(arrayExp = {Absyn.STRING(value = parallelism)}),
909- // Absyn.ARRAY(arrayExp = {Absyn.STRING(value = variability)}),
910- // Absyn.ARRAY(arrayExp = {Absyn.BOOL(value = dref1),Absyn.BOOL(value = dref2)}),
911- // Absyn.ARRAY(arrayExp = {Absyn.STRING(value = causality)})/*,
912- // Absyn.ARRAY(arrayExp = {Absyn.STRING(value = isField)})*/} := args;
913-
914- // if listLength(expl) == 5 then
915- // {Absyn.BOOL(value = finalPrefix),
916- // Absyn.BOOL(value = flowPrefix),
917- // Absyn.BOOL(value = streamPrefix),
918- // Absyn.BOOL(value = protected_),
919- // Absyn.BOOL(value = repl)} := expl;
920- // else // Old version of setComponentProperties, without stream.
921- // {Absyn.BOOL(value = finalPrefix),
922- // Absyn.BOOL(value = flowPrefix),
923- // Absyn.BOOL(value = protected_),
924- // Absyn.BOOL(value = repl)} := expl;
925- // streamPrefix := false;
926- // end if;
927-
928- // (outResult, p) := setComponentProperties(AbsynUtil.crefToPath(class_), cr,
929- // finalPrefix, flowPrefix, streamPrefix, protected_, repl,
930- // /*parallelism,*/ variability, {dref1,dref2}, causality, p/*, isField*/);
931- // SymbolTable.setAbsyn(p);
932- // then
933- // outResult;
934-
935- case "getElementsInfo"
936- algorithm
937- {Absyn . CREF (componentRef = cr)} := args;
938- then
939- getElementsInfo(cr, p);
940-
941903 case "getElementsOfVisType"
942904 algorithm
943905 {Absyn . CREF (componentRef = cr)} := args;
@@ -3414,33 +3376,25 @@ protected function constructElementsInfo
34143376 helperfunction to getElementsInfo
34153377 inputs: (string /* \" public \" or \" protected \" */, Absyn.ElementItem list)
34163378 outputs: string"
3417- input String inString;
3418- input list< Absyn . ElementItem > inAbsynElementItemLst;
3419- output String outString;
3379+ input String visibility;
3380+ input list< Absyn . ElementItem > elements;
3381+ output String result;
3382+ protected
3383+ list< String > elements_strl = {};
3384+ String element_str;
34203385algorithm
3421- outString:=
3422- matchcontinue (inString,inAbsynElementItemLst)
3423- local
3424- String visibility_str,s1,element_str,res,s2;
3425- Absyn . ElementItem current;
3426- list< Absyn . ElementItem > rest;
3427- case (_,{}) then "" ;
3428- case (visibility_str,(current :: {})) /* deal with the last element */
3429- equation
3430- s1 = getElementInfo(current);
3431- element_str = stringAppendList({"{ rec(elementvisibility=" ,visibility_str,", " ,s1,") }" });
3432- res = stringAppendList({element_str," \n " });
3433- then
3434- res;
3435- case (visibility_str,(current :: rest))
3436- equation
3437- s1 = getElementInfo(current);
3438- element_str = stringAppendList({"{ rec(elementvisibility=" ,visibility_str,", " ,s1,") }" });
3439- s2 = constructElementsInfo(visibility_str, rest);
3440- res = stringAppendList({element_str,", \n " ,s2});
3441- then
3442- res;
3443- end matchcontinue;
3386+ for e in elements loop
3387+ element_str := getElementInfo(e);
3388+ element_str := stringAppendList({"{ rec(elementvisibility=" , visibility, ", " , element_str, ") }" });
3389+ elements_strl := element_str :: elements_strl;
3390+ end for ;
3391+
3392+ elements_strl := Dangerous . listReverseInPlace(elements_strl);
3393+ result := stringDelimitList(elements_strl, ", \n " );
3394+
3395+ if not listEmpty(elements) then
3396+ result := result + " \n " ;
3397+ end if ;
34443398end constructElementsInfo;
34453399
34463400protected function appendNonEmptyStrings
@@ -3450,84 +3404,50 @@ protected function appendNonEmptyStrings
34503404 input: \"\" , \"\" , \" , \" => \"\"
34513405 \" some \" , \"\" , \" , \" => \" some \"
34523406 \" some \" , \" some \" , \" , \" => \" some, some \" "
3453- input String inString1 ;
3454- input String inString2 ;
3455- input String inString3 ;
3407+ input String str1 ;
3408+ input String str2 ;
3409+ input String delim ;
34563410 output String outString;
34573411algorithm
3458- outString:=
3459- match (inString1,inString2,inString3)
3460- local String s1,s2,str,delimiter;
3461- case ("" ,"" ,_) then "" ;
3462- case (s1,"" ,_) then s1;
3463- case ("" ,s2,_) then s2;
3464- case (s1,s2,delimiter)
3465- equation
3466- str = stringAppendList({s1,delimiter,s2});
3467- then
3468- str;
3469- end match;
3412+ if stringEmpty(str1) then
3413+ outString := str2;
3414+ elseif stringEmpty(str2) then
3415+ outString := str1;
3416+ else
3417+ outString := stringAppendList({str1, delim, str2});
3418+ end if ;
34703419end appendNonEmptyStrings;
34713420
3472- protected function getElementsInfo
3421+ public function getElementsInfo
34733422" author: adrpo@ida
34743423 date : 2005-11-11, changed 2006-02-06 to mirror the new SOURCEINFO
34753424 Retrieves the Info attribute of an element.
34763425 When parsing elements of the class composition, the source:
34773426 -> file name + readonly + start lineno + start columnno + end lineno + end columnno is added to the Element
34783427 and to the Class definition, see SourceInfo.
34793428 This function retrieves the Info contents of the elements of a class."
3480- input Absyn . ComponentRef inComponentRef;
3481- input Absyn . Program inProgram;
3482- output String outString;
3429+ input Absyn . Path classPath;
3430+ input Absyn . Program program;
3431+ output Values . Value result;
3432+ protected
3433+ String result_str, public_str, protected_str;
3434+ Absyn . Class cls;
3435+ list< Absyn . ClassPart > parts;
3436+ list< Absyn . ElementItem > public_elems, protected_elems;
34833437algorithm
3484- outString:=
3485- matchcontinue (inComponentRef,inProgram)
3486- local
3487- Absyn . Path modelpath;
3488- String i,public_str,protected_str,elements_str,str;
3489- Boolean f,e;
3490- Absyn . Restriction r;
3491- list< Absyn . ClassPart > parts;
3492- list< Absyn . ElementItem > public_elementitem_list,protected_elementitem_list;
3493- Absyn . ComponentRef model_;
3494- Absyn . Program p;
3495- /* a class with parts */
3496- case (model_,p)
3497- equation
3498- modelpath = AbsynUtil . crefToPath(model_);
3499- Absyn . CLASS (_,_,_,_,_,Absyn . PARTS (classParts= parts),_) = InteractiveUtil . getPathedClassInProgram(modelpath, p);
3500- public_elementitem_list = InteractiveUtil . getPublicList(parts);
3501- protected_elementitem_list = InteractiveUtil . getProtectedList(parts);
3502- public_str = constructElementsInfo("public" , public_elementitem_list);
3503- protected_str = constructElementsInfo("protected" , protected_elementitem_list);
3504- elements_str = appendNonEmptyStrings(public_str, protected_str, ", " );
3505- str = stringAppendList({"{ " ,elements_str," }" });
3506- then
3507- str;
3508- /* an extended class with parts: model extends M end M; */
3509- case (model_,p)
3510- equation
3511- modelpath = AbsynUtil . crefToPath(model_);
3512- Absyn . CLASS (_,_,_,_,_,Absyn . CLASS_EXTENDS (parts= parts),_) = InteractiveUtil . getPathedClassInProgram(modelpath, p);
3513- public_elementitem_list = InteractiveUtil . getPublicList(parts);
3514- protected_elementitem_list = InteractiveUtil . getProtectedList(parts);
3515- public_str = constructElementsInfo("public" , public_elementitem_list);
3516- protected_str = constructElementsInfo("protected" , protected_elementitem_list);
3517- elements_str = appendNonEmptyStrings(public_str, protected_str, ", " );
3518- str = stringAppendList({"{ " ,elements_str," }" });
3519- then
3520- str;
3521- /* otherwise */
3522- case (model_,p)
3523- equation
3524- modelpath = AbsynUtil . crefToPath(model_);
3525- Absyn . CLASS (_,_,_,_,_,_,_) = InteractiveUtil . getPathedClassInProgram(modelpath, p) "there are no elements in DERIVED, ENUMERATION, OVERLOAD, CLASS_EXTENDS and PDER
3526- maybe later we can give info about that also" ;
3527- then
3528- "{ }" ;
3529- else "Error" ;
3530- end matchcontinue;
3438+ try
3439+ cls := InteractiveUtil . getPathedClassInProgram(classPath, program);
3440+ parts := AbsynUtil . getClassPartsInClass(cls);
3441+ public_str := constructElementsInfo("public" , InteractiveUtil . getPublicList(parts));
3442+ protected_str := constructElementsInfo("protected" , InteractiveUtil . getProtectedList(parts));
3443+ result_str := appendNonEmptyStrings(public_str, protected_str, ", " );
3444+ result_str := stringAppendList({"{ " , result_str, " }" });
3445+ else
3446+ result_str := "Error" ;
3447+ end try ;
3448+
3449+ // getElementsInfo uses a format that can't be represented as a Value, fake it with a CodeType.
3450+ result := ValuesUtil . makeCodeTypeNameStr(result_str);
35313451end getElementsInfo;
35323452
35333453public function getSourceFile
0 commit comments