Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main
Open

Sourcery refactored main branch#1
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Aug 11, 2023

Copy link
Copy Markdown

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from ludoplex August 11, 2023 00:46
if isinstance(vec[0], ValType):
return vec
return [t for name,t in vec]
return vec if isinstance(vec[0], ValType) else [t for name,t in vec]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FuncType.extract_types refactored with the following changes:

Comment on lines -226 to +224
if n <= 16: return 2
return 4
return 2 if n <= 16 else 4

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function alignment_flags refactored with the following changes:

Comment on lines -272 to +269
if n <= 16: return 2
return 4 * num_i32_flags(labels)
return 2 if n <= 16 else 4 * num_i32_flags(labels)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function size_flags refactored with the following changes:

Comment on lines -371 to +367
self.rt_to_table = dict()
self.rt_to_table = {}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function HandleTables.__init__ refactored with the following changes:

Comment on lines -428 to +424
if math.isnan(f):
return reinterpret_i32_as_float(CANONICAL_FLOAT32_NAN)
return f
return reinterpret_i32_as_float(CANONICAL_FLOAT32_NAN) if math.isnan(f) else f

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function canonicalize32 refactored with the following changes:

Comment on lines -894 to +881
i = vi.next('i' + str(core_width))
i = vi.next(f'i{str(core_width)}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lift_flat_unsigned refactored with the following changes:

Comment on lines -899 to +889
i = vi.next('i' + str(core_width))
i = vi.next(f'i{str(core_width)}')
assert(0 <= i < (1 << core_width))
i %= (1 << t_width)
if i >= (1 << (t_width - 1)):
return i - (1 << t_width)
return i
return i - (1 << t_width) if i >= (1 << (t_width - 1)) else i

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lift_flat_signed refactored with the following changes:

Comment on lines -917 to +902
record = {}
for f in fields:
record[f.label] = lift_flat(cx, vi, f.t)
return record
return {f.label: lift_flat(cx, vi, f.t) for f in fields}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lift_flat_record refactored with the following changes:

Comment on lines -938 to +920
if c.t is None:
v = None
else:
v = lift_flat(cx, CoerceValueIter(), c.t)
v = None if c.t is None else lift_flat(cx, CoerceValueIter(), c.t)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lift_flat_variant refactored with the following changes:

Comment on lines -985 to +964
return [Value('i' + str(core_bits), i)]
return [Value(f'i{str(core_bits)}', i)]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lower_flat_signed refactored with the following changes:

Comment on lines -1006 to +985
if c.t is None:
payload = []
else:
payload = lower_flat(cx, case_value, c.t)
payload = [] if c.t is None else lower_flat(cx, case_value, c.t)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lower_flat_variant refactored with the following changes:

Comment on lines -1035 to +1017
if len(flat_types) > max_flat:
ptr = vi.next('i32')
tuple_type = Tuple(ts)
trap_if(ptr != align_to(ptr, alignment(tuple_type)))
trap_if(ptr + size(tuple_type) > len(cx.opts.memory))
return list(load(cx, ptr, tuple_type).values())
else:
if len(flat_types) <= max_flat:
return [ lift_flat(cx, vi, t) for t in ts ]
ptr = vi.next('i32')
tuple_type = Tuple(ts)
trap_if(ptr != align_to(ptr, alignment(tuple_type)))
trap_if(ptr + size(tuple_type) > len(cx.opts.memory))
return list(load(cx, ptr, tuple_type).values())

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lift_values refactored with the following changes:

self.last_alloc = ret + new_size
if self.last_alloc > len(self.memory):
print('oom: have {} need {}'.format(len(self.memory), self.last_alloc))
print(f'oom: have {len(self.memory)} need {self.last_alloc}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Heap.realloc refactored with the following changes:

elif src_encoding == 'utf16':
encoded = s.encode('utf-16-le')
tagged_code_units = int(len(encoded) / 2)
tagged_code_units = len(encoded) // 2

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_string refactored with the following changes:


if got != v:
fail("test_roundtrip({},{},{}) got {}".format(t, v, caller_args, got))
fail(f"test_roundtrip({t},{v},{caller_args}) got {got}")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_roundtrip refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants