Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use unchecked to skip range checks from BigInteger to smaller types #1205

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ private static void HandleBigIntegerExplicitConversion(MethodConvert methodConve
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(sbyte.MinValue);
Expand All @@ -211,6 +213,8 @@ private static void HandleBigIntegerToSByte(MethodConvert methodConvert, Semanti
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(sbyte.MinValue);
Expand All @@ -226,6 +230,8 @@ private static void HandleBigIntegerToByte(MethodConvert methodConvert, Semantic
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(byte.MinValue);
Expand All @@ -241,6 +247,8 @@ private static void HandleBigIntegerToShort(MethodConvert methodConvert, Semanti
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(short.MinValue);
Expand All @@ -256,6 +264,8 @@ private static void HandleBigIntegerToUShort(MethodConvert methodConvert, Semant
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(ushort.MinValue);
Expand All @@ -271,6 +281,8 @@ private static void HandleBigIntegerToInt(MethodConvert methodConvert, SemanticM
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(int.MinValue);
Expand All @@ -286,6 +298,8 @@ private static void HandleBigIntegerToUInt(MethodConvert methodConvert, Semantic
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(uint.MinValue);
Expand All @@ -301,6 +315,8 @@ private static void HandleBigIntegerToLong(MethodConvert methodConvert, Semantic
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(long.MinValue);
Expand All @@ -316,6 +332,8 @@ private static void HandleBigIntegerToULong(MethodConvert methodConvert, Semanti
{
if (arguments is not null)
methodConvert.PrepareArgumentsForMethod(model, symbol, arguments);
if (!methodConvert._checkedStack.Peek())
return;
JumpTarget endTarget = new();
methodConvert.AddInstruction(OpCode.DUP);
methodConvert.Push(ulong.MinValue);
Expand Down
Loading