Skip to content

Commit

Permalink
More conv opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Feb 2, 2025
1 parent ad7b829 commit 4d58c2f
Showing 1 changed file with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,9 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
case ILOpcode.conv_u2:
case ILOpcode.conv_u4:
case ILOpcode.conv_u8:
{
case ILOpcode.conv_r4:
case ILOpcode.conv_r8:
{
StackEntry popped = stack.Pop();
if (popped.ValueKind.WithNormalizedNativeInt(context) == StackValueKind.Int32)
{
Expand Down Expand Up @@ -874,6 +876,12 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
case ILOpcode.conv_u8:
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64((uint)val));
break;
case ILOpcode.conv_r4:
stack.Push(StackValueKind.Float, ValueTypeValue.FromSingle((float)val));
break;
case ILOpcode.conv_r8:
stack.Push(StackValueKind.Float, ValueTypeValue.FromDouble((double)val));
break;
default:
return Status.Fail(methodIL.OwningMethod, opcode);
}
Expand Down Expand Up @@ -912,6 +920,12 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
case ILOpcode.conv_u8:
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64(val));
break;
case ILOpcode.conv_r4:
stack.Push(StackValueKind.Float, ValueTypeValue.FromSingle((float)val));
break;
case ILOpcode.conv_r8:
stack.Push(StackValueKind.Float, ValueTypeValue.FromDouble((double)val));
break;
default:
return Status.Fail(methodIL.OwningMethod, opcode);
}
Expand All @@ -921,9 +935,36 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
double val = popped.Value.AsDouble();
switch (opcode)
{
case ILOpcode.conv_i1:
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((sbyte)val));
break;
case ILOpcode.conv_i2:
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((short)val));
break;
case ILOpcode.conv_i4:
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((int)val));
break;
case ILOpcode.conv_i8:
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64((long)val));
break;
case ILOpcode.conv_u1:
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((byte)val));
break;
case ILOpcode.conv_u2:
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((ushort)val));
break;
case ILOpcode.conv_u4:
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((int)val));
break;
case ILOpcode.conv_u8:
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64((long)val));
break;
case ILOpcode.conv_r4:
stack.Push(StackValueKind.Float, ValueTypeValue.FromSingle((float)val));
break;
case ILOpcode.conv_r8:
stack.Push(StackValueKind.Float, ValueTypeValue.FromDouble(val));
break;
default:
return Status.Fail(methodIL.OwningMethod, opcode);
}
Expand Down

0 comments on commit 4d58c2f

Please sign in to comment.