Community
Participate
Working Groups
The IR for a negative literal like -2 or -2.3 is a UnaryExpression, negating a positive literal. It should be a literal with the "isNegated" flag set to true. Egl2MofExpression.visit(IntegerLiteral) and visit(DecimalLiteral) call setIsNegated(true) when the first character in the value is '-'. I'm not sure if this should be kept and/or changed. Egl2MofExpression.visit(FloatLiteral) should be made to work similarly. Right now it never calls setIsNegated. It's not clear to me at this point if the sign should be included in the String returned by org.eclipse.edt.mof.egl.PrimitiveTypeLiteral.getValue(). Paul, Scott, any opinions?
After working more with IRs for numeric literals, I'm convinced that getValue() should include the sign for negative numbers.
Matt, I agree -- otherwise, why have isNegated at all? If we keep and use isNegated, does that mean more work for the generators to handle expressions like "x - -3"; I assume not but wanted to confirm....
I have updated EGL2MofExpression so that the isNegated flag is correctly set for numeric literals
FYI Scott: Paul added getUnsignedValue() to the NumericLiterals so we have lots of ways to get what we want without fiddling with the value ourselves.
Verified.