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

Change machine word constructors to have no default argument. #1938

Merged
merged 1 commit into from
Jun 3, 2017
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
14 changes: 7 additions & 7 deletions packages/builtin/signed.pony
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
primitive I8 is _SignedInteger[I8, U8]
new create(value: I8 = 0) => value
new create(value: I8) => value
new from[A: (Number & Real[A] val)](a: A) => a.i8()

new min_value() => -0x80
Expand Down Expand Up @@ -38,7 +38,7 @@ primitive I8 is _SignedInteger[I8, U8]
@"llvm.smul.with.overflow.i8"[(I8, Bool)](this, y)

primitive I16 is _SignedInteger[I16, U16]
new create(value: I16 = 0) => value
new create(value: I16) => value
new from[A: (Number & Real[A] val)](a: A) => a.i16()

new min_value() => -0x8000
Expand Down Expand Up @@ -77,7 +77,7 @@ primitive I16 is _SignedInteger[I16, U16]
@"llvm.smul.with.overflow.i16"[(I16, Bool)](this, y)

primitive I32 is _SignedInteger[I32, U32]
new create(value: I32 = 0) => value
new create(value: I32) => value
new from[A: (Number & Real[A] val)](a: A) => a.i32()

new min_value() => -0x8000_0000
Expand Down Expand Up @@ -116,7 +116,7 @@ primitive I32 is _SignedInteger[I32, U32]
@"llvm.smul.with.overflow.i32"[(I32, Bool)](this, y)

primitive I64 is _SignedInteger[I64, U64]
new create(value: I64 = 0) => value
new create(value: I64) => value
new from[A: (Number & Real[A] val)](a: A) => a.i64()

new min_value() => -0x8000_0000_0000_0000
Expand Down Expand Up @@ -155,7 +155,7 @@ primitive I64 is _SignedInteger[I64, U64]
@"llvm.smul.with.overflow.i64"[(I64, Bool)](this, y)

primitive ILong is _SignedInteger[ILong, ULong]
new create(value: ILong = 0) => value
new create(value: ILong) => value
new from[A: (Number & Real[A] val)](a: A) => a.ilong()

new min_value() =>
Expand Down Expand Up @@ -242,7 +242,7 @@ primitive ILong is _SignedInteger[ILong, ULong]
end

primitive ISize is _SignedInteger[ISize, USize]
new create(value: ISize = 0) => value
new create(value: ISize) => value
new from[A: (Number & Real[A] val)](a: A) => a.isize()

new min_value() =>
Expand Down Expand Up @@ -329,7 +329,7 @@ primitive ISize is _SignedInteger[ISize, USize]
end

primitive I128 is _SignedInteger[I128, U128]
new create(value: I128 = 0) => value
new create(value: I128) => value
new from[A: (Number & Real[A] val)](a: A) => a.i128()

new min_value() => -0x8000_0000_0000_0000_0000_0000_0000_0000
Expand Down
14 changes: 7 additions & 7 deletions packages/builtin/unsigned.pony
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
primitive U8 is _UnsignedInteger[U8]
new create(value: U8 = 0) => value
new create(value: U8) => value
new from[B: (Number & Real[B] val)](a: B) => a.u8()

new min_value() => 0
Expand Down Expand Up @@ -41,7 +41,7 @@ primitive U8 is _UnsignedInteger[U8]
@"llvm.umul.with.overflow.i8"[(U8, Bool)](this, y)

primitive U16 is _UnsignedInteger[U16]
new create(value: U16 = 0) => value
new create(value: U16) => value
new from[A: (Number & Real[A] val)](a: A) => a.u16()

new min_value() => 0
Expand Down Expand Up @@ -83,7 +83,7 @@ primitive U16 is _UnsignedInteger[U16]
@"llvm.umul.with.overflow.i16"[(U16, Bool)](this, y)

primitive U32 is _UnsignedInteger[U32]
new create(value: U32 = 0) => value
new create(value: U32) => value
new from[A: (Number & Real[A] val)](a: A) => a.u32()

new min_value() => 0
Expand Down Expand Up @@ -125,7 +125,7 @@ primitive U32 is _UnsignedInteger[U32]
@"llvm.umul.with.overflow.i32"[(U32, Bool)](this, y)

primitive U64 is _UnsignedInteger[U64]
new create(value: U64 = 0) => value
new create(value: U64) => value
new from[A: (Number & Real[A] val)](a: A) => a.u64()

new min_value() => 0
Expand Down Expand Up @@ -167,7 +167,7 @@ primitive U64 is _UnsignedInteger[U64]
@"llvm.umul.with.overflow.i64"[(U64, Bool)](this, y)

primitive ULong is _UnsignedInteger[ULong]
new create(value: ULong = 0) => value
new create(value: ULong) => value
new from[A: (Number & Real[A] val)](a: A) => a.ulong()

new min_value() => 0
Expand Down Expand Up @@ -261,7 +261,7 @@ primitive ULong is _UnsignedInteger[ULong]
end

primitive USize is _UnsignedInteger[USize]
new create(value: USize = 0) => value
new create(value: USize) => value
new from[A: (Number & Real[A] val)](a: A) => a.usize()

new min_value() => 0
Expand Down Expand Up @@ -355,7 +355,7 @@ primitive USize is _UnsignedInteger[USize]
end

primitive U128 is _UnsignedInteger[U128]
new create(value: U128 = 0) => value
new create(value: U128) => value
new from[A: (Number & Real[A] val)](a: A) => a.u128()

new min_value() => 0
Expand Down
8 changes: 4 additions & 4 deletions packages/serialise/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class _MachineWords
var i32: I32 = 0x12345678
var i64: I64 = 0x7EDCBA9876543210
var i128: I128 = 0x7EDCBA9876543210123456789ABCDEFE
var ilong: ILong = ILong(1) << (ILong.bitwidth() - 1)
var isize: ISize = ISize(1) << (ISize.bitwidth() - 1)
var ilong: ILong = ILong(1) << (ILong(0).bitwidth() - 1)
var isize: ISize = ISize(1) << (ISize(0).bitwidth() - 1)
var f32: F32 = 1.2345e-13
var f64: F64 = 9.82643431e19

Expand All @@ -49,8 +49,8 @@ class _StructWords
var u32: U32 = 0x12345678
var u64: U64 = 0xFEDCBA9876543210
var u128: U128 = 0xFEDCBA9876543210123456789ABCDEFE
var ulong: ULong = 1 << (ULong.bitwidth() - 1)
var usize: USize = 1 << (USize.bitwidth() - 1)
var ulong: ULong = 1 << (ULong(0).bitwidth() - 1)
var usize: USize = 1 << (USize(0).bitwidth() - 1)

fun eq(that: _StructWords box): Bool =>
(u8 == that.u8) and
Expand Down