Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 9216359

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] ExternalObject fixes.
- Added missing calls to typeFunctionBody when typing ExternalObject structors, so the whole function is typed and not only the inputs. - Collect ExternalObject structors in functions too. Belonging to [master]: - #2373
1 parent a473365 commit 9216359

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

Compiler/NFFrontEnd/NFFlatten.mo

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -843,16 +843,7 @@ algorithm
843843
algorithm
844844
// TODO: Collect functions from the component's type attributes.
845845

846-
// Collect external object structors.
847-
() := match ty
848-
case Type.COMPLEX(complexTy = ComplexType.EXTERNAL_OBJECT())
849-
algorithm
850-
funcs := collectExternalObjectStructors(ty.complexTy, funcs);
851-
then
852-
();
853-
854-
else ();
855-
end match;
846+
funcs := collectTypeFuncs(ty, funcs);
856847

857848
// Collect functions used in the component's binding, if it has one.
858849
if Binding.isBound(binding) then
@@ -864,6 +855,22 @@ algorithm
864855
end match;
865856
end collectComponentFuncs;
866857

858+
function collectTypeFuncs
859+
input Type ty;
860+
input output FunctionTree funcs;
861+
algorithm
862+
() := match ty
863+
// Collect external object structors.
864+
case Type.COMPLEX(complexTy = ComplexType.EXTERNAL_OBJECT())
865+
algorithm
866+
funcs := collectExternalObjectStructors(ty.complexTy, funcs);
867+
then
868+
();
869+
870+
else ();
871+
end match;
872+
end collectTypeFuncs;
873+
867874
function collectExternalObjectStructors
868875
input ComplexType ty;
869876
input output FunctionTree funcs;
@@ -1079,6 +1086,7 @@ algorithm
10791086
algorithm
10801087
for c in cls_tree.components loop
10811088
comp := InstNode.component(c);
1089+
funcs := collectTypeFuncs(Component.getType(comp), funcs);
10821090
binding := Component.getBinding(comp);
10831091

10841092
if Binding.isBound(binding) then

Compiler/NFFrontEnd/NFRestriction.mo

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ public
118118
end match;
119119
end isFunction;
120120

121+
function isRecord
122+
input Restriction res;
123+
output Boolean isFunction;
124+
algorithm
125+
isFunction := match res
126+
case RECORD() then true;
127+
else false;
128+
end match;
129+
end isRecord;
130+
121131
function isType
122132
input Restriction res;
123133
output Boolean isType;

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,14 @@ algorithm
215215
CachedData.FUNCTION({fn}, typed, special) := InstNode.getFuncCache(constructor);
216216
if not typed then
217217
fn := Function.typeFunction(fn);
218+
fn := Function.typeFunctionBody(fn);
218219
InstNode.setFuncCache(constructor, CachedData.FUNCTION({fn}, true, special));
219220
end if;
220221

221222
CachedData.FUNCTION({fn}, typed, special) := InstNode.getFuncCache(destructor);
222223
if not typed then
223224
fn := Function.typeFunction(fn);
225+
fn := Function.typeFunctionBody(fn);
224226
InstNode.setFuncCache(destructor, CachedData.FUNCTION({fn}, true, special));
225227
end if;
226228
end typeExternalObjectStructors;

0 commit comments

Comments
 (0)