Skip to content

Commit 6989421

Browse files
osa1Commit Queue
authored andcommitted
[dart2wasm] Remove unused JS interop helpers
Change-Id: I87c57cf59119e06c82660fd671eaf75c7b2ec0a6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418120 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Ömer Ağacan <[email protected]>
1 parent 8af371c commit 6989421

File tree

1 file changed

+0
-115
lines changed

1 file changed

+0
-115
lines changed

sdk/lib/_internal/wasm/lib/js_helper.dart

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ class JSArrayIterableAdapter<T> extends EfficientLengthIterable<T>
130130
int get length => array.length;
131131
}
132132

133-
// Convert to double to avoid converting to [BigInt] in the case of int64.
134-
WasmExternRef? getConstructorString(String constructor) =>
135-
getPropertyRaw(globalThisRaw(), constructor.toExternRef);
136-
137133
Object jsObjectToDartObject(WasmExternRef? ref) =>
138134
unsafeCastOpaque<Object>(ref.internalize());
139135

@@ -142,55 +138,9 @@ WasmExternRef jsObjectFromDartObject(Object object) =>
142138

143139
bool isJSUndefined(WasmExternRef? o) => JS<bool>('o => o === undefined', o);
144140

145-
bool isJSBoolean(WasmExternRef? o) =>
146-
JS<bool>("o => typeof o === 'boolean'", o);
147-
148-
bool isJSNumber(WasmExternRef? o) => JS<bool>("o => typeof o === 'number'", o);
149-
150-
bool isJSBigInt(WasmExternRef? o) => JS<bool>("o => typeof o === 'bigint'", o);
151-
152-
bool isJSString(WasmExternRef? o) => JS<bool>("o => typeof o === 'string'", o);
153-
154-
bool isJSSymbol(WasmExternRef? o) => JS<bool>("o => typeof o === 'symbol'", o);
155-
156141
bool isJSFunction(WasmExternRef? o) =>
157142
JS<bool>("o => typeof o === 'function'", o);
158143

159-
bool isJSInt8Array(WasmExternRef? o) =>
160-
JS<bool>("o => o instanceof Int8Array", o);
161-
162-
bool isJSUint8Array(WasmExternRef? o) =>
163-
JS<bool>("o => o instanceof Uint8Array", o);
164-
165-
bool isJSUint8ClampedArray(WasmExternRef? o) =>
166-
JS<bool>("o => o instanceof Uint8ClampedArray", o);
167-
168-
bool isJSInt16Array(WasmExternRef? o) =>
169-
JS<bool>("o => o instanceof Int16Array", o);
170-
171-
bool isJSUint16Array(WasmExternRef? o) =>
172-
JS<bool>("o => o instanceof Uint16Array", o);
173-
174-
bool isJSInt32Array(WasmExternRef? o) =>
175-
JS<bool>("o => o instanceof Int32Array", o);
176-
177-
bool isJSUint32Array(WasmExternRef? o) =>
178-
JS<bool>("o => o instanceof Uint32Array", o);
179-
180-
bool isJSFloat32Array(WasmExternRef? o) =>
181-
JS<bool>("o => o instanceof Float32Array", o);
182-
183-
bool isJSFloat64Array(WasmExternRef? o) =>
184-
JS<bool>("o => o instanceof Float64Array", o);
185-
186-
bool isJSArrayBuffer(WasmExternRef? o) =>
187-
JS<bool>("o => o instanceof ArrayBuffer", o);
188-
189-
bool isJSDataView(WasmExternRef? o) =>
190-
JS<bool>("o => o instanceof DataView", o);
191-
192-
bool isJSArray(WasmExternRef? o) => JS<bool>("o => o instanceof Array", o);
193-
194144
bool isJSWrappedDartFunction(WasmExternRef? o) => JS<bool>(
195145
"o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true",
196146
o,
@@ -225,9 +175,6 @@ int objectLength(WasmExternRef? o) =>
225175
int byteLength(WasmExternRef? o) =>
226176
JS<WasmI32>("o => o.byteLength", o).toIntSigned();
227177

228-
int dataViewGetUint8(WasmExternRef? o, int i) =>
229-
JS<WasmI32>("(o, i) => o.getUint8(i)", o, i.toWasmI32()).toIntSigned();
230-
231178
WasmExternRef? objectReadIndex(WasmExternRef? o, int index) =>
232179
JS<WasmExternRef?>("(o, i) => o[i]", o, index.toWasmI32());
233180

@@ -557,59 +504,6 @@ Object? dartifyRaw(WasmExternRef? ref, [int? refType]) {
557504
};
558505
}
559506

