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

Commit

Permalink
Completed support for checking Unary operators in checkUnaryOperation.
Browse files Browse the repository at this point in the history
Now also removing unary plus since it is a noop and there is no unary plus operator in DAE.Operator
  • Loading branch information
petfr authored and OpenModelica-Hudson committed Dec 8, 2016
1 parent 67fd997 commit 0ab52c8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Compiler/NFFrontEnd/NFTypeCheck.mo
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ algorithm
end try;
end checkBinaryOperation;


public function checkUnaryOperation
"petfr:
Type checks arithmetic unary operations. Both for simple scalar types and
Expand All @@ -661,13 +660,20 @@ protected
String e1_str, ty1_str, s1;
algorithm
try
unaryType := type1; // ?? correct?, since no type change for unary, see matchType?
// Arithmetic type expected for Unary operators, i.e., UMINUS, UMINUS_ARR; UPLUS removed
true := Types.isNumericType(type1);

unaryType := type1;
op := Expression.setOpType(operator, unaryType);
unaryExp := DAE.UNARY(op, exp1);
unaryExp := match op
case DAE.ADD() then exp1; // If UNARY +, +exp1, remove it since no unary DAE.ADD
else DAE.UNARY(op, exp1);
end match;
else
e1_str := ExpressionDump.printExpStr(exp1); // ??Remove possible Error message since Unary?
e1_str := ExpressionDump.printExpStr(exp1);
ty1_str := Types.unparseTypeNoAttr(type1);
s1 := "' " + e1_str + DAEDump.dumpOperatorSymbol(operator) + " '";
s1 := "' " + e1_str + DAEDump.dumpOperatorSymbol(operator) + " '" +
" Arithmetic type expected for this unary operator ";
Error.addSourceMessage(Error.UNRESOLVABLE_TYPE, {s1, ty1_str}, Absyn.dummyInfo);
fail();
end try;
Expand Down

0 comments on commit 0ab52c8

Please sign in to comment.