mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 18:58:30 +00:00
feat: add Sealed
trait
This commit is contained in:
parent
86cfe8f81a
commit
1c699cc2f3
14 changed files with 101 additions and 24 deletions
|
@ -2338,15 +2338,8 @@ impl Context {
|
|||
.register_trait(self, poly(OUTPUT, vec![ty_tp(T.clone())]))
|
||||
.unwrap();
|
||||
let homo_tuple_t = poly(HOMOGENOUS_TUPLE, vec![ty_tp(T.clone())]);
|
||||
// __Tuple_getitem__: (self: HomogenousTuple(T), Nat) -> T
|
||||
// __getitem__: (self: HomogenousTuple(T), Nat) -> T
|
||||
let tuple_getitem_t = fn1_met(homo_tuple_t.clone(), Nat, T.clone()).quantify();
|
||||
homo_tuple.register_builtin_py_impl(
|
||||
FUNDAMENTAL_TUPLE_GETITEM,
|
||||
tuple_getitem_t.clone(),
|
||||
Const,
|
||||
Visibility::BUILTIN_PUBLIC,
|
||||
Some(FUNDAMENTAL_GETITEM),
|
||||
);
|
||||
homo_tuple.register_builtin_py_impl(
|
||||
FUNDAMENTAL_GETITEM,
|
||||
tuple_getitem_t,
|
||||
|
|
|
@ -98,6 +98,7 @@ const TO_BOOL: &str = "ToBool";
|
|||
const TO_INT: &str = "ToInt";
|
||||
const TO_FLOAT: &str = "ToFloat";
|
||||
const ROUND: &str = "Round";
|
||||
const SEALED: &str = "Sealed";
|
||||
const INPUT: &str = "Input";
|
||||
const OUTPUT: &str = "Output";
|
||||
const POW_OUTPUT: &str = "PowOutput";
|
||||
|
|
|
@ -25,6 +25,7 @@ impl Context {
|
|||
} else {
|
||||
Visibility::BUILTIN_PRIVATE
|
||||
};
|
||||
let sealed = Self::builtin_mono_trait(SEALED, 1);
|
||||
let unpack = Self::builtin_mono_trait(UNPACK, 2);
|
||||
let inheritable_type = Self::builtin_mono_trait(INHERITABLE_TYPE, 2);
|
||||
let mut named = Self::builtin_mono_trait(NAMED, 2);
|
||||
|
@ -626,6 +627,7 @@ impl Context {
|
|||
round.register_builtin_erg_decl(FUNDAMENTAL_FLOOR, op_t, Visibility::BUILTIN_PUBLIC);
|
||||
let op_t = fn0_met(_Slf.clone(), Int).quantify();
|
||||
round.register_builtin_erg_decl(FUNDAMENTAL_CEIL, op_t, Visibility::BUILTIN_PUBLIC);
|
||||
self.register_builtin_type(mono(SEALED), sealed, vis.clone(), Const, None);
|
||||
self.register_builtin_type(mono(UNPACK), unpack, vis.clone(), Const, None);
|
||||
self.register_builtin_type(
|
||||
mono(INHERITABLE_TYPE),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue