Skip to content

Separate FloatOps.Generated from IntOps.Generated #1368

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

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
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
276 changes: 276 additions & 0 deletions Src/IronPython/Runtime/Operations/FloatOps.Generated.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

using System;
using System.Numerics;
using System.Runtime.CompilerServices;

using Microsoft.Scripting.Runtime;

#pragma warning disable 675

namespace IronPython.Runtime.Operations {

#region Generated FloatOps

// *** BEGIN GENERATED CODE ***
// generated by function: gen_float from: generate_alltypes.py

public static partial class SingleOps {
// Unary Operations
[SpecialName]
public static Single Plus(Single x) {
return x;
}
[SpecialName]
public static Single Negate(Single x) {
return (Single)(-(x));
}
[SpecialName]
public static Single Abs(Single x) {
return (Single)(Math.Abs(x));
}
public static bool __bool__(Single x) {
return (x != 0);
}

public static object __trunc__(Single x) {
if (x >= int.MaxValue || x <= int.MinValue) {
return (BigInteger)x;
} else {
return (int)x;
}
}

// Binary Operations - Arithmetic
[SpecialName]
public static Single Add(Single x, Single y) {
return x + y;
}
[SpecialName]
public static Single Subtract(Single x, Single y) {
return x - y;
}
[SpecialName]
public static Single Multiply(Single x, Single y) {
return x * y;
}
[SpecialName]
public static Single TrueDivide(Single x, Single y) {
if (y == 0) throw PythonOps.ZeroDivisionError();
return x / y;
}
[SpecialName]
public static Single FloorDivide(Single x, Single y) {
if (y == 0) throw PythonOps.ZeroDivisionError();
return (Single)Math.Floor(x / y);
}

// Conversion operators
[SpecialName, ExplicitConversionMethod]
public static SByte ConvertToSByte(Single x) {
if (SByte.MinValue <= x && x <= SByte.MaxValue) {
return (SByte)x;
}
throw Converter.CannotConvertOverflow("SByte", x);
}
[SpecialName, ExplicitConversionMethod]
public static Byte ConvertToByte(Single x) {
if (Byte.MinValue <= x && x <= Byte.MaxValue) {
return (Byte)x;
}
throw Converter.CannotConvertOverflow("Byte", x);
}
[SpecialName, ExplicitConversionMethod]
public static Int16 ConvertToInt16(Single x) {
if (Int16.MinValue <= x && x <= Int16.MaxValue) {
return (Int16)x;
}
throw Converter.CannotConvertOverflow("Int16", x);
}
[SpecialName, ExplicitConversionMethod]
public static UInt16 ConvertToUInt16(Single x) {
if (UInt16.MinValue <= x && x <= UInt16.MaxValue) {
return (UInt16)x;
}
throw Converter.CannotConvertOverflow("UInt16", x);
}
[SpecialName, ExplicitConversionMethod]
public static Int32 ConvertToInt32(Single x) {
if (Int32.MinValue <= x && x <= Int32.MaxValue) {
return (Int32)x;
}
throw Converter.CannotConvertOverflow("Int32", x);
}
[SpecialName, ExplicitConversionMethod]
public static UInt32 ConvertToUInt32(Single x) {
if (UInt32.MinValue <= x && x <= UInt32.MaxValue) {
return (UInt32)x;
}
throw Converter.CannotConvertOverflow("UInt32", x);
}
[SpecialName, ExplicitConversionMethod]
public static Int64 ConvertToInt64(Single x) {
if (Int64.MinValue <= x && x <= Int64.MaxValue) {
return (Int64)x;
}
throw Converter.CannotConvertOverflow("Int64", x);
}
[SpecialName, ExplicitConversionMethod]
public static UInt64 ConvertToUInt64(Single x) {
if (UInt64.MinValue <= x && x <= UInt64.MaxValue) {
return (UInt64)x;
}
throw Converter.CannotConvertOverflow("UInt64", x);
}
[SpecialName, ImplicitConversionMethod]
public static Double ConvertToDouble(Single x) {
return (Double)x;
}

// Public API - Numerics
[PropertyMethod, SpecialName]
public static Single Getreal(Single x) {
return x;
}
[PropertyMethod, SpecialName]
public static Single Getimag(Single x) {
return (Single)0;
}
public static Single conjugate(Single x) {
return x;
}
}

public static partial class DoubleOps {
// Unary Operations
[SpecialName]
public static Double Plus(Double x) {
return x;
}
[SpecialName]
public static Double Negate(Double x) {
return (Double)(-(x));
}
[SpecialName]
public static Double Abs(Double x) {
return (Double)(Math.Abs(x));
}
public static bool __bool__(Double x) {
return (x != 0);
}

public static object __trunc__(Double x) {
if (x >= int.MaxValue || x <= int.MinValue) {
return (BigInteger)x;
} else {
return (int)x;
}
}

// Binary Operations - Arithmetic
[SpecialName]
public static Double Add(Double x, Double y) {
return x + y;
}
[SpecialName]
public static Double Subtract(Double x, Double y) {
return x - y;
}
[SpecialName]
public static Double Multiply(Double x, Double y) {
return x * y;
}
[SpecialName]
public static Double TrueDivide(Double x, Double y) {
if (y == 0) throw PythonOps.ZeroDivisionError();
return x / y;
}
[SpecialName]
public static Double FloorDivide(Double x, Double y) {
if (y == 0) throw PythonOps.ZeroDivisionError();
return (Double)Math.Floor(x / y);
}

// Conversion operators
[SpecialName, ExplicitConversionMethod]
public static SByte ConvertToSByte(Double x) {
if (SByte.MinValue <= x && x <= SByte.MaxValue) {
return (SByte)x;
}
throw Converter.CannotConvertOverflow("SByte", x);
}
[SpecialName, ExplicitConversionMethod]
public static Byte ConvertToByte(Double x) {
if (Byte.MinValue <= x && x <= Byte.MaxValue) {
return (Byte)x;
}
throw Converter.CannotConvertOverflow("Byte", x);
}
[SpecialName, ExplicitConversionMethod]
public static Int16 ConvertToInt16(Double x) {
if (Int16.MinValue <= x && x <= Int16.MaxValue) {
return (Int16)x;
}
throw Converter.CannotConvertOverflow("Int16", x);
}
[SpecialName, ExplicitConversionMethod]
public static UInt16 ConvertToUInt16(Double x) {
if (UInt16.MinValue <= x && x <= UInt16.MaxValue) {
return (UInt16)x;
}
throw Converter.CannotConvertOverflow("UInt16", x);
}
[SpecialName, ExplicitConversionMethod]
public static Int32 ConvertToInt32(Double x) {
if (Int32.MinValue <= x && x <= Int32.MaxValue) {
return (Int32)x;
}
throw Converter.CannotConvertOverflow("Int32", x);
}
[SpecialName, ExplicitConversionMethod]
public static UInt32 ConvertToUInt32(Double x) {
if (UInt32.MinValue <= x && x <= UInt32.MaxValue) {
return (UInt32)x;
}
throw Converter.CannotConvertOverflow("UInt32", x);
}
[SpecialName, ExplicitConversionMethod]
public static Int64 ConvertToInt64(Double x) {
if (Int64.MinValue <= x && x <= Int64.MaxValue) {
return (Int64)x;
}
throw Converter.CannotConvertOverflow("Int64", x);
}
[SpecialName, ExplicitConversionMethod]
public static UInt64 ConvertToUInt64(Double x) {
if (UInt64.MinValue <= x && x <= UInt64.MaxValue) {
return (UInt64)x;
}
throw Converter.CannotConvertOverflow("UInt64", x);
}
[SpecialName, ImplicitConversionMethod]
public static Single ConvertToSingle(Double x) {
return (Single)x;
}

// Public API - Numerics
[PropertyMethod, SpecialName]
public static Double Getreal(Double x) {
return x;
}
[PropertyMethod, SpecialName]
public static Double Getimag(Double x) {
return (Double)0;
}
public static Double conjugate(Double x) {
return x;
}
}


// *** END GENERATED CODE ***

#endregion
}
Loading