Skip to content

Commit

Permalink
Remove unused arguments from makeGetValue (#23784)
Browse files Browse the repository at this point in the history
The last 4 arguments to this helper function are no used and we have had
assertions in the code a for while now with no reports of folks
depending on these.
  • Loading branch information
sbc100 authored Feb 27, 2025
1 parent 5a62c4d commit 40b52e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
22 changes: 4 additions & 18 deletions src/parseTools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -412,27 +412,13 @@ function asmFloatToInt(x) {
}

// See makeSetValue
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, _ignore, align) {
assert(typeof align === 'undefined', 'makeGetValue no longer supports align parameter');
assert(
typeof noNeedFirst === 'undefined',
'makeGetValue no longer supports noNeedFirst parameter',
);
if (typeof unsigned !== 'undefined') {
// TODO(sbc): make this into an error at some point.
printErr(
'makeGetValue: Please use u8/u16/u32/u64 unsigned types in favor of additional argument',
);
if (unsigned && type.startsWith('i')) {
type = `u${type.slice(1)}`;
}
} else if (type.startsWith('u')) {
// Set `unsigned` based on the type name.
unsigned = true;
}
function makeGetValue(ptr, pos, type) {
assert(arguments.length == 3, 'makeGetValue expects 3 arguments');

const offset = calcFastOffset(ptr, pos);
if (type === 'i53' || type === 'u53') {
// Set `unsigned` based on the type name.
const unsigned = type.startsWith('u');
return `readI53From${unsigned ? 'U' : 'I'}64(${offset})`;
}

Expand Down
15 changes: 0 additions & 15 deletions test/other/test_parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ addToLibrary({
out('u32: ' + val.toString(16))
assert(val == 0xedcba988);

// unsigned i32 (legacy)
val = {{{ makeGetValue('ptr', '0', 'i32', undefined, /*unsigned=*/true) }}};
out('u32 legacy: ' + val.toString(16))
assert(val == 0xedcba988);

// i16
val = {{{ makeGetValue('ptr', '0', 'i16') }}};
out('i16: ' + val.toString(16))
Expand All @@ -70,11 +65,6 @@ addToLibrary({
out('u16: ' + val.toString(16))
assert(val == 43400);

// unsigned i16 (legacy)
val = {{{ makeGetValue('ptr', '0', 'i16', undefined, /*unsigned=*/true) }}};
out('u16 legacy: ' + val.toString(16))
assert(val == 43400);

// i8
val = {{{ makeGetValue('ptr', '0', 'i8') }}};
out('i8: ' + val.toString(16))
Expand All @@ -85,11 +75,6 @@ addToLibrary({
out('u8: ' + val.toString(16))
assert(val == 0x88);

// unsigned i8 (legacy)
val = {{{ makeGetValue('ptr', '0', 'i8', undefined, /*unsigned=*/true) }}};
out('u8 legacy: ' + val.toString(16))
assert(val == 0x88);

// pointer
val = {{{ makeGetValue('ptr', '0', 'void*') }}};
out('ptr: ' + val.toString(16))
Expand Down
3 changes: 0 additions & 3 deletions test/other/test_parseTools.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ i53: -aabb12345678
u53: ffff5544edcba800
i32: -12345678
u32: edcba988
u32 legacy: edcba988
i16: -5678
u16: a988
u16 legacy: a988
i8: -78
u8: 88
u8 legacy: 88
ptr: edcba988
ptr: edcba988

Expand Down

0 comments on commit 40b52e2

Please sign in to comment.