Changeset 35a0fde5 in OpenModelica
- Timestamp:
- 2023-03-28T15:58:19+02:00 (13 months ago)
- Parents:
- 92b6780
- git-author:
- Per Östlund <perost86@…> (03/28/23 15:08:15)
- git-committer:
- Per Östlund <perost86@…> (03/28/23 15:58:19)
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/NFFrontEnd/NFInstNode.mo
r00c7cfda r35a0fde5 836 836 function getDerivedNode 837 837 input InstNode node; 838 input Boolean recursive = true; 838 839 output InstNode derived; 839 840 algorithm 840 841 derived := match node 841 case CLASS_NODE(nodeType = InstNodeType.BASE_CLASS(parent = derived)) 842 then getDerivedNode(derived); 842 case CLASS_NODE() then getDerivedNode2(node, node.nodeType, recursive); 843 843 else node; 844 844 end match; 845 845 end getDerivedNode; 846 847 function getDerivedNode2 848 input InstNode node; 849 input InstNodeType ty; 850 input Boolean recursive; 851 output InstNode derived; 852 algorithm 853 derived := match ty 854 case InstNodeType.BASE_CLASS() then if recursive then getDerivedNode(ty.parent) else ty.parent; 855 case InstNodeType.DERIVED_CLASS() then getDerivedNode2(node, ty.ty, recursive); 856 else node; 857 end match; 858 end getDerivedNode2; 846 859 847 860 function updateClass -
OMCompiler/Compiler/Script/NFApi.mo
rb37d4a5e r35a0fde5 1089 1089 json := JSON.addPair("restriction", 1090 1090 JSON.makeString(Restriction.toString(InstNode.restriction(node))), json); 1091 json := dumpJSONSCodeMod(SCodeUtil.elementMod(def), scope, json);1092 1091 1093 1092 json := JSON.addPairNotNull("prefixes", dumpJSONClassPrefixes(def, node), json); … … 1225 1224 InstNode node; 1226 1225 SCode.Element cls_def, ext_def; 1226 SCode.Mod mod; 1227 1227 algorithm 1228 1228 InstanceTree.CLASS(node = node) := ext; … … 1231 1231 1232 1232 json := JSON.addPair("$kind", JSON.makeString("extends"), json); 1233 json := dumpJSONSCodeMod( SCodeUtil.elementMod(ext_def), node, json);1233 json := dumpJSONSCodeMod(getExtendsModifier(ext_def, node), node, json); 1234 1234 json := dumpJSONCommentOpt(SCodeUtil.getElementComment(ext_def), node, json); 1235 1235 … … 1240 1240 end if; 1241 1241 end dumpJSONExtends; 1242 1243 function getExtendsModifier 1244 input SCode.Element definition; 1245 input InstNode node; 1246 output SCode.Mod mod; 1247 algorithm 1248 mod := match definition 1249 case SCode.EXTENDS() then definition.modifications; 1250 case SCode.CLASS() then SCodeUtil.elementMod(InstNode.definition(InstNode.getDerivedNode(node, recursive = false))); 1251 else SCode.NOMOD(); 1252 end match; 1253 end getExtendsModifier; 1242 1254 1243 1255 function dumpJSONReplaceableClass -
doc/instanceAPI/getModelInstance.schema.json
r3347ee4 r35a0fde5 20 20 "description": "The class prefixes", 21 21 "$ref": "#/definitions/classPrefixes" 22 },23 "modifiers": {24 "description": "Modifier from the SCode",25 "type": "#/definitions/scodeModifier"26 22 }, 27 23 "comment": { -
testsuite/openmodelica/instance-API/GetModelInstanceAttributes1.mos
rfbe0da1f r35a0fde5 40 40 // \"name\": \"Angle\", 41 41 // \"restriction\": \"type\", 42 // \"modifiers\": {43 // \"quantity\": {44 // \"final\": true,45 // \"$value\": \"\\\"Angle\\\"\"46 // }47 // },48 42 // \"elements\": [ 49 43 // { 50 44 // \"$kind\": \"extends\", 45 // \"modifiers\": { 46 // \"quantity\": { 47 // \"final\": true, 48 // \"$value\": \"\\\"Angle\\\"\" 49 // } 50 // }, 51 51 // \"baseClass\": \"Real\" 52 52 // } -
testsuite/openmodelica/instance-API/GetModelInstanceDerived1.mos
r7ce7c53 r35a0fde5 55 55 // \"name\": \"RealInput2\", 56 56 // \"restriction\": \"type\", 57 // \"modifiers\": {58 // \"start\": \"1.0\"59 // },60 57 // \"elements\": [ 61 58 // { 62 59 // \"$kind\": \"extends\", 60 // \"modifiers\": { 61 // \"start\": \"1.0\" 62 // }, 63 63 // \"baseClass\": { 64 64 // \"name\": \"RealInput\", -
testsuite/openmodelica/instance-API/GetModelInstanceDerived2.mos
r7ce7c53 r35a0fde5 40 40 // \"name\": \"RealInput2\", 41 41 // \"restriction\": \"type\", 42 // \"modifiers\": {43 // \"start\": \"1.0\"44 // },45 42 // \"elements\": [ 46 43 // { 47 44 // \"$kind\": \"extends\", 45 // \"modifiers\": { 46 // \"start\": \"1.0\" 47 // }, 48 48 // \"baseClass\": { 49 49 // \"name\": \"RealInput\", -
testsuite/openmodelica/instance-API/GetModelInstanceExtends3.mos
rfbe0da1f r35a0fde5 8 8 loadString(" 9 9 type MyReal 10 extends Real ;10 extends Real(start = 1.0); 11 11 end MyReal; 12 12 13 13 model M 14 MyReal x ;14 MyReal x(unit = \"m\"); 15 15 end M; 16 16 "); … … 35 35 // { 36 36 // \"$kind\": \"extends\", 37 // \"modifiers\": { 38 // \"start\": \"1.0\" 39 // }, 37 40 // \"baseClass\": \"Real\" 38 41 // } … … 45 48 // \"columnEnd\": 13 46 49 // } 50 // }, 51 // \"modifiers\": { 52 // \"unit\": \"\\\"m\\\"\" 47 53 // } 48 54 // } -
testsuite/openmodelica/instance-API/Makefile
rb37d4a5e r35a0fde5 24 24 GetModelInstanceDerived1.mos \ 25 25 GetModelInstanceDerived2.mos \ 26 GetModelInstanceDerived3.mos \ 26 27 GetModelInstanceDuplicate1.mos \ 27 28 GetModelInstanceEnum1.mos \
Note: See TracChangeset
for help on using the changeset viewer.