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

Method ast_to_object

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

Source from the content-addressed store, hash-verified

5// sum
6impl Node for ast::Stmt {
7 fn ast_to_object(self, vm: &VirtualMachine, source_file: &SourceFile) -> PyObjectRef {
8 match self {
9 Self::FunctionDef(cons) => cons.ast_to_object(vm, source_file),
10 Self::ClassDef(cons) => cons.ast_to_object(vm, source_file),
11 Self::Return(cons) => cons.ast_to_object(vm, source_file),
12 Self::Delete(cons) => cons.ast_to_object(vm, source_file),
13 Self::Assign(cons) => cons.ast_to_object(vm, source_file),
14 Self::TypeAlias(cons) => cons.ast_to_object(vm, source_file),
15 Self::AugAssign(cons) => cons.ast_to_object(vm, source_file),
16 Self::AnnAssign(cons) => cons.ast_to_object(vm, source_file),
17 Self::For(cons) => cons.ast_to_object(vm, source_file),
18 Self::While(cons) => cons.ast_to_object(vm, source_file),
19 Self::If(cons) => cons.ast_to_object(vm, source_file),
20 Self::With(cons) => cons.ast_to_object(vm, source_file),
21 Self::Match(cons) => cons.ast_to_object(vm, source_file),
22 Self::Raise(cons) => cons.ast_to_object(vm, source_file),
23 Self::Try(cons) => cons.ast_to_object(vm, source_file),
24 Self::Assert(cons) => cons.ast_to_object(vm, source_file),
25 Self::Import(cons) => cons.ast_to_object(vm, source_file),
26 Self::ImportFrom(cons) => cons.ast_to_object(vm, source_file),
27 Self::Global(cons) => cons.ast_to_object(vm, source_file),
28 Self::Nonlocal(cons) => cons.ast_to_object(vm, source_file),
29 Self::Expr(cons) => cons.ast_to_object(vm, source_file),
30 Self::Pass(cons) => cons.ast_to_object(vm, source_file),
31 Self::Break(cons) => cons.ast_to_object(vm, source_file),
32 Self::Continue(cons) => cons.ast_to_object(vm, source_file),
33 Self::IpyEscapeCommand(_) => {
34 unimplemented!("IPython escape command is not allowed in Python AST")
35 }
36 }
37 }
38
39 #[allow(clippy::if_same_then_else)]
40 fn ast_from_object(

Callers

nothing calls this directly

Calls 15

newFunction · 0.85
node_add_locationFunction · 0.85
split_class_def_argsFunction · 0.85
ast_to_objectFunction · 0.85
line_indexMethod · 0.80
into_ref_with_typeMethod · 0.80
noneMethod · 0.80
new_listMethod · 0.80
SomeClass · 0.50
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected