1#![allow(dead_code, clippy::enum_variant_names)]
2
3/// A `ResolutionScope` is an index into a certain table indicating the scope in which a TypeRef can be resolved.
4#[derive(Clone)]
5pub enum ResolutionScope {
6 Module(u32),
7 ModuleRef(u32),
8 AssemblyRef(u32),
9 TypeRef(u32),
10}
11
12impl ResolutionScope {
13 pub fn encode(&self) -> u32 {
14 match self {
15 Self::Module(row: &u32) => (row + 1) << 2,
16 Self::ModuleRef(row: &u32) => ((row + 1) << 2) + 1,
17 Self::AssemblyRef(row: &u32) => ((row + 1) << 2) + 2,
18 Self::TypeRef(row: &u32) => ((row + 1) << 2) + 3,
19 }
20 }
21}
22
23/// A `TypeDefOrRef` is an index into a certain table used to locate a type definition.
24#[derive(Clone)]
25pub enum TypeDefOrRef {
26 TypeDef(u32),
27 TypeRef(u32),
28 TypeSpec(u32),
29}
30
31impl TypeDefOrRef {
32 pub fn encode(&self) -> u32 {
33 match self {
34 Self::TypeDef(row: &u32) => (row + 1) << 2,
35 Self::TypeRef(row: &u32) => ((row + 1) << 2) + 1,
36 Self::TypeSpec(row: &u32) => ((row + 1) << 2) + 2,
37 }
38 }
39}
40
41/// A `HasConstant` is an index into a certain table used to identify the parent of a row in the `Constant` table.
42#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
43pub enum HasConstant {
44 Field(u32),
45 Param(u32),
46 Property(u32),
47}
48
49impl HasConstant {
50 pub fn encode(&self) -> u32 {
51 match self {
52 Self::Field(row: &u32) => (row + 1) << 2,
53 Self::Param(row: &u32) => ((row + 1) << 2) + 1,
54 Self::Property(row: &u32) => ((row + 1) << 2) + 2,
55 }
56 }
57}
58
59/// A `TypeOrMethodDef` is an index into a certain table used to locate the owner of a generic parameter.
60#[derive(Clone)]
61pub enum TypeOrMethodDef {
62 TypeDef(u32),
63}
64
65impl TypeOrMethodDef {
66 pub fn encode(&self) -> u32 {
67 match self {
68 Self::TypeDef(row: &u32) => (row + 1) << 1,
69 }
70 }
71}
72