Skip to content

Commit

Permalink
Metadata processing improvements (#2598)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Aug 10, 2023
1 parent 53eed86 commit f0c7eda
Show file tree
Hide file tree
Showing 36 changed files with 1,756 additions and 823 deletions.
3 changes: 2 additions & 1 deletion crates/libs/metadata/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ impl MethodAttributes {
pub const Virtual: Self = Self(0x40);
}

flags!(MethodImplAttributes, usize);
flags!(MethodImplAttributes, u16);
impl MethodImplAttributes {
pub const PreserveSig: Self = Self(0x80);
}

// These are not really ECMA-335 attributes but instead the flags found in the method signature.
flags!(MethodCallAttributes, u8);
impl MethodCallAttributes {
pub const HASTHIS: Self = Self(0x20);
Expand Down
14 changes: 9 additions & 5 deletions crates/libs/metadata/src/file/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ pub trait RowReader<'a> {
// GenericParam
//

fn generic_param_number(&self, row: GenericParam) -> u16 {
self.row_usize(row, 0) as u16
}

fn generic_param_name(&self, row: GenericParam) -> &'a str {
self.row_str(row, 3)
}
Expand Down Expand Up @@ -212,7 +216,7 @@ pub trait RowReader<'a> {
//

fn method_def_impl_flags(&self, row: MethodDef) -> MethodImplAttributes {
MethodImplAttributes(self.row_usize(row, 1))
MethodImplAttributes(self.row_usize(row, 1) as u16)
}

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

fn param_sequence(&self, row: Param) -> usize {
self.row_usize(row, 1)
fn param_sequence(&self, row: Param) -> u16 {
self.row_usize(row, 1) as u16
}

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

fn type_def_generics(&self, row: TypeDef) -> Vec<Type> {
self.row_equal_range(row, 2, TypeOrMethodDef::TypeDef(row).encode()).map(Type::GenericParam).collect()
fn type_def_generics(&self, row: TypeDef) -> RowIterator<GenericParam> {
self.row_equal_range(row, 2, TypeOrMethodDef::TypeDef(row).encode())
}

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

0 comments on commit f0c7eda

Please sign in to comment.