Closed fholm closed 13 years ago
We may be better off taking advantage of Type.GetTypeCode for this and perform appropriate type conversions on the numeric types.
@ChaosPandion: Well, we need to box all numbers do doubles for them to work properly, so there really isn't any choice here since JS requires all numbers to be doubles.
@fholm - That is what I meant except we do it for more than just Int32.
// check for nulls
switch (Type.GetTypeCode(value.GetType()))
{
case TypeCode.Int32:
case TypeCode.Int16:
case TypeCode.Single:
return Box((double)value);
}
aha, clever. I will implement it right away.
Fixed in 5dc5b14afaf9cb4efbdeb98623fe187c242daa4b
If you look at line 176 (https://github.com/fholm/IronJS/blob/master/Src/IronJS.Runtime/BoxedValue.cs#L176) in BoxedValue.cs you will see this code:
This will call the
Box(object value)
overload again which would recurse infinitely, since we don't have an int-overload for Box. Also in my mind this should convert value to a double, and call the Box(double) overload.I didn't write this specific line so not sure on what the reasoning is here.