Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if class exists before linearization. (#8417)
* Check if class exists before linearization. - Fixes #8415. - To be consistent with the simulate() API, add an explicit check for existence of class. - Also fix a probable wrong parameter to the class lookup which asks for the enclosing class when a the actual class is not found inside it. * Move the check for instantiating invlaid class types - The check for attempted instantiation of disallowed class types (packages. functions) is now moved to Inst.instantiateClass_dispatch - This probably does not cover every path. I am almost sure it does not. However, OF is already deprecated. All we care about is the interactive environment working properly before passing on things to NF. * Allow instantiation of TOP level packages/functions
- Loading branch information
Showing
8 changed files
with
80 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
// name: ErrorSimPackage | ||
// status: correct | ||
// cflags: -d=-newInst | ||
// | ||
// This is now allowed temporarily by the OF. For consistency. | ||
// We have test cases assuming we can do this on the .mo files, i.e, | ||
// when it is instantiated as the LAST CLASS in a file it is expected | ||
// to work. But not when it is asked for explicilty. | ||
// So we are going to allow this for now in the OF. | ||
|
||
loadString("package P end P;"); | ||
translateModel(P);getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// false | ||
// "Error: Cannot instantiate P due to class specialization PACKAGE. | ||
// " | ||
// true | ||
// "" | ||
// 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
9 changes: 9 additions & 0 deletions
9
testsuite/openmodelica/interactive-API/instantiateFunction.mo
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,9 @@ | ||
model Base | ||
function Foo | ||
parameter Integer foo = 0; | ||
end Foo; | ||
end Base; | ||
|
||
model Derived | ||
extends Base; | ||
end Derived; |
19 changes: 19 additions & 0 deletions
19
testsuite/openmodelica/interactive-API/instantiateFunction.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,19 @@ | ||
// name: instantiateFunction.mos | ||
// keywords: instantiate API function | ||
// status: correct | ||
// cflags: -d=-newInst | ||
// | ||
// Checks that functions can not be instantiated. | ||
// | ||
|
||
loadFile("instantiateFunction.mo"); getErrorString(); | ||
instantiateModel(Derived.Foo); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// "" | ||
// "[openmodelica/interactive-API/instantiateFunction.mo:2:3-4:10:writable] Error: Cannot instantiate Derived.Foo due to class specialization pure function. | ||
// Error: Error occurred while flattening model Derived.Foo | ||
// " | ||
// endResult |