Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Change ComponentRef.updateNodeType so it only sets the type of nodes that actually have a type. - Change Dimension.mapExp to use fromExp instead of directly creating an EXP dimension, since the new dimension might be e.g. an Integer. - Improve EvalConstants to better handle constants in dimensions. - Change EvalConstants.evaluateFunction to use evaluateAlgorithm for the function body rather than just mapping the expressions, since evaluateAlgorithm also handles e.g. the types of statements. - Allow evaluation of dimensions to fail in functions, since they might be dependent on the input arguments.
- Loading branch information
Showing
10 changed files
with
121 additions
and
14 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
52 changes: 52 additions & 0 deletions
52
testsuite/flattening/modelica/scodeinst/FunctionRecordArg3.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,52 @@ | ||
// name: FunctionRecordArg3 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
record BaseR | ||
constant Integer n; | ||
parameter Real x[n]; | ||
end BaseR; | ||
|
||
function f | ||
input BaseR r; | ||
output Real x; | ||
algorithm | ||
x := r.x * r.x; | ||
end f; | ||
|
||
record R = BaseR(n = 2); | ||
|
||
model FunctionRecordArg3 | ||
R r(x = {1, 2}); | ||
Real x = f(r); | ||
end FunctionRecordArg3; | ||
|
||
// Result: | ||
// function BaseR "Automatically generated record constructor for BaseR" | ||
// constant Integer n; | ||
// input Real[n] x; | ||
// output BaseR res; | ||
// end BaseR; | ||
// | ||
// function R "Automatically generated record constructor for R" | ||
// protected Integer n = 2; | ||
// input Real[2] x; | ||
// output R res; | ||
// end R; | ||
// | ||
// function f | ||
// input BaseR r; | ||
// output Real x; | ||
// algorithm | ||
// x := r.x * r.x; | ||
// end f; | ||
// | ||
// class FunctionRecordArg3 | ||
// constant Integer r.n = 2; | ||
// parameter Real r.x[1] = 1.0; | ||
// parameter Real r.x[2] = 2.0; | ||
// Real x = f(r); | ||
// end FunctionRecordArg3; | ||
// 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
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