MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_cell_var_index

Method get_cell_var_index

crates/codegen/src/compile.rs:779–787  ·  view source on GitHub ↗

Get the cell-relative index of a cell variable. Returns cellvar_idx. Fixed up to localsplus index during finalize.

(&mut self, name: &str)

Source from the content-addressed store, hash-verified

777 /// Get the cell-relative index of a cell variable.
778 /// Returns cellvar_idx. Fixed up to localsplus index during finalize.
779 fn get_cell_var_index(&mut self, name: &str) -> CompileResult<oparg::VarNum> {
780 let info = self.code_stack.last_mut().unwrap();
781 let idx = info
782 .metadata
783 .cellvars
784 .get_index_of(name)
785 .unwrap_or_else(|| info.metadata.cellvars.insert_full(name.to_owned()).0);
786 Ok(idx.to_u32().into())
787 }
788
789 /// Get the index of a local variable.
790 fn get_local_var_index(&mut self, name: &str) -> CompileResult<oparg::VarNum> {

Callers 4

load_args_for_superMethod · 0.80
compile_nameMethod · 0.80
compile_class_bodyMethod · 0.80

Calls 3

unwrapMethod · 0.45
to_ownedMethod · 0.45
to_u32Method · 0.45

Tested by

no test coverage detected