Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348565 - IR for negative numbers done poorly or not at all
Summary: IR for negative numbers done poorly or not at all
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Paul Harmon CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-07 09:53 EDT by Matt Heitz CLA
Modified: 2017-02-23 14:14 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Heitz CLA 2011-06-07 09:53:55 EDT
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?
Comment 1 Matt Heitz CLA 2011-06-07 16:50:42 EDT
After working more with IRs for numeric literals, I'm convinced that getValue() should include the sign for negative numbers.
Comment 2 Scott Greer CLA 2011-06-10 18:58:08 EDT
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....
Comment 3 Paul Harmon CLA 2011-06-14 10:58:15 EDT
I have updated EGL2MofExpression so that the isNegated flag is correctly set for numeric literals
Comment 4 Matt Heitz CLA 2011-06-14 20:18:43 EDT
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.
Comment 5 Matt Heitz CLA 2011-07-06 16:27:04 EDT
Verified.