Skip to content

Commit

Permalink
update for recent compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Dec 17, 2024
1 parent 8b2c779 commit 406d116
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
8 changes: 6 additions & 2 deletions source/mir/bignum/decimal.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ struct Decimal(uint size64)
void toString(C = char, W)(ref scope W w, NumericSpec spec = NumericSpec.init) const scope
if(isSomeChar!C && isMutable!C)
{
scope C[] _buffer;
if (false) w.put(_buffer);
() @trusted {
assert(spec.format == NumericSpec.Format.exponent || spec.format == NumericSpec.Format.human);
import mir.utility: _expect;
// handle special values
Expand Down Expand Up @@ -212,6 +215,7 @@ struct Decimal(uint size64)
auto expLength = printSignedToTail(exponent, buffer0[$ - N - 16 .. $ - 16], '+');
buffer[$ - ++expLength] = spec.exponentChar;
w.put(buffer[$ - expLength .. $]);
} ();
}

@safe:
Expand Down Expand Up @@ -422,7 +426,7 @@ struct Decimal(uint size64)
}

///
ref opOpAssign(string op, size_t rhsMaxSize64)(ref const Decimal!rhsMaxSize64 rhs) @safe pure return
ref opOpAssign(string op, size_t rhsMaxSize64)(ref const Decimal!rhsMaxSize64 rhs) @trusted pure return
if (op == "+" || op == "-")
{
import mir.utility: max;
Expand Down Expand Up @@ -450,7 +454,7 @@ struct Decimal(uint size64)

///
version(mir_bignum_test)
@safe pure nothrow @nogc
@trusted pure nothrow @nogc
unittest
{
import mir.test: should;
Expand Down
2 changes: 1 addition & 1 deletion source/mir/bignum/fp.d
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ struct Fp(uint size)

///
Fp!(coefficientizeA + coefficientizeB) extendedMul(bool noSpecial = false, uint coefficientizeA, uint coefficientizeB)(Fp!coefficientizeA a, Fp!coefficientizeB b)
@safe pure nothrow @nogc
@trusted pure nothrow @nogc
{
import mir.bignum.fixed: extendedMul;
import mir.checkedint: adds;
Expand Down
6 changes: 3 additions & 3 deletions source/mir/bignum/integer.d
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ struct BigInt(uint size64)
}

///
BigInt copy() @property
BigInt copy() @property @trusted
{
BigInt ret = void;
ret.sign = sign;
Expand Down Expand Up @@ -479,7 +479,7 @@ struct BigInt(uint size64)

///ditto
ref powMod()(scope BigUIntView!(const size_t) exponent, scope ref const BigInt modulus)
@safe pure nothrow @nogc return scope
@trusted pure nothrow @nogc return scope
{
pragma(inline, false);

Expand Down Expand Up @@ -654,7 +654,7 @@ struct BigInt(uint size64)
remainder or quotient from the truncated division
+/
ref opOpAssign(string op : "*", size_t rhsSize64)(scope const ref BigInt!rhsSize64 rhs)
@safe pure nothrow @nogc return
@trusted pure nothrow @nogc return
{
BigInt!(size64 + rhsSize64) c = void;
c.multiply(this, rhs);
Expand Down
2 changes: 1 addition & 1 deletion source/mir/bignum/internal/dec2float.d
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private template bigSize(T)
}
}

@optStrategy("minsize")
@optStrategy("minsize") @trusted
private T algorithmM(T)(scope const size_t[] coefficients, long exponent)
if ((is(T == float) || is(T == double) || is(T == real)))
in (coefficients.length)
Expand Down
34 changes: 17 additions & 17 deletions source/mir/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -295,27 +295,27 @@ Performs `nothrow` and `@nogc` string to native type conversion.
Rseturns: true if success and false otherwise.
+/
bool fromString(T, C)(scope const(C)[] str, ref T value)
if (isSomeChar!C)
bool fromString(T, C)(scope const(C)[] str, ref T value) @trusted
if (isSomeChar!C && isFloatingPoint!T)
{
static if (isFloatingPoint!T)
{
import mir.bignum.decimal: Decimal, DecimalExponentKey;
import mir.utility: _expect;
import mir.bignum.decimal: Decimal, DecimalExponentKey;
import mir.utility: _expect;

Decimal!128 decimal = void;
DecimalExponentKey key;
auto ret = decimal.fromStringImpl(str, key);
if (_expect(ret, true))
{
value = cast(T) decimal;
}
return ret;
}
else
Decimal!128 decimal = void;
DecimalExponentKey key;
auto ret = decimal.fromStringImpl(str, key);
if (_expect(ret, true))
{
return parse!T(str, value) && str.length == 0;
value = cast(T) decimal;
}
return ret;
}

/// ditto
bool fromString(T, C)(scope const(C)[] str, ref T value)
if (isSomeChar!C && !isFloatingPoint!T)
{
return parse!T(str, value) && str.length == 0;
}

///
Expand Down

0 comments on commit 406d116

Please sign in to comment.