Community
Participate
Working Groups
IntegerLiteral has getIntValue and setIntValue methods. They operate with an Integer. But an integer literal in EGL can be up to 32 digits long, much too big for a puny Integer. I see no calls of setIntValue anywhere, and two methods that call getIntValue in the JS generator. (Scott: the condition where you call getIntValue in IntTypeTemplate is either going to be true, or it'll die due to a NumberFormatException if the integer is too big for an int.) I suggest that we remove getIntValue and setIntValue, but add methods to tell us about the size of the literal: public boolean fitsInInt() { return new BigInteger( getValue() ).bitLength() < 32; } public boolean fitsInSmallint() { return new BigInteger( getValue() ).bitLength() < 16; } public boolean fitsInBigint() { return new BigInteger( getValue() ).bitLength() < 64; } Paul & Scott: I'd like your feedback on this suggestion.
I agree with both of Matt's points: clearly, we need the IntegerLiteral to support as many digits as the language allows and we also need convenience routines that characterize the size of a given literal. However, I'm not sure the suggested fitsIn<type> methods result in the best design; I can see generator code cascading thru the different sizes trying to find the one that fits best, which with the suggested logic will repeatedly construct temporary BigIntegers.
I have updated IntegerLiteral.getType() as per bug 384644. I have not removed the getIntValue and setIntValue methods, because JS generation is still using the getter. Scott, please let me know when you have removed the references to this method from your code and i will delete the methods from the mof class.
Changing the owner to Paul since he started doing the work.
The setter was removed, and nobody was calling the getter anymore, so I removed it too. While doing this, I noticed that PrimitiveTypeLiteral has public void getObjectValue(); A getter that returns void! Now that's thinking outside the box! I changed it to return Object, and added a reasonable implementation in all the PrimitiveTypeLiterals. It returns getValue() in most cases.
Closing.