mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
feat: add const Array::{insert, remove_at, remove_all}
This commit is contained in:
parent
b7d9598d28
commit
66352ddd3a
7 changed files with 201 additions and 11 deletions
|
@ -292,8 +292,11 @@ const FUNC_EXTEND: &str = "extend";
|
|||
const PROC_EXTEND: &str = "extend!";
|
||||
const FUNC_INSERT: &str = "insert";
|
||||
const PROC_INSERT: &str = "insert!";
|
||||
const FUNC_INSERT_AT: &str = "insert_at";
|
||||
const FUNC_REMOVE: &str = "remove";
|
||||
const PROC_REMOVE: &str = "remove!";
|
||||
const FUNC_REMOVE_AT: &str = "remove_at";
|
||||
const FUNC_REMOVE_ALL: &str = "remove_all";
|
||||
const FUNC_POP: &str = "pop";
|
||||
const PROC_POP: &str = "pop!";
|
||||
const FUNC_COPY: &str = "copy";
|
||||
|
@ -748,6 +751,17 @@ impl Context {
|
|||
vis: Visibility,
|
||||
t: Option<Type>,
|
||||
obj: ValueObj,
|
||||
) {
|
||||
self._register_builtin_const(name, vis, t, obj, None)
|
||||
}
|
||||
|
||||
fn _register_builtin_const(
|
||||
&mut self,
|
||||
name: &str,
|
||||
vis: Visibility,
|
||||
t: Option<Type>,
|
||||
obj: ValueObj,
|
||||
py_name: Option<Str>,
|
||||
) {
|
||||
if self.rec_get_const_obj(name).is_some() {
|
||||
panic!("already registered: {} {name}", self.name);
|
||||
|
@ -772,7 +786,7 @@ impl Context {
|
|||
Builtin,
|
||||
None,
|
||||
self.kind.clone(),
|
||||
None,
|
||||
py_name,
|
||||
AbsLocation::unknown(),
|
||||
);
|
||||
self.consts.insert(VarName::from_str(Str::rc(name)), obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue