@@ -18,16 +18,12 @@ export async function createInstantiator(options, swift) {
1818 let tmpRetOptionalFloat ;
1919 let tmpRetOptionalDouble ;
2020 let tmpRetOptionalHeapObject ;
21- let tmpRetTag = [ ] ;
22- let tmpRetStrings = [ ] ;
23- let tmpRetInts = [ ] ;
24- let tmpRetF32s = [ ] ;
25- let tmpRetF64s = [ ] ;
26- let tmpParamInts = [ ] ;
27- let tmpParamF32s = [ ] ;
28- let tmpParamF64s = [ ] ;
29- let tmpRetPointers = [ ] ;
30- let tmpParamPointers = [ ] ;
21+ let tagStack = [ ] ;
22+ let strStack = [ ] ;
23+ let i32Stack = [ ] ;
24+ let f32Stack = [ ] ;
25+ let f64Stack = [ ] ;
26+ let ptrStack = [ ] ;
3127 let tmpStructCleanups = [ ] ;
3228 const enumHelpers = { } ;
3329 const structHelpers = { } ;
@@ -71,36 +67,36 @@ export async function createInstantiator(options, swift) {
7167 swift . memory . release ( id ) ;
7268 }
7369 bjs [ "swift_js_push_tag" ] = function ( tag ) {
74- tmpRetTag . push ( tag ) ;
70+ tagStack . push ( tag ) ;
7571 }
7672 bjs [ "swift_js_push_i32" ] = function ( v ) {
77- tmpRetInts . push ( v | 0 ) ;
73+ i32Stack . push ( v | 0 ) ;
7874 }
7975 bjs [ "swift_js_push_f32" ] = function ( v ) {
80- tmpRetF32s . push ( Math . fround ( v ) ) ;
76+ f32Stack . push ( Math . fround ( v ) ) ;
8177 }
8278 bjs [ "swift_js_push_f64" ] = function ( v ) {
83- tmpRetF64s . push ( v ) ;
79+ f64Stack . push ( v ) ;
8480 }
8581 bjs [ "swift_js_push_string" ] = function ( ptr , len ) {
8682 const bytes = new Uint8Array ( memory . buffer , ptr , len ) ;
8783 const value = textDecoder . decode ( bytes ) ;
88- tmpRetStrings . push ( value ) ;
84+ strStack . push ( value ) ;
8985 }
9086 bjs [ "swift_js_pop_i32" ] = function ( ) {
91- return tmpParamInts . pop ( ) ;
87+ return i32Stack . pop ( ) ;
9288 }
9389 bjs [ "swift_js_pop_f32" ] = function ( ) {
94- return tmpParamF32s . pop ( ) ;
90+ return f32Stack . pop ( ) ;
9591 }
9692 bjs [ "swift_js_pop_f64" ] = function ( ) {
97- return tmpParamF64s . pop ( ) ;
93+ return f64Stack . pop ( ) ;
9894 }
9995 bjs [ "swift_js_push_pointer" ] = function ( pointer ) {
100- tmpRetPointers . push ( pointer ) ;
96+ ptrStack . push ( pointer ) ;
10197 }
10298 bjs [ "swift_js_pop_pointer" ] = function ( ) {
103- return tmpParamPointers . pop ( ) ;
99+ return ptrStack . pop ( ) ;
104100 }
105101 bjs [ "swift_js_struct_cleanup" ] = function ( cleanupId ) {
106102 if ( cleanupId === 0 ) { return ; }
@@ -213,11 +209,11 @@ export async function createInstantiator(options, swift) {
213209 const TestModule = importObject [ "TestModule" ] = importObject [ "TestModule" ] || { } ;
214210 TestModule [ "bjs_importMirrorDictionary" ] = function bjs_importMirrorDictionary ( ) {
215211 try {
216- const dictLen = tmpRetInts . pop ( ) ;
212+ const dictLen = i32Stack . pop ( ) ;
217213 const dictResult = { } ;
218214 for ( let i = 0 ; i < dictLen ; i ++ ) {
219- const f64 = tmpRetF64s . pop ( ) ;
220- const string = tmpRetStrings . pop ( ) ;
215+ const f64 = f64Stack . pop ( ) ;
216+ const string = strStack . pop ( ) ;
221217 dictResult [ string ] = f64 ;
222218 }
223219 let ret = imports . importMirrorDictionary ( dictResult ) ;
@@ -227,14 +223,14 @@ export async function createInstantiator(options, swift) {
227223 const [ key , value ] = entry ;
228224 const bytes = textEncoder . encode ( key ) ;
229225 const id = swift . memory . retain ( bytes ) ;
230- tmpParamInts . push ( bytes . length ) ;
231- tmpParamInts . push ( id ) ;
226+ i32Stack . push ( bytes . length ) ;
227+ i32Stack . push ( id ) ;
232228 arrayCleanups . push ( ( ) => {
233229 swift . memory . release ( id ) ;
234230 } ) ;
235- tmpParamF64s . push ( value ) ;
231+ f64Stack . push ( value ) ;
236232 }
237- tmpParamInts . push ( entries . length ) ;
233+ i32Stack . push ( entries . length ) ;
238234 } catch ( error ) {
239235 setException ( error ) ;
240236 }
@@ -285,20 +281,20 @@ export async function createInstantiator(options, swift) {
285281 const [ key , value ] = entry ;
286282 const bytes = textEncoder . encode ( key ) ;
287283 const id = swift . memory . retain ( bytes ) ;
288- tmpParamInts . push ( bytes . length ) ;
289- tmpParamInts . push ( id ) ;
284+ i32Stack . push ( bytes . length ) ;
285+ i32Stack . push ( id ) ;
290286 arrayCleanups . push ( ( ) => {
291287 swift . memory . release ( id ) ;
292288 } ) ;
293- tmpParamInts . push ( ( value | 0 ) ) ;
289+ i32Stack . push ( ( value | 0 ) ) ;
294290 }
295- tmpParamInts . push ( entries . length ) ;
291+ i32Stack . push ( entries . length ) ;
296292 instance . exports . bjs_mirrorDictionary ( ) ;
297- const dictLen = tmpRetInts . pop ( ) ;
293+ const dictLen = i32Stack . pop ( ) ;
298294 const dictResult = { } ;
299295 for ( let i = 0 ; i < dictLen ; i ++ ) {
300- const int = tmpRetInts . pop ( ) ;
301- const string = tmpRetStrings . pop ( ) ;
296+ const int = i32Stack . pop ( ) ;
297+ const string = strStack . pop ( ) ;
302298 dictResult [ string ] = int ;
303299 }
304300 for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
@@ -314,31 +310,31 @@ export async function createInstantiator(options, swift) {
314310 const [ key , value ] = entry ;
315311 const bytes = textEncoder . encode ( key ) ;
316312 const id = swift . memory . retain ( bytes ) ;
317- tmpParamInts . push ( bytes . length ) ;
318- tmpParamInts . push ( id ) ;
313+ i32Stack . push ( bytes . length ) ;
314+ i32Stack . push ( id ) ;
319315 arrayCleanups . push ( ( ) => {
320316 swift . memory . release ( id ) ;
321317 } ) ;
322318 const bytes1 = textEncoder . encode ( value ) ;
323319 const id1 = swift . memory . retain ( bytes1 ) ;
324- tmpParamInts . push ( bytes1 . length ) ;
325- tmpParamInts . push ( id1 ) ;
320+ i32Stack . push ( bytes1 . length ) ;
321+ i32Stack . push ( id1 ) ;
326322 arrayCleanups . push ( ( ) => {
327323 swift . memory . release ( id1 ) ;
328324 } ) ;
329325 }
330- tmpParamInts . push ( entries . length ) ;
326+ i32Stack . push ( entries . length ) ;
331327 valuesCleanups . push ( ( ) => { for ( const cleanup of arrayCleanups ) { cleanup ( ) ; } } ) ;
332328 }
333329 instance . exports . bjs_optionalDictionary ( + isSome ) ;
334- const isSome1 = tmpRetInts . pop ( ) ;
330+ const isSome1 = i32Stack . pop ( ) ;
335331 let optResult ;
336332 if ( isSome1 ) {
337- const dictLen = tmpRetInts . pop ( ) ;
333+ const dictLen = i32Stack . pop ( ) ;
338334 const dictResult = { } ;
339335 for ( let i = 0 ; i < dictLen ; i ++ ) {
340- const string = tmpRetStrings . pop ( ) ;
341- const string1 = tmpRetStrings . pop ( ) ;
336+ const string = strStack . pop ( ) ;
337+ const string1 = strStack . pop ( ) ;
342338 dictResult [ string1 ] = string ;
343339 }
344340 optResult = dictResult ;
@@ -355,33 +351,33 @@ export async function createInstantiator(options, swift) {
355351 const [ key , value ] = entry ;
356352 const bytes = textEncoder . encode ( key ) ;
357353 const id = swift . memory . retain ( bytes ) ;
358- tmpParamInts . push ( bytes . length ) ;
359- tmpParamInts . push ( id ) ;
354+ i32Stack . push ( bytes . length ) ;
355+ i32Stack . push ( id ) ;
360356 arrayCleanups . push ( ( ) => {
361357 swift . memory . release ( id ) ;
362358 } ) ;
363359 const arrayCleanups1 = [ ] ;
364360 for ( const elem of value ) {
365- tmpParamInts . push ( ( elem | 0 ) ) ;
361+ i32Stack . push ( ( elem | 0 ) ) ;
366362 }
367- tmpParamInts . push ( value . length ) ;
363+ i32Stack . push ( value . length ) ;
368364 arrayCleanups . push ( ( ) => {
369365 for ( const cleanup of arrayCleanups1 ) { cleanup ( ) ; }
370366 } ) ;
371367 }
372- tmpParamInts . push ( entries . length ) ;
368+ i32Stack . push ( entries . length ) ;
373369 instance . exports . bjs_nestedDictionary ( ) ;
374- const dictLen = tmpRetInts . pop ( ) ;
370+ const dictLen = i32Stack . pop ( ) ;
375371 const dictResult = { } ;
376372 for ( let i = 0 ; i < dictLen ; i ++ ) {
377- const arrayLen = tmpRetInts . pop ( ) ;
373+ const arrayLen = i32Stack . pop ( ) ;
378374 const arrayResult = [ ] ;
379375 for ( let i1 = 0 ; i1 < arrayLen ; i1 ++ ) {
380- const int = tmpRetInts . pop ( ) ;
376+ const int = i32Stack . pop ( ) ;
381377 arrayResult . push ( int ) ;
382378 }
383379 arrayResult . reverse ( ) ;
384- const string = tmpRetStrings . pop ( ) ;
380+ const string = strStack . pop ( ) ;
385381 dictResult [ string ] = arrayResult ;
386382 }
387383 for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
@@ -394,21 +390,21 @@ export async function createInstantiator(options, swift) {
394390 const [ key , value ] = entry ;
395391 const bytes = textEncoder . encode ( key ) ;
396392 const id = swift . memory . retain ( bytes ) ;
397- tmpParamInts . push ( bytes . length ) ;
398- tmpParamInts . push ( id ) ;
393+ i32Stack . push ( bytes . length ) ;
394+ i32Stack . push ( id ) ;
399395 arrayCleanups . push ( ( ) => {
400396 swift . memory . release ( id ) ;
401397 } ) ;
402- tmpParamPointers . push ( value . pointer ) ;
398+ ptrStack . push ( value . pointer ) ;
403399 }
404- tmpParamInts . push ( entries . length ) ;
400+ i32Stack . push ( entries . length ) ;
405401 instance . exports . bjs_boxDictionary ( ) ;
406- const dictLen = tmpRetInts . pop ( ) ;
402+ const dictLen = i32Stack . pop ( ) ;
407403 const dictResult = { } ;
408404 for ( let i = 0 ; i < dictLen ; i ++ ) {
409- const ptr = tmpRetPointers . pop ( ) ;
405+ const ptr = ptrStack . pop ( ) ;
410406 const obj = _exports [ 'Box' ] . __construct ( ptr ) ;
411- const string = tmpRetStrings . pop ( ) ;
407+ const string = strStack . pop ( ) ;
412408 dictResult [ string ] = obj ;
413409 }
414410 for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
@@ -421,34 +417,34 @@ export async function createInstantiator(options, swift) {
421417 const [ key , value ] = entry ;
422418 const bytes = textEncoder . encode ( key ) ;
423419 const id = swift . memory . retain ( bytes ) ;
424- tmpParamInts . push ( bytes . length ) ;
425- tmpParamInts . push ( id ) ;
420+ i32Stack . push ( bytes . length ) ;
421+ i32Stack . push ( id ) ;
426422 arrayCleanups . push ( ( ) => {
427423 swift . memory . release ( id ) ;
428424 } ) ;
429425 const isSome = value != null ? 1 : 0 ;
430426 if ( isSome ) {
431- tmpParamPointers . push ( value . pointer ) ;
427+ ptrStack . push ( value . pointer ) ;
432428 } else {
433- tmpParamPointers . push ( 0 ) ;
429+ ptrStack . push ( 0 ) ;
434430 }
435- tmpParamInts . push ( isSome ) ;
431+ i32Stack . push ( isSome ) ;
436432 }
437- tmpParamInts . push ( entries . length ) ;
433+ i32Stack . push ( entries . length ) ;
438434 instance . exports . bjs_optionalBoxDictionary ( ) ;
439- const dictLen = tmpRetInts . pop ( ) ;
435+ const dictLen = i32Stack . pop ( ) ;
440436 const dictResult = { } ;
441437 for ( let i = 0 ; i < dictLen ; i ++ ) {
442- const isSome1 = tmpRetInts . pop ( ) ;
438+ const isSome1 = i32Stack . pop ( ) ;
443439 let optValue ;
444440 if ( isSome1 === 0 ) {
445441 optValue = null ;
446442 } else {
447- const ptr = tmpRetPointers . pop ( ) ;
443+ const ptr = ptrStack . pop ( ) ;
448444 const obj = _exports [ 'Box' ] . __construct ( ptr ) ;
449445 optValue = obj ;
450446 }
451- const string = tmpRetStrings . pop ( ) ;
447+ const string = strStack . pop ( ) ;
452448 dictResult [ string ] = optValue ;
453449 }
454450 for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
0 commit comments