Changeset c62eaf3 in OpenModelica
- Timestamp:
- 2022-05-19T12:30:41+02:00 (2 years ago)
- Parents:
- e6238a1
- git-author:
- Per Östlund <perost86@…> (05/19/22 12:28:47)
- git-committer:
- Per Östlund <perost86@…> (05/19/22 12:30:41)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/Script/NFApi.mo
rdfa5c6bb rc62eaf3 843 843 record COMPONENT 844 844 InstNode node; 845 InstanceTree cls; 845 846 end COMPONENT; 846 847 … … 850 851 list<InstanceTree> components; 851 852 end CLASS; 853 854 record EMPTY 855 end EMPTY; 852 856 end InstanceTree; 853 857 … … 880 884 output InstanceTree tree; 881 885 protected 886 Class cls; 882 887 ClassTree cls_tree; 883 888 list<InstanceTree> exts, components; 884 889 array<InstNode> ext_nodes; 885 890 algorithm 886 cls_tree := Class.classTree(InstNode.getClass(node)); 891 cls := InstNode.getClass(node); 892 893 if Class.isBuiltin(cls) then 894 tree := InstanceTree.EMPTY(); 895 return; 896 end if; 897 898 cls_tree := Class.classTree(cls); 887 899 888 900 tree := match cls_tree … … 906 918 input Mutable<InstNode> compNode; 907 919 output InstanceTree tree; 908 algorithm 909 tree := InstanceTree.COMPONENT(Mutable.access(compNode)); 920 protected 921 InstNode node; 922 InstanceTree cls; 923 algorithm 924 node := Mutable.access(compNode); 925 cls := buildInstanceTree(InstNode.classScope(node)); 926 tree := InstanceTree.COMPONENT(node, cls); 910 927 end buildInstanceTreeComponent; 911 928 … … 919 936 Sections sections; 920 937 Option<SCode.Comment> cmt; 938 JSON j; 921 939 algorithm 922 940 InstanceTree.CLASS(node = node, exts = exts, components = comps) := tree; … … 937 955 if root then 938 956 sections := Class.getSections(InstNode.getClass(node)); 939 json := JSON.addPair("connections", dumpJSONConnections(sections), json); 940 json := JSON.addPair("replaceable", dumpJSONReplaceableElements(node), json); 957 j := dumpJSONConnections(sections); 958 if not JSON.isNull(j) then 959 json := JSON.addPair("connections", j, json); 960 end if; 961 962 j := dumpJSONReplaceableElements(node); 963 if not JSON.isNull(j) then 964 json := JSON.addPair("replaceable", j, json); 965 end if; 941 966 end if; 942 967 end dumpJSONInstanceTree; … … 983 1008 SCode.Comment cmt; 984 1009 SCode.Annotation ann; 985 algorithm 986 InstanceTree.COMPONENT(node = node) := component; 1010 InstanceTree cls; 1011 algorithm 1012 InstanceTree.COMPONENT(node = node, cls = cls) := component; 987 1013 node := InstNode.resolveOuter(node); 988 1014 comp := InstNode.component(node); … … 992 1018 case (Component.TYPED_COMPONENT(), SCode.Element.COMPONENT()) 993 1019 algorithm 994 json := JSON.addPair("type", dumpJSON TypeName(comp.ty), json);1020 json := JSON.addPair("type", dumpJSONComponentType(cls, comp.ty), json); 995 1021 996 1022 if Type.isArray(comp.ty) then … … 1028 1054 end match; 1029 1055 end dumpJSONComponent; 1056 1057 function dumpJSONComponentType 1058 input InstanceTree cls; 1059 input Type ty; 1060 output JSON json; 1061 algorithm 1062 json := match cls 1063 case InstanceTree.CLASS() then dumpJSONInstanceTree(cls); 1064 else dumpJSONTypeName(ty); 1065 end match; 1066 end dumpJSONComponentType; 1030 1067 1031 1068 function dumpJSONTypeName … … 1164 1201 function dumpJSONConnections 1165 1202 input Sections sections; 1166 output JSON json = JSON. emptyArray();1203 output JSON json = JSON.makeNull(); 1167 1204 algorithm 1168 1205 () := match sections … … 1196 1233 function dumpJSONReplaceableElements 1197 1234 input InstNode clsNode; 1198 output JSON json = JSON. emptyArray();1235 output JSON json = JSON.makeNull(); 1199 1236 protected 1200 1237 ClassTree cls_tree; -
testsuite/openmodelica/instance-API/GetModelInstanceAnnotation1.mos
rdfa5c6bb rc62eaf3 35 35 // } 36 36 // } 37 // }, 38 // \"connections\": [ 39 // 40 // ], 41 // \"replaceable\": [ 42 // 43 // ] 37 // } 44 38 // }" 45 39 // endResult -
testsuite/openmodelica/instance-API/GetModelInstanceAttributes1.mos
r4cb8721 rc62eaf3 54 54 // } 55 55 // } 56 // }, 57 // \"connections\": [ 58 // 59 // ], 60 // \"replaceable\": [ 61 // 62 // ] 56 // } 63 57 // }" 64 58 // endResult -
testsuite/openmodelica/instance-API/GetModelInstanceComment1.mos
raa8243e0 rc62eaf3 18 18 // "{ 19 19 // \"name\": \"M\", 20 // \"comment\": \"A class\", 21 // \"connections\": [ 22 // 23 // ], 24 // \"replaceable\": [ 25 // 26 // ] 20 // \"comment\": \"A class\" 27 21 // }" 28 22 // endResult -
testsuite/openmodelica/instance-API/GetModelInstanceConnection1.mos
rdfa5c6bb rc62eaf3 37 37 // \"components\": { 38 38 // \"c2\": { 39 // \"type\": \"C\", 39 // \"type\": { 40 // \"name\": \"C\", 41 // \"components\": { 42 // \"f\": { 43 // \"type\": \"Real\", 44 // \"modifier\": \"\", 45 // \"prefixes\": { 46 // \"public\": true, 47 // \"final\": false, 48 // \"inner\": false, 49 // \"outer\": false, 50 // \"replaceable\": false, 51 // \"redeclare\": false, 52 // \"connector\": \"flow\", 53 // \"variability\": \"\", 54 // \"direction\": \"\" 55 // } 56 // }, 57 // \"e\": { 58 // \"type\": \"Real\", 59 // \"modifier\": \"\", 60 // \"prefixes\": { 61 // \"public\": true, 62 // \"final\": false, 63 // \"inner\": false, 64 // \"outer\": false, 65 // \"replaceable\": false, 66 // \"redeclare\": false, 67 // \"connector\": \"\", 68 // \"variability\": \"\", 69 // \"direction\": \"\" 70 // } 71 // } 72 // } 73 // }, 40 74 // \"modifier\": \"\", 41 75 // \"prefixes\": { … … 52 86 // }, 53 87 // \"c1\": { 54 // \"type\": \"C\", 88 // \"type\": { 89 // \"name\": \"C\", 90 // \"components\": { 91 // \"f\": { 92 // \"type\": \"Real\", 93 // \"modifier\": \"\", 94 // \"prefixes\": { 95 // \"public\": true, 96 // \"final\": false, 97 // \"inner\": false, 98 // \"outer\": false, 99 // \"replaceable\": false, 100 // \"redeclare\": false, 101 // \"connector\": \"flow\", 102 // \"variability\": \"\", 103 // \"direction\": \"\" 104 // } 105 // }, 106 // \"e\": { 107 // \"type\": \"Real\", 108 // \"modifier\": \"\", 109 // \"prefixes\": { 110 // \"public\": true, 111 // \"final\": false, 112 // \"inner\": false, 113 // \"outer\": false, 114 // \"replaceable\": false, 115 // \"redeclare\": false, 116 // \"connector\": \"\", 117 // \"variability\": \"\", 118 // \"direction\": \"\" 119 // } 120 // } 121 // } 122 // }, 55 123 // \"modifier\": \"\", 56 124 // \"prefixes\": { … … 71 139 // \"components\": { 72 140 // \"c3\": { 73 // \"type\": \"C\", 141 // \"type\": { 142 // \"name\": \"C\", 143 // \"components\": { 144 // \"f\": { 145 // \"type\": \"Real\", 146 // \"modifier\": \"\", 147 // \"prefixes\": { 148 // \"public\": true, 149 // \"final\": false, 150 // \"inner\": false, 151 // \"outer\": false, 152 // \"replaceable\": false, 153 // \"redeclare\": false, 154 // \"connector\": \"flow\", 155 // \"variability\": \"\", 156 // \"direction\": \"\" 157 // } 158 // }, 159 // \"e\": { 160 // \"type\": \"Real\", 161 // \"modifier\": \"\", 162 // \"prefixes\": { 163 // \"public\": true, 164 // \"final\": false, 165 // \"inner\": false, 166 // \"outer\": false, 167 // \"replaceable\": false, 168 // \"redeclare\": false, 169 // \"connector\": \"\", 170 // \"variability\": \"\", 171 // \"direction\": \"\" 172 // } 173 // } 174 // } 175 // }, 74 176 // \"modifier\": \"\", 75 177 // \"prefixes\": { … … 104 206 // \"rhs\": \"c2\" 105 207 // } 106 // ],107 // \"replaceable\": [108 //109 208 // ] 110 209 // }" -
testsuite/openmodelica/instance-API/GetModelInstanceDuplicate1.mos
r4cb8721 rc62eaf3 61 61 // } 62 62 // } 63 // }, 64 // \"connections\": [ 65 // 66 // ], 67 // \"replaceable\": [ 68 // 69 // ] 63 // } 70 64 // }" 71 65 // endResult -
testsuite/openmodelica/instance-API/GetModelInstanceReplaceable1.mos
r4cb8721 rc62eaf3 26 26 // \"components\": { 27 27 // \"m\": { 28 // \"type\": \"M\", 28 // \"type\": { 29 // \"name\": \"M\", 30 // \"components\": { 31 // \"x\": { 32 // \"type\": \"Real\", 33 // \"modifier\": \"\", 34 // \"prefixes\": { 35 // \"public\": true, 36 // \"final\": false, 37 // \"inner\": false, 38 // \"outer\": false, 39 // \"replaceable\": false, 40 // \"redeclare\": false, 41 // \"connector\": \"\", 42 // \"variability\": \"\", 43 // \"direction\": \"\" 44 // } 45 // } 46 // } 47 // }, 29 48 // \"modifier\": \"\", 30 49 // \"prefixes\": { … … 59 78 // } 60 79 // }, 61 // \"connections\": [62 //63 // ],64 80 // \"replaceable\": [ 65 81 // {
Note: See TracChangeset
for help on using the changeset viewer.