Skip to content

Commit f0c7eda

Browse files
authored
Metadata processing improvements (#2598)
1 parent 53eed86 commit f0c7eda

36 files changed

+1756
-823
lines changed

crates/libs/metadata/src/attributes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ impl MethodAttributes {
6161
pub const Virtual: Self = Self(0x40);
6262
}
6363

64-
flags!(MethodImplAttributes, usize);
64+
flags!(MethodImplAttributes, u16);
6565
impl MethodImplAttributes {
6666
pub const PreserveSig: Self = Self(0x80);
6767
}
6868

69+
// These are not really ECMA-335 attributes but instead the flags found in the method signature.
6970
flags!(MethodCallAttributes, u8);
7071
impl MethodCallAttributes {
7172
pub const HASTHIS: Self = Self(0x20);

crates/libs/metadata/src/file/reader.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ pub trait RowReader<'a> {
175175
// GenericParam
176176
//
177177

178+
fn generic_param_number(&self, row: GenericParam) -> u16 {
179+
self.row_usize(row, 0) as u16
180+
}
181+
178182
fn generic_param_name(&self, row: GenericParam) -> &'a str {
179183
self.row_str(row, 3)
180184
}
@@ -212,7 +216,7 @@ pub trait RowReader<'a> {
212216
//
213217

214218
fn method_def_impl_flags(&self, row: MethodDef) -> MethodImplAttributes {
215-
MethodImplAttributes(self.row_usize(row, 1))
219+
MethodImplAttributes(self.row_usize(row, 1) as u16)
216220
}
217221

218222
fn method_def_flags(&self, row: MethodDef) -> MethodAttributes {
@@ -268,8 +272,8 @@ pub trait RowReader<'a> {
268272
ParamAttributes(self.row_usize(row, 0) as u16)
269273
}
270274

271-
fn param_sequence(&self, row: Param) -> usize {
272-
self.row_usize(row, 1)
275+
fn param_sequence(&self, row: Param) -> u16 {
276+
self.row_usize(row, 1) as u16
273277
}
274278

275279
fn param_name(&self, row: Param) -> &'a str {
@@ -307,8 +311,8 @@ pub trait RowReader<'a> {
307311
self.row_list(row, 4)
308312
}
309313

310-
fn type_def_generics(&self, row: TypeDef) -> Vec<Type> {
311-
self.row_equal_range(row, 2, TypeOrMethodDef::TypeDef(row).encode()).map(Type::GenericParam).collect()
314+
fn type_def_generics(&self, row: TypeDef) -> RowIterator<GenericParam> {
315+
self.row_equal_range(row, 2, TypeOrMethodDef::TypeDef(row).encode())
312316
}
313317

314318
fn type_def_interface_impls(&self, row: TypeDef) -> RowIterator<InterfaceImpl> {

0 commit comments

Comments
 (0)