Skip to content

Commit

Permalink
Merge pull request #526 from GreasySlug/feat-pathlib
Browse files Browse the repository at this point in the history
Add glob! and resolve! Methods in Pathlib.d.er
  • Loading branch information
GreasySlug authored Sep 23, 2024
2 parents 6890d82 + a2e8ba4 commit 21caf6f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
20 changes: 9 additions & 11 deletions crates/erg_compiler/context/initialize/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4045,10 +4045,14 @@ impl Context {
Immutable,
Visibility::BUILTIN_PRIVATE,
);
let mut g_generator = Self::builtin_mono_class(GENERIC_GENERATOR, 2);
g_generator.register_superclass(mono(SUBROUTINE), &subr);
let t_yield = fn1_met(mono(GENERIC_GENERATOR), Obj, Never).quantify();
g_generator.register_builtin_erg_impl(
let generator_t = poly(GENERATOR, vec![ty_tp(T.clone())]);
let mut generator = Self::builtin_poly_class(GENERATOR, vec![PS::t_nd(TY_T)], 2);
generator.register_superclass(mono(SUBROUTINE), &subr);
generator
.register_trait(self, poly(ITERATOR, vec![ty_tp(T.clone())]))
.unwrap();
let t_yield = fn1_met(generator_t.clone(), T.clone(), Never).quantify();
generator.register_builtin_erg_impl(
FUNC_YIELD,
t_yield,
Immutable,
Expand Down Expand Up @@ -4674,13 +4678,7 @@ impl Context {
self.register_builtin_type(dict_mut_t, dict_mut, vis.clone(), Const, Some(DICT));
self.register_builtin_type(set_mut_t, set_mut_, vis.clone(), Const, Some(SET));
self.register_builtin_type(mono(SUBROUTINE), subr, vis.clone(), Const, Some(SUBROUTINE));
self.register_builtin_type(
mono(GENERIC_GENERATOR),
g_generator,
vis.clone(),
Const,
Some(GENERATOR),
);
self.register_builtin_type(generator_t, generator, vis.clone(), Const, Some(GENERATOR));
self.register_builtin_type(dimension_t, dimension, vis.clone(), Const, Some(DIMENSION));
self.register_builtin_type(
mono(BASE_EXCEPTION),
Expand Down
1 change: 0 additions & 1 deletion crates/erg_compiler/context/initialize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ const PROC_INVERT: &str = "invert!";
const RANGE: &str = "Range";
const GENERIC_CALLABLE: &str = "GenericCallable";
const SUBROUTINE: &str = "Subroutine";
const GENERIC_GENERATOR: &str = "GenericGenerator";
const FUNC_RETURN: &str = "return";
const FUNC_YIELD: &str = "yield";
const PROC: &str = "Proc";
Expand Down
4 changes: 3 additions & 1 deletion crates/erg_compiler/lib/pystd/pathlib.d.er
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@
chmod!: (self: .Path, mode: Nat) => NoneType
exists!: (self: .Path) => Bool
expanduser!: (self: .Path) => .Path
glob!: (self: .Path, pattern: Str) => Generator .Path
home!: () => .Path
iterdir!: (self: .Path) => Iterable .Path
iterdir!: (self: .Path) => Generator .Path
joinpath: (self: .Path, *other: PathLike) -> .Path
mkdir!: (self: .Path, mode := Nat, parents := Bool, exist_ok := Bool) => NoneType
open!: (self: .Path, mode := Str) => File!
rmdir!: (self: .Path) => NoneType
read_bytes!: (self: .Path) => Bytes
read_text!: (self: .Path, encoding := Str, errors := Str) => Str
rename!: (self: .Path, target: PathLike) => NoneType
resolve!: (self: .Path, strict := Bool) => .Path
samefile!: (self: .Path, other: PathLike) => Bool
touch!: (self: .Path, mode := Nat, exist_ok := Bool) => NoneType
unlink!: (self: .Path, missing_ok := Bool) => NoneType
Expand Down

0 comments on commit 21caf6f

Please sign in to comment.