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

Method ast_to_object

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

Source from the content-addressed store, hash-verified

4// product
5impl Node for ast::Parameters {
6 fn ast_to_object(self, vm: &VirtualMachine, source_file: &SourceFile) -> PyObjectRef {
7 let Self {
8 node_index: _,
9 posonlyargs,
10 args,
11 vararg,
12 kwonlyargs,
13 kwarg,
14 range,
15 } = self;
16 let (posonlyargs, args, defaults) =
17 extract_positional_parameter_defaults(posonlyargs, args);
18 let (kwonlyargs, kw_defaults) = extract_keyword_parameter_defaults(kwonlyargs);
19 let node = NodeAst
20 .into_ref_with_type(vm, pyast::NodeArguments::static_type().to_owned())
21 .unwrap();
22 let dict = node.as_object().dict().unwrap();
23 dict.set_item(
24 "posonlyargs",
25 posonlyargs.ast_to_object(vm, source_file),
26 vm,
27 )
28 .unwrap();
29 dict.set_item("args", args.ast_to_object(vm, source_file), vm)
30 .unwrap();
31 dict.set_item("vararg", vararg.ast_to_object(vm, source_file), vm)
32 .unwrap();
33 dict.set_item("kwonlyargs", kwonlyargs.ast_to_object(vm, source_file), vm)
34 .unwrap();
35 dict.set_item(
36 "kw_defaults",
37 kw_defaults.ast_to_object(vm, source_file),
38 vm,
39 )
40 .unwrap();
41 dict.set_item("kwarg", kwarg.ast_to_object(vm, source_file), vm)
42 .unwrap();
43 dict.set_item("defaults", defaults.ast_to_object(vm, source_file), vm)
44 .unwrap();
45 let _ = range;
46 node.into()
47 }
48
49 fn ast_from_object(
50 vm: &VirtualMachine,

Callers

nothing calls this directly

Calls 14

newFunction · 0.85
node_add_locationFunction · 0.85
BoxedSliceClass · 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

Tested by

no test coverage detected