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

Commit e8395d7

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix call attributes for operator overloading.
- Create real call attributes for overloaded operator calls, so that they get e.g. the correct inline attributes. Belonging to [master]: - #2470
1 parent 215b5fc commit e8395d7

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

Compiler/NFFrontEnd/NFCall.mo

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ uniontype Call
609609
protected
610610
Function func;
611611
list<Expression> args;
612-
CallAttributes ca;
613612
list<TypedArg> typed_args;
614613
MatchedFunction matchedFunc;
615614
InstNode scope;
@@ -643,13 +642,7 @@ uniontype Call
643642
ty := evaluateCallType(ty, func, args);
644643
end if;
645644

646-
ca := CallAttributes.CALL_ATTR(
647-
ty, Type.isTuple(ty), Function.isBuiltin(func)
648-
, Function.isImpure(func), Function.isFunctionPointer(func)
649-
, Function.inlineBuiltin(func), DAE.NO_TAIL()
650-
);
651-
652-
call := TYPED_CALL(func, ty, var, args, ca);
645+
call := makeTypedCall(func, args, ty, var);
653646

654647
// If the matching was a vectorized one then create a map call
655648
// using the vectorization dim. This means going through each argument
@@ -660,6 +653,28 @@ uniontype Call
660653

661654
end matchTypedNormalCall;
662655

656+
function makeTypedCall
657+
input Function fn;
658+
input list<Expression> args;
659+
input Type returnType;
660+
input Variability variability;
661+
output Call call;
662+
protected
663+
CallAttributes ca;
664+
algorithm
665+
ca := CallAttributes.CALL_ATTR(
666+
returnType,
667+
Type.isTuple(returnType),
668+
Function.isBuiltin(fn),
669+
Function.isImpure(fn),
670+
Function.isFunctionPointer(fn),
671+
Function.inlineBuiltin(fn),
672+
DAE.NO_TAIL()
673+
);
674+
675+
call := TYPED_CALL(fn, returnType, variability, args, ca);
676+
end makeTypedCall;
677+
663678
function vectorizeCall
664679
input Call base_call;
665680
input FunctionMatchKind mk;

Compiler/NFFrontEnd/NFTypeCheck.mo

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function checkBinaryOperationOperatorRecords
174174
output Type outType;
175175
protected
176176
String opstr;
177-
Function operfn;
177+
Function fn;
178178
InstNode node1, node2;
179179
ComponentRef fn_ref;
180180
list<Function> candidates;
@@ -257,12 +257,14 @@ algorithm
257257

258258
if listLength(exactMatches) == 1 then
259259
matchedFunc ::_ := exactMatches;
260-
outType := Function.returnType(matchedFunc.func);
261-
outExp := Expression.CALL(Call.TYPED_CALL(matchedFunc.func, outType, Variability.CONSTANT, list(Util.tuple31(a) for a in matchedFunc.args)
262-
, CallAttributes.CALL_ATTR(
263-
outType, false, false, false, false, DAE.NO_INLINE(),DAE.NO_TAIL())
264-
)
265-
);
260+
fn := matchedFunc.func;
261+
outType := Function.returnType(fn);
262+
outExp := Expression.CALL(
263+
Call.makeTypedCall(
264+
matchedFunc.func,
265+
list(Util.tuple31(a) for a in matchedFunc.args),
266+
outType,
267+
Variability.CONSTANT));
266268
else
267269
Error.addSourceMessage(Error.AMBIGUOUS_MATCHING_OPERATOR_FUNCTIONS_NFINST,
268270
{Expression.toString(Expression.BINARY(inExp1, inOp, inExp2))
@@ -902,9 +904,8 @@ protected
902904
Expression e1, e2;
903905
MatchKind mk;
904906
algorithm
905-
906907
if Type.isComplex(Type.arrayElementType(type1)) or
907-
Type.isComplex(Type.arrayElementType(type2)) then
908+
Type.isComplex(Type.arrayElementType(type2)) then
908909
(outExp,resultType) := checkBinaryOperationOperatorRecords(exp1, type1, operator, exp2, type2, info);
909910
return;
910911
end if;

0 commit comments

Comments
 (0)