Skip to content

Commit

Permalink
use a double to store all floating point values (dotnet#5011)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed Sep 4, 2018
1 parent d7cc694 commit ff6fd3b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 23 deletions.
2 changes: 0 additions & 2 deletions src/Common/src/TypeSystem/IL/ILImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ internal enum StackValueKind
NativeInt,
/// <summary>Any float value.</summary>
Float,
/// <summary>Any double value.</summary>
Double,
/// <summary>A managed pointer.</summary>
ByRef,
/// <summary>An object reference.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private void ImportReturn()
_interpreter.SetReturnValue(stackItem.AsIntPtr());
break;
case TypeFlags.Single:
_interpreter.SetReturnValue(stackItem.AsFloat());
_interpreter.SetReturnValue((float)stackItem.AsDouble());
break;
case TypeFlags.Double:
_interpreter.SetReturnValue(stackItem.AsDouble());
Expand Down Expand Up @@ -245,11 +245,6 @@ private void ImportLoadInt(long value, StackValueKind kind)
_interpreter.EvaluationStack.Push(StackItem.FromInt64(value));
}

private void ImportLoadFloat(float value)
{
_interpreter.EvaluationStack.Push(StackItem.FromFloat(value));
}

private void ImportLoadFloat(double value)
{
_interpreter.EvaluationStack.Push(StackItem.FromDouble(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ internal unsafe struct StackItem
[FieldOffset(8)]
private IntPtr _nativeInt;

[FieldOffset(8)]
private float _float;

[FieldOffset(8)]
private double _double;

Expand Down Expand Up @@ -72,20 +69,9 @@ public IntPtr AsIntPtr()
return _nativeInt;
}

public static StackItem FromFloat(float single)
{
return new StackItem { _float = single, _kind = StackValueKind.Float };
}

public float AsFloat()
{
Debug.Assert(_kind == StackValueKind.Float);
return _float;
}

public static StackItem FromDouble(double d)
{
return new StackItem { _double = d, _kind = StackValueKind.Double };
return new StackItem { _double = d, _kind = StackValueKind.Float };
}

public double AsDouble()
Expand Down

0 comments on commit ff6fd3b

Please sign in to comment.