@@ -162,10 +162,8 @@ impl Extern {
162162 R : IntoWasmValueTuple + ValTypesFromTuple + Debug ,
163163 {
164164 let inner_func = move |ctx : FuncContext < ' _ > , args : & [ WasmValue ] | -> Result < Vec < WasmValue > > {
165- log:: error!( "args: {:?}" , args) ;
166165 let args = P :: from_wasm_value_tuple ( args. to_vec ( ) ) ?;
167166 let result = func ( ctx, args) ?;
168- log:: error!( "result: {:?}" , result) ;
169167 Ok ( result. into_wasm_value_tuple ( ) )
170168 } ;
171169
@@ -290,18 +288,6 @@ impl Imports {
290288 _ => { }
291289 }
292290
293- // if expected.size_max.is_none() && actual.size_max.is_some() {
294- // return Err(LinkingError::incompatible_import_type(import).into());
295- // }
296-
297- // if expected.size_max.unwrap_or(0) < actual.size_max.unwrap_or(0) {
298- // return Err(LinkingError::incompatible_import_type(import).into());
299- // }
300-
301- log:: error!( "size_initial: expected: {:?} got: {:?}" , expected. size_initial, actual. size_initial) ;
302- log:: error!( "size_max: expected: {:?} got: {:?}" , expected. size_max, actual. size_max) ;
303- // TODO: check limits
304-
305291 Ok ( ( ) )
306292 }
307293
@@ -331,11 +317,6 @@ impl Imports {
331317 _ => { }
332318 }
333319
334- log:: error!( "size_initial: {:?} {:?}" , expected. page_count_initial, actual. page_count_initial) ;
335- log:: error!( "size_max: {:?} {:?}" , expected. page_count_max, actual. page_count_max) ;
336-
337- // TODO: check limits
338-
339320 Ok ( ( ) )
340321 }
341322
@@ -348,13 +329,7 @@ impl Imports {
348329 let mut imports = ResolvedImports :: new ( ) ;
349330
350331 for import in module. data . imports . iter ( ) {
351- let Some ( val) = self . take ( store, import) else {
352- return Err ( crate :: LinkingError :: UnknownImport {
353- module : import. module . to_string ( ) ,
354- name : import. name . to_string ( ) ,
355- }
356- . into ( ) ) ;
357- } ;
332+ let val = self . take ( store, import) . ok_or_else ( || LinkingError :: unknown_import ( import) ) ?;
358333
359334 match val {
360335 // A link to something that needs to be added to the store
@@ -364,42 +339,31 @@ impl Imports {
364339 imports. globals . push ( store. add_global ( extern_global. ty , extern_global. val . into ( ) , idx) ?) ;
365340 }
366341 ( Extern :: Table ( extern_table) , ImportKind :: Table ( ty) ) => {
367- Self :: compare_table_types ( import, & extern_table. ty , & ty) ?;
342+ Self :: compare_table_types ( import, & extern_table. ty , ty) ?;
368343 imports. tables . push ( store. add_table ( extern_table. ty , idx) ?) ;
369344 }
370345 ( Extern :: Memory ( extern_memory) , ImportKind :: Memory ( ty) ) => {
371- Self :: compare_memory_types ( import, & extern_memory. ty , & ty, None ) ?;
346+ Self :: compare_memory_types ( import, & extern_memory. ty , ty, None ) ?;
372347 imports. memories . push ( store. add_mem ( extern_memory. ty , idx) ?) ;
373348 }
374349 ( Extern :: Function ( extern_func) , ImportKind :: Function ( ty) ) => {
375- let import_func_type = module. data . func_types . get ( * ty as usize ) . ok_or_else ( || {
376- crate :: LinkingError :: IncompatibleImportType {
377- module : import. module . to_string ( ) ,
378- name : import. name . to_string ( ) ,
379- }
380- } ) ?;
350+ let import_func_type = module
351+ . data
352+ . func_types
353+ . get ( * ty as usize )
354+ . ok_or_else ( || LinkingError :: incompatible_import_type ( import) ) ?;
381355
382356 Self :: compare_types ( import, extern_func. ty ( ) , import_func_type) ?;
383357 imports. funcs . push ( store. add_func ( extern_func, * ty, idx) ?) ;
384358 }
385- _ => {
386- return Err ( crate :: LinkingError :: IncompatibleImportType {
387- module : import. module . to_string ( ) ,
388- name : import. name . to_string ( ) ,
389- }
390- . into ( ) ) ;
391- }
359+ _ => return Err ( LinkingError :: incompatible_import_type ( import) . into ( ) ) ,
392360 } ,
393361
394362 // A link to something already in the store
395363 ResolvedExtern :: Store ( val) => {
396364 // check if the kind matches
397365 if val. kind ( ) != ( & import. kind ) . into ( ) {
398- return Err ( crate :: LinkingError :: IncompatibleImportType {
399- module : import. module . to_string ( ) ,
400- name : import. name . to_string ( ) ,
401- }
402- . into ( ) ) ;
366+ return Err ( LinkingError :: incompatible_import_type ( import) . into ( ) ) ;
403367 }
404368
405369 match ( val, & import. kind ) {
@@ -410,37 +374,30 @@ impl Imports {
410374 }
411375 ( ExternVal :: Table ( table_addr) , ImportKind :: Table ( ty) ) => {
412376 let table = store. get_table ( table_addr as usize ) ?;
413- Self :: compare_table_types ( import, & table. borrow ( ) . kind , & ty) ?;
377+ Self :: compare_table_types ( import, & table. borrow ( ) . kind , ty) ?;
414378 imports. tables . push ( table_addr) ;
415379 }
416380 ( ExternVal :: Mem ( memory_addr) , ImportKind :: Memory ( ty) ) => {
417381 let mem = store. get_mem ( memory_addr as usize ) ?;
418382 let ( size, kind) = {
419383 let mem = mem. borrow ( ) ;
420- ( mem. page_count ( ) , mem. kind . clone ( ) )
384+ ( mem. page_count ( ) , mem. kind )
421385 } ;
422- Self :: compare_memory_types ( import, & kind, & ty, Some ( size) ) ?;
386+ Self :: compare_memory_types ( import, & kind, ty, Some ( size) ) ?;
423387 imports. memories . push ( memory_addr) ;
424388 }
425389 ( ExternVal :: Func ( func_addr) , ImportKind :: Function ( ty) ) => {
426390 let func = store. get_func ( func_addr as usize ) ?;
427- let import_func_type = module. data . func_types . get ( * ty as usize ) . ok_or_else ( || {
428- crate :: LinkingError :: IncompatibleImportType {
429- module : import. module . to_string ( ) ,
430- name : import. name . to_string ( ) ,
431- }
432- } ) ?;
391+ let import_func_type = module
392+ . data
393+ . func_types
394+ . get ( * ty as usize )
395+ . ok_or_else ( || LinkingError :: incompatible_import_type ( import) ) ?;
433396
434397 Self :: compare_types ( import, func. func . ty ( ) , import_func_type) ?;
435398 imports. funcs . push ( func_addr) ;
436399 }
437- _ => {
438- return Err ( crate :: LinkingError :: IncompatibleImportType {
439- module : import. module . to_string ( ) ,
440- name : import. name . to_string ( ) ,
441- }
442- . into ( ) ) ;
443- }
400+ _ => return Err ( LinkingError :: incompatible_import_type ( import) . into ( ) ) ,
444401 }
445402 }
446403 }
0 commit comments