@@ -441,7 +441,7 @@ fn struct_def_eq(arguments: Vec<(Value, Location)>, location: Location) -> IResu
441
441
eq_item ( arguments, location, get_struct)
442
442
}
443
443
444
- // fn has_named_attribute(self, name: Quoted ) -> bool
444
+ // fn has_named_attribute<let N: u32> (self, name: str<N> ) -> bool {}
445
445
fn struct_def_has_named_attribute (
446
446
interner : & NodeInterner ,
447
447
arguments : Vec < ( Value , Location ) > ,
@@ -450,14 +450,9 @@ fn struct_def_has_named_attribute(
450
450
let ( self_argument, name) = check_two_arguments ( arguments, location) ?;
451
451
let struct_id = get_struct ( self_argument) ?;
452
452
453
- let name = get_quoted ( name) ?;
454
- let name = name. iter ( ) . map ( |token| token. to_string ( ) ) . collect :: < Vec < _ > > ( ) . join ( "" ) ;
453
+ let name = get_str ( interner, name) ?;
455
454
456
- let attributes = interner. struct_attributes ( & struct_id) ;
457
- let attributes = attributes. iter ( ) . filter_map ( |attribute| attribute. as_custom ( ) ) ;
458
- let attributes = attributes. map ( |attribute| & attribute. contents ) ;
459
-
460
- Ok ( Value :: Bool ( has_named_attribute ( & name, attributes, location) ) )
455
+ Ok ( Value :: Bool ( has_named_attribute ( & name, interner. struct_attributes ( & struct_id) ) ) )
461
456
}
462
457
463
458
/// fn fields(self) -> [(Quoted, Type)]
@@ -1957,23 +1952,25 @@ fn function_def_body(
1957
1952
}
1958
1953
}
1959
1954
1960
- // fn has_named_attribute(self, name: Quoted ) -> bool
1955
+ // fn has_named_attribute<let N: u32> (self, name: str<N> ) -> bool {}
1961
1956
fn function_def_has_named_attribute (
1962
1957
interner : & NodeInterner ,
1963
1958
arguments : Vec < ( Value , Location ) > ,
1964
1959
location : Location ,
1965
1960
) -> IResult < Value > {
1966
1961
let ( self_argument, name) = check_two_arguments ( arguments, location) ?;
1967
1962
let func_id = get_function_def ( self_argument) ?;
1968
- let func_meta = interner. function_meta ( & func_id) ;
1969
1963
1970
- let name = get_quoted ( name) ?;
1971
- let name = name. iter ( ) . map ( |token| token. to_string ( ) ) . collect :: < Vec < _ > > ( ) . join ( "" ) ;
1964
+ let name = & * get_str ( interner, name) ?;
1972
1965
1973
- let attributes = & func_meta. custom_attributes ;
1974
- let attributes = attributes. iter ( ) . map ( |attribute| & attribute. contents ) ;
1966
+ let modifiers = interner. function_modifiers ( & func_id) ;
1967
+ if let Some ( attribute) = & modifiers. attributes . function {
1968
+ if name == attribute. name ( ) {
1969
+ return Ok ( Value :: Bool ( true ) ) ;
1970
+ }
1971
+ }
1975
1972
1976
- Ok ( Value :: Bool ( has_named_attribute ( & name, attributes, location ) ) )
1973
+ Ok ( Value :: Bool ( has_named_attribute ( name, & modifiers . attributes . secondary ) ) )
1977
1974
}
1978
1975
1979
1976
fn function_def_hash ( arguments : Vec < ( Value , Location ) > , location : Location ) -> IResult < Value > {
@@ -2306,7 +2303,7 @@ fn module_structs(
2306
2303
Ok ( Value :: Slice ( struct_ids, slice_type) )
2307
2304
}
2308
2305
2309
- // fn has_named_attribute(self, name: Quoted ) -> bool
2306
+ // fn has_named_attribute<let N: u32> (self, name: str<N> ) -> bool {}
2310
2307
fn module_has_named_attribute (
2311
2308
interpreter : & Interpreter ,
2312
2309
arguments : Vec < ( Value , Location ) > ,
@@ -2316,12 +2313,9 @@ fn module_has_named_attribute(
2316
2313
let module_id = get_module ( self_argument) ?;
2317
2314
let module_data = interpreter. elaborator . get_module ( module_id) ;
2318
2315
2319
- let name = get_quoted ( name) ?;
2320
- let name = name. iter ( ) . map ( |token| token. to_string ( ) ) . collect :: < Vec < _ > > ( ) . join ( "" ) ;
2321
-
2322
- let attributes = module_data. outer_attributes . iter ( ) . chain ( & module_data. inner_attributes ) ;
2316
+ let name = get_str ( interpreter. elaborator . interner , name) ?;
2323
2317
2324
- Ok ( Value :: Bool ( has_named_attribute ( & name, attributes, location ) ) )
2318
+ Ok ( Value :: Bool ( has_named_attribute ( & name, & module_data . attributes ) ) )
2325
2319
}
2326
2320
2327
2321
// fn is_contract(self) -> bool
0 commit comments