mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 12:14:43 +00:00
feat: add Frame
type
This commit is contained in:
parent
0a24c0cb77
commit
fc75151f2a
4 changed files with 32 additions and 2 deletions
|
@ -342,8 +342,6 @@ impl<Parser: ASTBuildable, Builder: Buildable> PackageBuilder<Parser, Builder> {
|
||||||
graph.remove(&ancestor);
|
graph.remove(&ancestor);
|
||||||
if let Some((__name__, ancestor_ast)) = self.asts.remove(&ancestor) {
|
if let Some((__name__, ancestor_ast)) = self.asts.remove(&ancestor) {
|
||||||
self.start_analysis_process(ancestor_ast, __name__, ancestor);
|
self.start_analysis_process(ancestor_ast, __name__, ancestor);
|
||||||
} else if !self.submodules.contains(&ancestor) {
|
|
||||||
panic!("not found: {ancestor}");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ancestors.insert(0, ancestor);
|
ancestors.insert(0, ancestor);
|
||||||
|
|
|
@ -1303,6 +1303,28 @@ impl Context {
|
||||||
);
|
);
|
||||||
code.register_trait(Code, code_hash);
|
code.register_trait(Code, code_hash);
|
||||||
code.register_marker_trait(self, mono(EQ_HASH)).unwrap();
|
code.register_marker_trait(self, mono(EQ_HASH)).unwrap();
|
||||||
|
let mut frame = Self::builtin_mono_class(FRAME, 10);
|
||||||
|
frame.register_builtin_erg_impl(
|
||||||
|
F_BUILTINS,
|
||||||
|
mono(GENERIC_DICT),
|
||||||
|
Immutable,
|
||||||
|
Visibility::BUILTIN_PUBLIC,
|
||||||
|
);
|
||||||
|
frame.register_builtin_erg_impl(F_CODE, Code, Immutable, Visibility::BUILTIN_PUBLIC);
|
||||||
|
frame.register_builtin_erg_impl(
|
||||||
|
F_GLOBALS,
|
||||||
|
mono(GENERIC_DICT),
|
||||||
|
Immutable,
|
||||||
|
Visibility::BUILTIN_PUBLIC,
|
||||||
|
);
|
||||||
|
frame.register_builtin_erg_impl(F_LASTI, Nat, Immutable, Visibility::BUILTIN_PUBLIC);
|
||||||
|
frame.register_builtin_erg_impl(F_LINENO, Nat, Immutable, Visibility::BUILTIN_PUBLIC);
|
||||||
|
frame.register_builtin_erg_impl(
|
||||||
|
F_LOCALS,
|
||||||
|
mono(GENERIC_DICT),
|
||||||
|
Immutable,
|
||||||
|
Visibility::BUILTIN_PUBLIC,
|
||||||
|
);
|
||||||
let g_module_t = mono(GENERIC_MODULE);
|
let g_module_t = mono(GENERIC_MODULE);
|
||||||
let mut generic_module = Self::builtin_mono_class(GENERIC_MODULE, 2);
|
let mut generic_module = Self::builtin_mono_class(GENERIC_MODULE, 2);
|
||||||
generic_module.register_superclass(Obj, &obj);
|
generic_module.register_superclass(Obj, &obj);
|
||||||
|
@ -2950,6 +2972,7 @@ impl Context {
|
||||||
self.register_builtin_type(ClassType, class_type, vis.clone(), Const, Some(CLASS_TYPE));
|
self.register_builtin_type(ClassType, class_type, vis.clone(), Const, Some(CLASS_TYPE));
|
||||||
self.register_builtin_type(TraitType, trait_type, vis.clone(), Const, Some(TRAIT_TYPE));
|
self.register_builtin_type(TraitType, trait_type, vis.clone(), Const, Some(TRAIT_TYPE));
|
||||||
self.register_builtin_type(Code, code, vis.clone(), Const, Some(CODE_TYPE));
|
self.register_builtin_type(Code, code, vis.clone(), Const, Some(CODE_TYPE));
|
||||||
|
self.register_builtin_type(Frame, frame, vis.clone(), Const, Some(FRAME_TYPE));
|
||||||
self.register_builtin_type(
|
self.register_builtin_type(
|
||||||
g_module_t,
|
g_module_t,
|
||||||
generic_module,
|
generic_module,
|
||||||
|
|
|
@ -202,6 +202,7 @@ const CLASS_TYPE: &str = "ClassType";
|
||||||
const TRAIT: &str = "Trait";
|
const TRAIT: &str = "Trait";
|
||||||
const TRAIT_TYPE: &str = "TraitType";
|
const TRAIT_TYPE: &str = "TraitType";
|
||||||
const CODE: &str = "Code";
|
const CODE: &str = "Code";
|
||||||
|
const FRAME: &str = "Frame";
|
||||||
const FUNC_MRO: &str = "mro";
|
const FUNC_MRO: &str = "mro";
|
||||||
const FUNC_CO_ARGCOUNT: &str = "co_argcount";
|
const FUNC_CO_ARGCOUNT: &str = "co_argcount";
|
||||||
const FUNC_CO_VARNAMES: &str = "co_varnames";
|
const FUNC_CO_VARNAMES: &str = "co_varnames";
|
||||||
|
@ -322,6 +323,7 @@ const FUNC_STR__: &str = "str__";
|
||||||
const FUNC_TYPE: &str = "type";
|
const FUNC_TYPE: &str = "type";
|
||||||
const CODE_TYPE: &str = "CodeType";
|
const CODE_TYPE: &str = "CodeType";
|
||||||
const MODULE_TYPE: &str = "ModuleType";
|
const MODULE_TYPE: &str = "ModuleType";
|
||||||
|
const FRAME_TYPE: &str = "FrameType";
|
||||||
const FUNC_LIST: &str = "list";
|
const FUNC_LIST: &str = "list";
|
||||||
const _FUNC_SET: &str = "set";
|
const _FUNC_SET: &str = "set";
|
||||||
const FUNC_DICT: &str = "dict";
|
const FUNC_DICT: &str = "dict";
|
||||||
|
@ -476,6 +478,12 @@ const SITEBUILTINS_PRINTER: &str = "_sitebuiltins._Printer";
|
||||||
const PY: &str = "py";
|
const PY: &str = "py";
|
||||||
const PYIMPORT: &str = "pyimport";
|
const PYIMPORT: &str = "pyimport";
|
||||||
const PYCOMPILE: &str = "pycompile";
|
const PYCOMPILE: &str = "pycompile";
|
||||||
|
const F_BUILTINS: &str = "f_builtins";
|
||||||
|
const F_CODE: &str = "f_code";
|
||||||
|
const F_GLOBALS: &str = "f_globals";
|
||||||
|
const F_LASTI: &str = "f_lasti";
|
||||||
|
const F_LINENO: &str = "f_lineno";
|
||||||
|
const F_LOCALS: &str = "f_locals";
|
||||||
|
|
||||||
const TY_A: &str = "A";
|
const TY_A: &str = "A";
|
||||||
const TY_B: &str = "B";
|
const TY_B: &str = "B";
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
.FrameInfo: ClassType
|
.FrameInfo: ClassType
|
||||||
.Traceback: ClassType
|
.Traceback: ClassType
|
||||||
|
|
||||||
|
.currentframe!: () => Frame
|
||||||
.ismodule: (object: Obj) -> Bool
|
.ismodule: (object: Obj) -> Bool
|
||||||
.isclass: (object: Obj) -> Bool
|
.isclass: (object: Obj) -> Bool
|
||||||
.ismethod: (object: Obj) -> Bool
|
.ismethod: (object: Obj) -> Bool
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue