mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Implement default parameter
This commit is contained in:
parent
af65a48355
commit
d0456ec1ee
10 changed files with 375 additions and 171 deletions
|
@ -94,6 +94,29 @@ impl CodeObjFlags {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[repr(u8)]
|
||||
pub enum MakeFunctionFlags {
|
||||
None = 0,
|
||||
Defaults = 1,
|
||||
KwDefaults = 2,
|
||||
Annotations = 4,
|
||||
Closure = 8,
|
||||
}
|
||||
|
||||
impl From<u8> for MakeFunctionFlags {
|
||||
fn from(flags: u8) -> Self {
|
||||
match flags {
|
||||
0 => Self::None,
|
||||
1 => Self::Defaults,
|
||||
2 => Self::KwDefaults,
|
||||
4 => Self::Annotations,
|
||||
8 => Self::Closure,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation of `PyCodeObject`, see Include/cpython/code.h in CPython for details.
|
||||
///
|
||||
/// 各属性をErg側のObjに変換すると遅くなりそうなので、アクサスされたときのみ変換して提供する
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue