mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 05:54:33 +00:00
Add DefKind
This commit is contained in:
parent
1a3f204879
commit
bd17bf3299
5 changed files with 145 additions and 96 deletions
|
@ -26,6 +26,7 @@ use erg_common::vis::Visibility;
|
|||
use erg_common::Str;
|
||||
use erg_common::{fn_name, get_hash, log};
|
||||
|
||||
use erg_parser::ast::DefKind;
|
||||
use erg_type::typaram::TyParam;
|
||||
use erg_type::value::ValueObj;
|
||||
use erg_type::{Predicate, TyBound, Type};
|
||||
|
@ -230,6 +231,17 @@ pub enum ContextKind {
|
|||
Dummy,
|
||||
}
|
||||
|
||||
impl From<DefKind> for ContextKind {
|
||||
fn from(kind: DefKind) -> Self {
|
||||
match kind {
|
||||
DefKind::Class | DefKind::Inherit => Self::Class,
|
||||
DefKind::Trait | DefKind::Subsume => Self::Trait,
|
||||
DefKind::StructuralTrait => Self::StructuralTrait,
|
||||
DefKind::Other => Self::Instant,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ContextKind {
|
||||
pub const fn is_method_def(&self) -> bool {
|
||||
matches!(self, Self::MethodDefs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue