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

Method get_local_var_index

crates/codegen/src/compile.rs:790–798  ·  view source on GitHub ↗

Get the index of a local variable.

(&mut self, name: &str)

Source from the content-addressed store, hash-verified

788
789 /// Get the index of a local variable.
790 fn get_local_var_index(&mut self, name: &str) -> CompileResult<oparg::VarNum> {
791 let info = self.code_stack.last_mut().unwrap();
792 let idx = info
793 .metadata
794 .varnames
795 .get_index_of(name)
796 .unwrap_or_else(|| info.metadata.varnames.insert_full(name.to_owned()).0);
797 Ok(idx.to_u32().into())
798 }
799
800 /// Get the index of a global name.
801 fn get_global_name_index(&mut self, name: &str) -> u32 {

Callers 1

compile_nameMethod · 0.80

Calls 3

unwrapMethod · 0.45
to_ownedMethod · 0.45
to_u32Method · 0.45

Tested by

no test coverage detected