-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add modifier argument to getModelInstance
- Add an argument to getModelInstance that makes it possible to supply a modifier to use when instantiating the model. - Fix Static.elabCodeType to make it possible to use modifiers and expressions as default arguments in ModelicaBuiltin. Fixes #10349
- Loading branch information
Showing
10 changed files
with
143 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
testsuite/openmodelica/instance-API/GetModelInstanceMod4.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// name: GetModelInstanceMod4 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
loadString(" | ||
type MyReal = Real; | ||
|
||
model A | ||
Real x; | ||
replaceable Real y; | ||
end A; | ||
|
||
model M | ||
A a(x = 1, y = 2); | ||
Real z; | ||
end M; | ||
"); | ||
|
||
getModelInstance(M, modifier = $Code((a(redeclare MyReal y = 4, x = 3), z = 5)), prettyPrint = true); | ||
getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "{ | ||
// \"name\": \"M\", | ||
// \"restriction\": \"model\", | ||
// \"elements\": [ | ||
// { | ||
// \"$kind\": \"component\", | ||
// \"name\": \"a\", | ||
// \"type\": { | ||
// \"name\": \"A\", | ||
// \"restriction\": \"model\", | ||
// \"elements\": [ | ||
// { | ||
// \"$kind\": \"component\", | ||
// \"name\": \"x\", | ||
// \"type\": \"Real\", | ||
// \"value\": { | ||
// \"binding\": 3 | ||
// } | ||
// }, | ||
// { | ||
// \"$kind\": \"component\", | ||
// \"name\": \"y\", | ||
// \"type\": { | ||
// \"name\": \"MyReal\", | ||
// \"restriction\": \"type\", | ||
// \"elements\": [ | ||
// { | ||
// \"$kind\": \"extends\", | ||
// \"baseClass\": \"Real\" | ||
// } | ||
// ], | ||
// \"source\": { | ||
// \"filename\": \"<interactive>\", | ||
// \"lineStart\": 2, | ||
// \"columnStart\": 3, | ||
// \"lineEnd\": 2, | ||
// \"columnEnd\": 21 | ||
// } | ||
// }, | ||
// \"value\": { | ||
// \"binding\": 4 | ||
// }, | ||
// \"prefixes\": { | ||
// \"replaceable\": true | ||
// } | ||
// } | ||
// ], | ||
// \"source\": { | ||
// \"filename\": \"<interactive>\", | ||
// \"lineStart\": 4, | ||
// \"columnStart\": 3, | ||
// \"lineEnd\": 7, | ||
// \"columnEnd\": 8 | ||
// } | ||
// }, | ||
// \"modifiers\": { | ||
// \"x\": \"1\", | ||
// \"y\": \"2\" | ||
// } | ||
// }, | ||
// { | ||
// \"$kind\": \"component\", | ||
// \"name\": \"z\", | ||
// \"type\": \"Real\", | ||
// \"value\": { | ||
// \"binding\": 5 | ||
// } | ||
// } | ||
// ], | ||
// \"source\": { | ||
// \"filename\": \"<interactive>\", | ||
// \"lineStart\": 9, | ||
// \"columnStart\": 3, | ||
// \"lineEnd\": 12, | ||
// \"columnEnd\": 8 | ||
// } | ||
// }" | ||
// "" | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters