mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 04:24:43 +00:00
Rename: Type::Class -> Type::ClassType
This commit is contained in:
parent
5396b13e6d
commit
b8b6acdf3a
5 changed files with 35 additions and 26 deletions
|
@ -163,7 +163,7 @@ impl Context {
|
|||
| (Float | Ratio | Int, Int)
|
||||
| (Float | Ratio, Ratio)
|
||||
| (Float, Float) => (Absolutely, true),
|
||||
(Type, Class | Trait) => (Absolutely, true),
|
||||
(Type, ClassType | TraitType) => (Absolutely, true),
|
||||
(Type, Record(rec)) => (
|
||||
Absolutely,
|
||||
rec.iter().all(|(_, attr)| self.supertype_of(&Type, attr)),
|
||||
|
|
|
@ -772,8 +772,17 @@ impl Context {
|
|||
class_type.register_superclass(Type, &type_);
|
||||
class_type.register_marker_trait(builtin_mono("Named"));
|
||||
let mut class_eq = Self::builtin_methods("Eq", 2);
|
||||
class_eq.register_builtin_impl("__eq__", fn1_met(Class, Class, Bool), Const, Public);
|
||||
class_type.register_trait(Class, builtin_poly("Eq", vec![ty_tp(Class)]), class_eq);
|
||||
class_eq.register_builtin_impl(
|
||||
"__eq__",
|
||||
fn1_met(ClassType, ClassType, Bool),
|
||||
Const,
|
||||
Public,
|
||||
);
|
||||
class_type.register_trait(
|
||||
ClassType,
|
||||
builtin_poly("Eq", vec![ty_tp(ClassType)]),
|
||||
class_eq,
|
||||
);
|
||||
let g_module_t = builtin_mono("GenericModule");
|
||||
let mut generic_module = Self::builtin_mono_class("GenericModule", 2);
|
||||
generic_module.register_superclass(Obj, &obj);
|
||||
|
@ -1645,7 +1654,7 @@ impl Context {
|
|||
self.register_builtin_type(Bool, bool_, Const);
|
||||
self.register_builtin_type(Str, str_, Const);
|
||||
self.register_builtin_type(Type, type_, Const);
|
||||
self.register_builtin_type(Class, class_type, Const);
|
||||
self.register_builtin_type(ClassType, class_type, Const);
|
||||
self.register_builtin_type(g_module_t, generic_module, Const);
|
||||
self.register_builtin_type(module_t, module, Const);
|
||||
self.register_builtin_type(array_t, array_, Const);
|
||||
|
@ -1741,7 +1750,7 @@ impl Context {
|
|||
vec![kw("err_message", Str)],
|
||||
NoneType,
|
||||
);
|
||||
let t_classof = nd_func(vec![kw("old", Obj)], None, Class);
|
||||
let t_classof = nd_func(vec![kw("old", Obj)], None, ClassType);
|
||||
let t_compile = nd_func(vec![kw("src", Str)], None, Code);
|
||||
let t_cond = nd_func(
|
||||
vec![
|
||||
|
@ -1820,15 +1829,15 @@ impl Context {
|
|||
vec![kw("Requirement", Type)],
|
||||
None,
|
||||
vec![kw("Impl", Type)],
|
||||
Class,
|
||||
ClassType,
|
||||
);
|
||||
let class = ConstSubr::Builtin(BuiltinConstSubr::new("Class", class_func, class_t, None));
|
||||
self.register_builtin_const("Class", ValueObj::Subr(class));
|
||||
let inherit_t = func(
|
||||
vec![kw("Super", Class)],
|
||||
vec![kw("Super", ClassType)],
|
||||
None,
|
||||
vec![kw("Impl", Type), kw("Additional", Type)],
|
||||
Class,
|
||||
ClassType,
|
||||
);
|
||||
let inherit = ConstSubr::Builtin(BuiltinConstSubr::new(
|
||||
"Inherit",
|
||||
|
@ -1841,15 +1850,15 @@ impl Context {
|
|||
vec![kw("Requirement", Type)],
|
||||
None,
|
||||
vec![kw("Impl", Type)],
|
||||
Trait,
|
||||
TraitType,
|
||||
);
|
||||
let trait_ = ConstSubr::Builtin(BuiltinConstSubr::new("Trait", trait_func, trait_t, None));
|
||||
self.register_builtin_const("Trait", ValueObj::Subr(trait_));
|
||||
let subsume_t = func(
|
||||
vec![kw("Super", Trait)],
|
||||
vec![kw("Super", TraitType)],
|
||||
None,
|
||||
vec![kw("Impl", Type), kw("Additional", Type)],
|
||||
Trait,
|
||||
TraitType,
|
||||
);
|
||||
let subsume = ConstSubr::Builtin(BuiltinConstSubr::new(
|
||||
"Subsume",
|
||||
|
@ -1859,7 +1868,7 @@ impl Context {
|
|||
));
|
||||
self.register_builtin_const("Subsume", ValueObj::Subr(subsume));
|
||||
// decorators
|
||||
let inheritable_t = func1(Class, Class);
|
||||
let inheritable_t = func1(ClassType, ClassType);
|
||||
let inheritable = ConstSubr::Builtin(BuiltinConstSubr::new(
|
||||
"Inheritable",
|
||||
inheritable_func,
|
||||
|
|
|
@ -1131,7 +1131,7 @@ impl ASTLowerer {
|
|||
loc,
|
||||
self.ctx.caused_by(),
|
||||
&impl_trait.name(),
|
||||
&Type::Trait,
|
||||
&Type::TraitType,
|
||||
&trait_obj.t(),
|
||||
None,
|
||||
None,
|
||||
|
@ -1359,7 +1359,7 @@ impl ASTLowerer {
|
|||
ast::DefId(0),
|
||||
)?;
|
||||
match t {
|
||||
Type::Class => {
|
||||
Type::ClassType => {
|
||||
let ty_obj = GenTypeObj::new(
|
||||
TypeKind::Class,
|
||||
mono(self.ctx.path(), ident.inspect()),
|
||||
|
@ -1369,7 +1369,7 @@ impl ASTLowerer {
|
|||
);
|
||||
self.ctx.register_gen_type(&ident, ty_obj);
|
||||
}
|
||||
Type::Trait => {
|
||||
Type::TraitType => {
|
||||
let ty_obj = GenTypeObj::new(
|
||||
TypeKind::Trait,
|
||||
mono(self.ctx.path(), ident.inspect()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue