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

Method ast_to_object

crates/vm/src/stdlib/_ast/pattern.rs:6–25  ·  view source on GitHub ↗
(self, vm: &VirtualMachine, source_file: &SourceFile)

Source from the content-addressed store, hash-verified

4// product
5impl Node for ast::MatchCase {
6 fn ast_to_object(self, vm: &VirtualMachine, source_file: &SourceFile) -> PyObjectRef {
7 let Self {
8 node_index: _,
9 pattern,
10 guard,
11 body,
12 range: _,
13 } = self;
14 let node = NodeAst
15 .into_ref_with_type(vm, pyast::NodeMatchCase::static_type().to_owned())
16 .unwrap();
17 let dict = node.as_object().dict().unwrap();
18 dict.set_item("pattern", pattern.ast_to_object(vm, source_file), vm)
19 .unwrap();
20 dict.set_item("guard", guard.ast_to_object(vm, source_file), vm)
21 .unwrap();
22 dict.set_item("body", body.ast_to_object(vm, source_file), vm)
23 .unwrap();
24 node.into()
25 }
26
27 fn ast_from_object(
28 vm: &VirtualMachine,

Callers

nothing calls this directly

Calls 10

node_add_locationFunction · 0.85
into_ref_with_typeMethod · 0.80
noneMethod · 0.80
unwrapMethod · 0.45
to_ownedMethod · 0.45
dictMethod · 0.45
as_objectMethod · 0.45
set_itemMethod · 0.45
new_boolMethod · 0.45

Tested by

no test coverage detected