@@ -18,6 +18,7 @@ import std._vec;
18
18
tag scope {
19
19
scope_crate( @ast. crate ) ;
20
20
scope_item ( @ast. item ) ;
21
+ scope_native_item ( @ast. native_item ) ;
21
22
scope_loop ( @ast. decl ) ; // there's only 1 decl per loop.
22
23
scope_block ( ast. block ) ;
23
24
scope_arm ( ast. arm ) ;
@@ -309,6 +310,23 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] {
309
310
}
310
311
}
311
312
313
+ fn handle_fn_decl ( ast . ident i, & ast. fn_decl decl ,
314
+ & vec[ ast. ty_param] ty_params ) -> option. t[ def_wrap ] {
315
+ for ( ast. arg a in decl. inputs) {
316
+ if ( _str. eq ( a. ident , i) ) {
317
+ auto t = ast. def_arg ( a. id ) ;
318
+ ret some( def_wrap_other ( t) ) ;
319
+ }
320
+ }
321
+ for ( ast. ty_param tp in ty_params) {
322
+ if ( _str. eq ( tp. ident , i) ) {
323
+ auto t = ast. def_ty_arg ( tp. id ) ;
324
+ ret some( def_wrap_other ( t) ) ;
325
+ }
326
+ }
327
+ ret none[ def_wrap] ;
328
+ }
329
+
312
330
fn in_scope ( ast . ident i, & scope s) -> option. t[ def_wrap ] {
313
331
alt ( s) {
314
332
@@ -319,18 +337,7 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] {
319
337
case ( scope_item ( ?it) ) {
320
338
alt ( it. node ) {
321
339
case ( ast. item_fn ( _, ?f, ?ty_params, _, _) ) {
322
- for ( ast. arg a in f. decl. inputs) {
323
- if ( _str. eq ( a. ident , i) ) {
324
- auto t = ast. def_arg ( a. id ) ;
325
- ret some( def_wrap_other ( t) ) ;
326
- }
327
- }
328
- for ( ast. ty_param tp in ty_params) {
329
- if ( _str. eq ( tp. ident , i) ) {
330
- auto t = ast. def_ty_arg ( tp. id ) ;
331
- ret some( def_wrap_other ( t) ) ;
332
- }
333
- }
340
+ ret handle_fn_decl ( i, f. decl , ty_params) ;
334
341
}
335
342
case ( ast. item_obj ( _, ?ob, ?ty_params, _, _) ) {
336
343
for ( ast. obj_field f in ob. fields) {
@@ -364,6 +371,14 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] {
364
371
}
365
372
}
366
373
374
+ case ( scope_native_item ( ?it) ) {
375
+ alt ( it. node ) {
376
+ case ( ast. native_item_fn ( _, ?decl, ?ty_params, _) ) {
377
+ ret handle_fn_decl ( i, decl, ty_params) ;
378
+ }
379
+ }
380
+ }
381
+
367
382
case ( scope_loop ( ?d) ) {
368
383
alt ( d. node ) {
369
384
case ( ast. decl_local ( ?local) ) {
@@ -529,6 +544,10 @@ fn update_env_for_item(&env e, @ast.item i) -> env {
529
544
ret rec ( scopes = cons[ scope] ( scope_item ( i) , @e. scopes ) with e) ;
530
545
}
531
546
547
+ fn update_env_for_native_item ( & env e, @ast. native_item i ) -> env {
548
+ ret rec ( scopes = cons[ scope] ( scope_native_item ( i) , @e. scopes ) with e) ;
549
+ }
550
+
532
551
fn update_env_for_block ( & env e, & ast . block b) -> env {
533
552
ret rec ( scopes = cons[ scope] ( scope_block ( b) , @e. scopes ) with e) ;
534
553
}
@@ -555,6 +574,8 @@ fn resolve_imports(session.session sess, @ast.crate crate) -> @ast.crate {
555
574
= bind fold_view_item_import ( _, _, import_index, _, _, _, _) ,
556
575
update_env_for_crate = bind update_env_for_crate ( _, _) ,
557
576
update_env_for_item = bind update_env_for_item ( _, _) ,
577
+ update_env_for_native_item =
578
+ bind update_env_for_native_item ( _, _) ,
558
579
update_env_for_block = bind update_env_for_block ( _, _) ,
559
580
update_env_for_arm = bind update_env_for_arm ( _, _) ,
560
581
update_env_for_expr = bind update_env_for_expr ( _, _)
@@ -577,6 +598,8 @@ fn resolve_crate(session.session sess, @ast.crate crate) -> @ast.crate {
577
598
fold_ty_path = bind fold_ty_path ( _, _, _, _) ,
578
599
update_env_for_crate = bind update_env_for_crate ( _, _) ,
579
600
update_env_for_item = bind update_env_for_item ( _, _) ,
601
+ update_env_for_native_item =
602
+ bind update_env_for_native_item ( _, _) ,
580
603
update_env_for_block = bind update_env_for_block ( _, _) ,
581
604
update_env_for_arm = bind update_env_for_arm ( _, _) ,
582
605
update_env_for_expr = bind update_env_for_expr ( _, _)
0 commit comments