Skip to content

Commit

Permalink
Run forc-fmt with #5410
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Dec 21, 2023
1 parent 06f4738 commit 2118c9a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
24 changes: 12 additions & 12 deletions sway-lib-core/src/primitive_conversions.sw
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl u64 {
/// ```
pub fn as_u256(self) -> u256 {
let input = (0u64, 0u64, 0u64, self);
asm( input: input ) {
asm(input: input) {
input: u256
}
}
Expand All @@ -41,7 +41,7 @@ impl u32 {
/// }
/// ```
pub fn as_u64(self) -> u64 {
asm( input: self ) {
asm(input: self) {
input: u64
}
}
Expand All @@ -66,7 +66,7 @@ impl u32 {
/// ```
pub fn as_u256(self) -> u256 {
let input = (0u64, 0u64, 0u64, self.as_u64());
asm( input: input ) {
asm(input: input) {
input: u256
}
}
Expand All @@ -89,7 +89,7 @@ impl u16 {
/// }
/// ```
pub fn as_u32(self) -> u32 {
asm( input: self ) {
asm(input: self) {
input: u32
}
}
Expand All @@ -110,7 +110,7 @@ impl u16 {
/// }
/// ```
pub fn as_u64(self) -> u64 {
asm( input: self ) {
asm(input: self) {
input: u64
}
}
Expand All @@ -135,7 +135,7 @@ impl u16 {
/// ```
pub fn as_u256(self) -> u256 {
let input = (0u64, 0u64, 0u64, self.as_u64());
asm( input: input ) {
asm(input: input) {
input: u256
}
}
Expand All @@ -158,7 +158,7 @@ impl u8 {
/// }
/// ```
pub fn as_u16(self) -> u16 {
asm( input: self ) {
asm(input: self) {
input: u16
}
}
Expand All @@ -179,7 +179,7 @@ impl u8 {
/// }
/// ```
pub fn as_u32(self) -> u32 {
asm( input: self ) {
asm(input: self) {
input: u32
}
}
Expand All @@ -200,7 +200,7 @@ impl u8 {
/// }
/// ```
pub fn as_u64(self) -> u64 {
asm( input: self ) {
asm(input: self) {
input: u64
}
}
Expand All @@ -225,7 +225,7 @@ impl u8 {
/// ```
pub fn as_u256(self) -> u256 {
let input = (0u64, 0u64, 0u64, self.as_u64());
asm( input: input ) {
asm(input: input) {
input: u256
}
}
Expand All @@ -248,7 +248,7 @@ impl b256 {
/// }
/// ```
pub fn as_u256(self) -> u256 {
asm( input: self ) {
asm(input: self) {
input: u256
}
}
Expand All @@ -271,7 +271,7 @@ impl u256 {
/// }
/// ```
pub fn as_b256(self) -> b256 {
asm( input: self ) {
asm(input: self) {
input: b256
}
}
Expand Down
26 changes: 13 additions & 13 deletions sway-lib-core/src/raw_ptr.sw
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ impl raw_ptr {
/// ```
pub fn read<T>(self) -> T {
if __is_reference_type::<T>() {
asm( ptr: self ) {
asm(ptr: self) {
ptr: T
}
} else if __eq(__size_of::<T>(), 1) {
asm( ptr: self, val ) {
asm(ptr: self, val) {
lb val ptr i0;
val: T
}
} else {
asm( ptr: self, val ) {
asm(ptr: self, val) {
lw val ptr i0;
val: T
}
Expand Down Expand Up @@ -132,7 +132,7 @@ impl raw_ptr {
/// ```
pub fn copy_to<T>(self, dst: Self, count: u64) {
let len = __mul(count, __size_of::<T>());
asm( dst: dst, src: self, len: len ) {
asm(dst: dst, src: self, len: len) {
mcp dst src len;
};
}
Expand All @@ -154,15 +154,15 @@ impl raw_ptr {
/// ```
pub fn write<T>(self, val: T) {
if __is_reference_type::<T>() {
asm( dst: self, src: val, count: __size_of_val(val) ) {
asm(dst: self, src: val, count: __size_of_val(val)) {
mcp dst src count;
};
} else if __eq(__size_of::<T>(), 1) {
asm( ptr: self, val: val ) {
asm(ptr: self, val: val) {
sb ptr val i0;
};
} else {
asm( ptr: self, val: val ) {
asm(ptr: self, val: val) {
sw ptr val i0;
};
}
Expand All @@ -186,10 +186,10 @@ impl raw_ptr {
/// }
/// ```
pub fn write_byte(self, val: u8) {
let val_ptr = asm( r1: val ) {
let val_ptr = asm(r1: val) {
r1: raw_ptr
};
asm( ptr: self, val: val_ptr ) {
asm(ptr: self, val: val_ptr) {
sb ptr val i0;
};
}
Expand All @@ -212,7 +212,7 @@ impl raw_ptr {
/// }
/// ```
pub fn read_byte(self) -> u8 {
asm( r1: self, r2 ) {
asm(r1: self, r2) {
lb r2 r1 i0;
r2: u8
}
Expand All @@ -239,7 +239,7 @@ impl raw_ptr {
/// }
/// ```
pub fn copy_bytes_to(self, dst: Self, count: u64) {
asm( dst: dst, src: self, len: count ) {
asm(dst: dst, src: self, len: count) {
mcp dst src len;
};
}
Expand Down Expand Up @@ -267,7 +267,7 @@ impl raw_ptr {
/// }
/// ```
pub fn add_uint_offset(self, offset: u64) -> Self {
asm( ptr: self, offset: offset, new ) {
asm(ptr: self, offset: offset, new) {
add new ptr offset;
new: raw_ptr
}
Expand Down Expand Up @@ -296,7 +296,7 @@ impl raw_ptr {
/// }
/// ```
pub fn sub_uint_offset(self, offset: u64) -> Self {
asm( ptr: self, offset: offset, new ) {
asm(ptr: self, offset: offset, new) {
sub new ptr offset;
new: raw_ptr
}
Expand Down
4 changes: 2 additions & 2 deletions sway-lib-core/src/raw_slice.sw
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub trait AsRawSlice {
///
/// * [raw_slice] - The newly created `raw_slice`.
fn from_parts(parts: (raw_ptr, u64)) -> raw_slice {
asm( ptr: parts ) {
asm(ptr: parts) {
ptr: raw_slice
}
}
Expand All @@ -64,7 +64,7 @@ fn from_parts(parts: (raw_ptr, u64)) -> raw_slice {
///
/// * [(raw_ptr, u64)] - A tuple of the location in memory of the original `raw_slice` and its length.
fn into_parts(slice: raw_slice) -> (raw_ptr, u64) {
asm( ptr: slice ) {
asm(ptr: slice) {
ptr: (raw_ptr, u64)
}
}
Expand Down
8 changes: 4 additions & 4 deletions sway-lib-core/src/str.sw
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ library;
impl str {
/// Return a `raw_ptr` to the beginning of the string slice on the heap
pub fn as_ptr(self) -> raw_ptr {
let (ptr, _) = asm( s: self ) {
let (ptr, _) = asm(s: self) {
s: (raw_ptr, u64)
};
ptr
}

/// Return the length of the string slice in bytes
pub fn len(self) -> u64 {
let (_, len) = asm( s: self ) {
let (_, len) = asm(s: self) {
s: (raw_ptr, u64)
};
len
Expand All @@ -23,14 +23,14 @@ pub fn from_str_array<S>(s: S) -> str {
let str_size = __size_of_str_array::<S>();
let src = __addr_of(s);

let ptr = asm( size: __size_of::<S>(), dest, src: src ) {
let ptr = asm(size: __size_of::<S>(), dest, src: src) {
aloc size;
move dest hp;
mcp dest src size;
dest: raw_ptr
};

asm( s: (ptr, str_size) ) {
asm(s: (ptr, str_size)) {
s: str
}
}

0 comments on commit 2118c9a

Please sign in to comment.