@@ -81,7 +81,8 @@ final class JSStringImpl implements String {
81
81
@override
82
82
String operator + (String other) {
83
83
if (other is JSStringImpl ) {
84
- return JSStringImpl (_jsConcat (toExternRef, other.toExternRef));
84
+ return JSStringImpl (
85
+ _jsStringConcatImport (toExternRef, other.toExternRef));
85
86
}
86
87
87
88
// TODO(joshualitt): Refactor `string_patch.dart` so we can directly
@@ -712,32 +713,51 @@ bool _jsIdentical(WasmExternRef? ref1, WasmExternRef? ref2) =>
712
713
js.JS <bool >('Object.is' , ref1, ref2);
713
714
714
715
@pragma ("wasm:prefer-inline" )
715
- int _jsCharCodeAt (WasmExternRef ? stringRef, int index) => js
716
- .JS <WasmI32 >(
717
- 'WebAssembly.String.charCodeAt' , stringRef, WasmI32 .fromInt (index))
718
- .toIntUnsigned ();
719
-
720
- WasmExternRef _jsConcat (WasmExternRef ? s1, WasmExternRef ? s2) =>
721
- js.JS <WasmExternRef >('WebAssembly.String.concat' , s1, s2);
716
+ int _jsCharCodeAt (WasmExternRef ? stringRef, int index) =>
717
+ _jsStringCharCodeAtImport (stringRef, WasmI32 .fromInt (index))
718
+ .toIntUnsigned ();
722
719
723
720
@pragma ("wasm:prefer-inline" )
724
721
WasmExternRef _jsSubstring (
725
722
WasmExternRef ? stringRef, int startIndex, int endIndex) =>
726
- js. JS < WasmExternRef >( 'WebAssembly.String.substring' , stringRef,
727
- WasmI32 .fromInt (startIndex), WasmI32 .fromInt (endIndex));
723
+ _jsStringSubstringImport (
724
+ stringRef, WasmI32 .fromInt (startIndex), WasmI32 .fromInt (endIndex));
728
725
729
726
@pragma ("wasm:prefer-inline" )
730
727
int _jsLength (WasmExternRef ? stringRef) =>
731
- js. JS < WasmI32 >( 'WebAssembly.String.length' , stringRef).toIntUnsigned ();
728
+ _jsStringLengthImport ( stringRef).toIntUnsigned ();
732
729
733
730
@pragma ("wasm:prefer-inline" )
734
731
bool _jsEquals (WasmExternRef ? s1, WasmExternRef ? s2) =>
735
- js. JS < WasmI32 >( 'WebAssembly.String.equals' , s1, s2).toBool ();
732
+ _jsStringEqualsImport ( s1, s2).toBool ();
736
733
737
734
@pragma ("wasm:prefer-inline" )
738
735
int _jsCompare (WasmExternRef ? s1, WasmExternRef ? s2) =>
739
- js. JS < WasmI32 >( 'WebAssembly.String.compare' , s1, s2).toIntSigned ();
736
+ _jsStringCompareImport ( s1, s2).toIntSigned ();
740
737
741
738
@pragma ("wasm:prefer-inline" )
742
- WasmExternRef _jsFromCharCode (int charCode) => js.JS <WasmExternRef >(
743
- 'WebAssembly.String.fromCharCode' , WasmI32 .fromInt (charCode));
739
+ WasmExternRef _jsFromCharCode (int charCode) =>
740
+ _jsStringFromCharCodeImport (WasmI32 .fromInt (charCode));
741
+
742
+ @pragma ("wasm:import" , "wasm:js-string.charCodeAt" )
743
+ external WasmI32 _jsStringCharCodeAtImport (WasmExternRef ? s, WasmI32 index);
744
+
745
+ @pragma ("wasm:import" , "wasm:js-string.compare" )
746
+ external WasmI32 _jsStringCompareImport (WasmExternRef ? s1, WasmExternRef ? s2);
747
+
748
+ @pragma ("wasm:import" , "wasm:js-string.concat" )
749
+ external WasmExternRef _jsStringConcatImport (
750
+ WasmExternRef ? s1, WasmExternRef ? s2);
751
+
752
+ @pragma ("wasm:import" , "wasm:js-string.equals" )
753
+ external WasmI32 _jsStringEqualsImport (WasmExternRef ? s1, WasmExternRef ? s2);
754
+
755
+ @pragma ("wasm:import" , "wasm:js-string.fromCharCode" )
756
+ external WasmExternRef _jsStringFromCharCodeImport (WasmI32 c);
757
+
758
+ @pragma ("wasm:import" , "wasm:js-string.length" )
759
+ external WasmI32 _jsStringLengthImport (WasmExternRef ? s);
760
+
761
+ @pragma ("wasm:import" , "wasm:js-string.substring" )
762
+ external WasmExternRef _jsStringSubstringImport (
763
+ WasmExternRef ? s, WasmI32 startIndex, WasmI32 endIndex);
0 commit comments