Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of package constants
- Try to fetch the binding of a package constant from its parent if it doesn't have a binding and is a record field. - Add case for cref in Expression.nthRecordElement that returns a new cref instead of a record element expression. - Disable collection of package constants in functions, since it doesn't work properly anyway. - Move collection of package constants before collection of functions, so that function in package constants are also collected.
- Loading branch information
Showing
8 changed files
with
116 additions
and
20 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
38 changes: 38 additions & 0 deletions
38
testsuite/flattening/modelica/scodeinst/PackageConstant4.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,38 @@ | ||
// name: PackageConstant4 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
package P | ||
record R | ||
Real x; | ||
end R; | ||
|
||
parameter R r1(x = ext_func()); | ||
parameter R r2[1] = {r1}; | ||
|
||
function ext_func | ||
output Real x; | ||
|
||
external "C"; | ||
end ext_func; | ||
end P; | ||
|
||
model PackageConstant4 | ||
Real x = P.r2[1].x; | ||
end PackageConstant4; | ||
|
||
// Result: | ||
// function P.ext_func | ||
// output Real x; | ||
// | ||
// external "C" x = ext_func(); | ||
// end P.ext_func; | ||
// | ||
// class PackageConstant4 | ||
// parameter Real P.r1.x = P.ext_func(); | ||
// parameter Real P.r2[1].x = P.r1.x; | ||
// Real x = P.r2[1].x; | ||
// end PackageConstant4; | ||
// endResult |