@@ -35,7 +35,7 @@ type ty_table = hashmap[ast.def_id, @ty.t];
35
35
36
36
tag any_item {
37
37
any_item_rust( @ast. item ) ;
38
- any_item_native ( @ast. native_item ) ;
38
+ any_item_native ( @ast. native_item , ast . native_abi ) ;
39
39
}
40
40
41
41
type ty_item_table = hashmap [ ast. def_id , any_item] ;
@@ -272,7 +272,7 @@ fn ast_ty_to_ty_crate(@crate_ctxt ccx, &@ast.ty ast_ty) -> @ty.t {
272
272
ty = actual_type( ty, item) ;
273
273
params = ty_params_of_item( item) ;
274
274
}
275
- case ( any_item_native( ?native_item) ) {
275
+ case ( any_item_native( ?native_item, _ ) ) {
276
276
params = ty_params_of_native_item( native_item) ;
277
277
}
278
278
}
@@ -346,10 +346,11 @@ fn ty_of_native_fn_decl(@ty_item_table id_to_ty_item,
346
346
fn( & @ast. ty ast_ty) -> @ty. t convert,
347
347
fn( & ast. arg a) -> arg ty_of_arg,
348
348
& ast. fn_decl decl,
349
+ ast. native_abi abi,
349
350
ast. def_id def_id) -> @ty. t {
350
351
auto input_tys = _vec. map[ ast. arg, arg] ( ty_of_arg, decl. inputs) ;
351
352
auto output_ty = convert( decl. output) ;
352
- auto t_fn = plain_ty( ty. ty_native_fn( input_tys, output_ty) ) ;
353
+ auto t_fn = plain_ty( ty. ty_native_fn( abi , input_tys, output_ty) ) ;
353
354
item_to_ty. insert( def_id, t_fn) ;
354
355
ret t_fn;
355
356
}
@@ -370,9 +371,9 @@ fn collect_item_types(session.session sess, @ast.crate crate)
370
371
ty = actual_type( ty, item) ;
371
372
params = ty_params_of_item( item) ;
372
373
}
373
- case ( any_item_native( ?native_item) ) {
374
+ case ( any_item_native( ?native_item, ?abi ) ) {
374
375
ty = ty_of_native_item( id_to_ty_item, item_to_ty,
375
- native_item) ;
376
+ native_item, abi ) ;
376
377
params = ty_params_of_native_item( native_item) ;
377
378
}
378
379
}
@@ -490,14 +491,15 @@ fn collect_item_types(session.session sess, @ast.crate crate)
490
491
491
492
fn ty_of_native_item( @ty_item_table id_to_ty_item,
492
493
@ty_table item_to_ty,
493
- @ast. native_item it) -> @ty. t {
494
+ @ast. native_item it,
495
+ ast. native_abi abi) -> @ty. t {
494
496
alt ( it. node) {
495
497
case ( ast. native_item_fn( ?ident, ?fn_decl, ?params, ?def_id, _) ) {
496
498
auto get = bind getter( id_to_ty_item, item_to_ty, _) ;
497
499
auto convert = bind ast_ty_to_ty( get, _) ;
498
500
auto f = bind ty_of_arg( id_to_ty_item, item_to_ty, _) ;
499
501
ret ty_of_native_fn_decl( id_to_ty_item, item_to_ty, convert,
500
- f, fn_decl, def_id) ;
502
+ f, fn_decl, abi , def_id) ;
501
503
}
502
504
case ( ast. native_item_ty( _, ?def_id) ) {
503
505
if ( item_to_ty. contains_key( def_id) ) {
@@ -578,7 +580,10 @@ fn collect_item_types(session.session sess, @ast.crate crate)
578
580
-> @ty_item_table {
579
581
alt ( i. node) {
580
582
case ( ast. native_item_ty( _, ?def_id) ) {
581
- id_to_ty_item. insert( def_id, any_item_native( i) ) ;
583
+ // The abi of types is not used.
584
+ id_to_ty_item. insert( def_id,
585
+ any_item_native( i,
586
+ ast. native_abi_cdecl) ) ;
582
587
}
583
588
case ( _) {
584
589
}
@@ -598,30 +603,34 @@ fn collect_item_types(session.session sess, @ast.crate crate)
598
603
599
604
type env = rec( session. session sess,
600
605
@ty_item_table id_to_ty_item,
601
- @ty_table item_to_ty) ;
606
+ @ty_table item_to_ty,
607
+ ast. native_abi abi) ;
602
608
let @env e = @rec( sess=sess,
603
609
id_to_ty_item=id_to_ty_item,
604
- item_to_ty=item_to_ty) ;
610
+ item_to_ty=item_to_ty,
611
+ abi=ast. native_abi_cdecl) ;
605
612
606
613
fn convert( & @env e, @ast. item i) -> @env {
614
+ auto abi = e. abi;
607
615
alt ( i. node) {
608
616
case ( ast. item_mod( _, _, _) ) {
609
617
// ignore item_mod, it has no type.
610
618
}
611
- case ( ast. item_native_mod( _, _ , _) ) {
619
+ case ( ast. item_native_mod( _, ?native_mod , _) ) {
612
620
// ignore item_native_mod, it has no type.
621
+ abi = native_mod. abi;
613
622
}
614
623
case ( _) {
615
624
// This call populates the ty_table with the converted type of
616
625
// the item in passing; we don't need to do anything else.
617
626
ty_of_item( e. id_to_ty_item, e. item_to_ty, i) ;
618
627
}
619
628
}
620
- ret e ;
629
+ ret @rec ( abi=abi with * e ) ;
621
630
}
622
631
623
632
fn convert_native( & @env e, @ast. native_item i) -> @env {
624
- ty_of_native_item( e. id_to_ty_item, e. item_to_ty, i) ;
633
+ ty_of_native_item( e. id_to_ty_item, e. item_to_ty, i, e . abi ) ;
625
634
ret e;
626
635
}
627
636
@@ -1322,8 +1331,8 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
1322
1331
case ( ty. ty_fn( ?proto, _, _) ) {
1323
1332
t_0 = plain_ty( ty. ty_fn( proto, arg_tys_0, rt_0) ) ;
1324
1333
}
1325
- case ( ty. ty_native_fn( _, _) ) {
1326
- t_0 = plain_ty( ty. ty_native_fn( arg_tys_0, rt_0) ) ;
1334
+ case ( ty. ty_native_fn( ?abi , _, _) ) {
1335
+ t_0 = plain_ty( ty. ty_native_fn( abi , arg_tys_0, rt_0) ) ;
1327
1336
}
1328
1337
case ( _) {
1329
1338
log "check_call_or_bind(): fn expr doesn't have fn type" ;
@@ -1807,7 +1816,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
1807
1816
auto rt_1 = plain_ty ( ty. ty_nil ) ; // FIXME: typestate botch
1808
1817
alt ( expr_ty( result. _0 ) . struct ) {
1809
1818
case ( ty. ty_fn ( _, _, ?rt) ) { rt_1 = rt; }
1810
- case ( ty. ty_native_fn ( _, ?rt) ) { rt_1 = rt; }
1819
+ case ( ty. ty_native_fn ( _, _ , ?rt) ) { rt_1 = rt; }
1811
1820
case ( _) {
1812
1821
log "LHS of call expr didn't have a function type?!" ;
1813
1822
fail;
0 commit comments