560-
Int8List toDartInt8List(WasmExternRef? ref) =>
561-
jsIntTypedArrayToDartIntTypedData(ref, (size) => Int8List(size))
562-
as Int8List;
563-
564-
Uint8List toDartUint8List(WasmExternRef? ref) =>
565-
jsIntTypedArrayToDartIntTypedData(ref, (size) => Uint8List(size))
566-
as Uint8List;
567-
568-
Uint8ClampedList toDartUint8ClampedList(WasmExternRef? ref) =>
569-
jsIntTypedArrayToDartIntTypedData(ref, (size) => Uint8ClampedList(size))
570-
as Uint8ClampedList;
571-
572-
Int16List toDartInt16List(WasmExternRef? ref) =>
573-
jsIntTypedArrayToDartIntTypedData(ref, (size) => Int16List(size))
574-
as Int16List;
575-
576-
Uint16List toDartUint16List(WasmExternRef? ref) =>
577-
jsIntTypedArrayToDartIntTypedData(ref, (size) => Uint16List(size))
578-
as Uint16List;
579-
580-
Int32List toDartInt32List(WasmExternRef? ref) =>
581-
jsIntTypedArrayToDartIntTypedData(ref, (size) => Int32List(size))
582-
as Int32List;
583-
584-
Uint32List toDartUint32List(WasmExternRef? ref) =>
585-
jsIntTypedArrayToDartIntTypedData(ref, (size) => Uint32List(size))
586-
as Uint32List;
587-
588-
Float32List toDartFloat32List(WasmExternRef? ref) =>
589-
jsFloatTypedArrayToDartFloatTypedData(ref, (size) => Float32List(size))
590-
as Float32List;
591-
592-
Float64List toDartFloat64List(WasmExternRef? ref) =>
593-
jsFloatTypedArrayToDartFloatTypedData(ref, (size) => Float64List(size))
594-
as Float64List;
595-
596-
ByteBuffer toDartByteBuffer(WasmExternRef? ref) =>
597-
toDartByteData(
598-
callConstructorVarArgsRaw(
599-
getConstructorString('DataView'),
600-
[JSValue(ref) as JSAny].toJS.toExternRef,
601-
),
602-
).buffer;
603-
604-
ByteData toDartByteData(WasmExternRef? ref) {
605-
int length = byteLength(ref).toInt();
606-
ByteData data = ByteData(length);
607-
for (int i = 0; i < length; i++) {
608-
data.setUint8(i, dataViewGetUint8(ref, i));
609-
}
610-
return data;
611-
}
612-
613507
List<double> jsFloatTypedArrayToDartFloatTypedData(
614508
WasmExternRef? ref,
615509
List<double> makeTypedData(int size),
@@ -684,11 +578,6 @@ JSArray<T> toJSArray<T extends JSAny?>(List<T> list) {
684578
return result;
685579
}
686580

687-
List<JSAny?> toDartListJSAny(WasmExternRef? ref) => List<JSAny?>.generate(
688-
objectLength(ref),
689-
(int n) => JSValue(objectReadIndex(ref, n)) as JSAny?,
690-
);
691-
692581
List<Object?> toDartList(WasmExternRef? ref) => List<Object?>.generate(
693582
objectLength(ref),
694583
(int n) => dartifyRaw(objectReadIndex(ref, n)),
@@ -704,10 +593,6 @@ F _wrapDartFunction<F extends Function>(F f, WasmExternRef ref) {
704593
return f;
705594
}
706595

707-
/// Returns the JS constructor object for a given [String].
708-
WasmExternRef? getConstructorRaw(String name) =>
709-
getPropertyRaw(globalThisRaw(), name.toExternRef);
710-
711596
/// Takes a [codeTemplate] string which must represent a valid JS function, and
712597
/// a list of optional arguments. The [codeTemplate] will be inserted into the
713598
/// JS runtime, and the call to [JS] will be replaced by a call to an external

0 commit comments

Comments
 (0)