Browse Source

handle NumericalUnaryExpressions ...

terfloth@itemis.de 13 years ago
parent
commit
f153d1c5af

+ 12 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Expression.ext

@@ -107,6 +107,10 @@ String toCCode(NumericalAddSubtractExpression expression) :
 String toCCode(NumericalMultiplyDivideExpression expression) :
   	" ( " + expression.leftOperand.toCCode() + " ) " + getOperator(expression.operator) + " ( " + expression.rightOperand.toCCode() + " ) ";
 
+
+String toCCode(NumericalUnaryExpression expression) :
+    getOperator(expression.operator) + " ( " + expression.operand.toCCode() + " ) ";
+
 /* can not handle internal scope  */
 
 ExecutionFlow getExecutionFlow(InterfaceScope this) : ((ExecutionFlow)this.eContainer);
@@ -142,6 +146,14 @@ String getOperator(RelationalOperator operator) :
 	  default : ""
 	};
 
+String getOperator(UnaryOperator operator) :
+	switch (operator) {
+	  case (UnaryOperator::negative) : " -"
+	  case (UnaryOperator::positive) : " + "
+	  case (UnaryOperator::complement) : " ~ "
+	  default : ""
+	};
+
 Set[EventDefinition] getInEvents(Scope interface) : 
 	{};