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

Method get_free_var_index

crates/codegen/src/compile.rs:767–775  ·  view source on GitHub ↗

Get the cell-relative index of a free variable. Returns ncells + freevar_idx. Fixed up to localsplus index during finalize.

(&mut self, name: &str)

Source from the content-addressed store, hash-verified

765 /// Get the cell-relative index of a free variable.
766 /// Returns ncells + freevar_idx. Fixed up to localsplus index during finalize.
767 fn get_free_var_index(&mut self, name: &str) -> CompileResult<oparg::VarNum> {
768 let info = self.code_stack.last_mut().unwrap();
769 let idx = info
770 .metadata
771 .freevars
772 .get_index_of(name)
773 .unwrap_or_else(|| info.metadata.freevars.insert_full(name.to_owned()).0);
774 Ok((idx + info.metadata.cellvars.len()).to_u32().into())
775 }
776
777 /// Get the cell-relative index of a cell variable.
778 /// Returns cellvar_idx. Fixed up to localsplus index during finalize.

Callers 4

load_args_for_superMethod · 0.80
compile_nameMethod · 0.80

Calls 4

unwrapMethod · 0.45
to_ownedMethod · 0.45
to_u32Method · 0.45
lenMethod · 0.45

Tested by

no test coverage detected