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

Method ast_to_object

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

Source from the content-addressed store, hash-verified

9// sum
10impl Node for ast::Expr {
11 fn ast_to_object(self, vm: &VirtualMachine, source_file: &SourceFile) -> PyObjectRef {
12 match self {
13 Self::BoolOp(cons) => cons.ast_to_object(vm, source_file),
14 Self::Name(cons) => cons.ast_to_object(vm, source_file),
15 Self::BinOp(cons) => cons.ast_to_object(vm, source_file),
16 Self::UnaryOp(cons) => cons.ast_to_object(vm, source_file),
17 Self::Lambda(cons) => cons.ast_to_object(vm, source_file),
18 Self::If(cons) => cons.ast_to_object(vm, source_file),
19 Self::Dict(cons) => cons.ast_to_object(vm, source_file),
20 Self::Set(cons) => cons.ast_to_object(vm, source_file),
21 Self::ListComp(cons) => cons.ast_to_object(vm, source_file),
22 Self::SetComp(cons) => cons.ast_to_object(vm, source_file),
23 Self::DictComp(cons) => cons.ast_to_object(vm, source_file),
24 Self::Generator(cons) => cons.ast_to_object(vm, source_file),
25 Self::Await(cons) => cons.ast_to_object(vm, source_file),
26 Self::Yield(cons) => cons.ast_to_object(vm, source_file),
27 Self::YieldFrom(cons) => cons.ast_to_object(vm, source_file),
28 Self::Compare(cons) => cons.ast_to_object(vm, source_file),
29 Self::Call(cons) => cons.ast_to_object(vm, source_file),
30 Self::Attribute(cons) => cons.ast_to_object(vm, source_file),
31 Self::Subscript(cons) => cons.ast_to_object(vm, source_file),
32 Self::Starred(cons) => cons.ast_to_object(vm, source_file),
33 Self::List(cons) => cons.ast_to_object(vm, source_file),
34 Self::Tuple(cons) => cons.ast_to_object(vm, source_file),
35 Self::Slice(cons) => cons.ast_to_object(vm, source_file),
36 Self::NumberLiteral(cons) => constant::number_literal_to_object(vm, source_file, cons),
37 Self::StringLiteral(cons) => constant::string_literal_to_object(vm, source_file, cons),
38 Self::FString(cons) => string::fstring_to_object(vm, source_file, cons),
39 Self::TString(cons) => string::tstring_to_object(vm, source_file, cons),
40 Self::BytesLiteral(cons) => constant::bytes_literal_to_object(vm, source_file, cons),
41 Self::BooleanLiteral(cons) => {
42 constant::boolean_literal_to_object(vm, source_file, cons)
43 }
44 Self::NoneLiteral(cons) => constant::none_literal_to_object(vm, source_file, cons),
45 Self::EllipsisLiteral(cons) => {
46 constant::ellipsis_literal_to_object(vm, source_file, cons)
47 }
48 Self::Named(cons) => cons.ast_to_object(vm, source_file),
49 Self::IpyEscapeCommand(_) => {
50 unimplemented!("IPython escape command is not allowed in Python AST")
51 }
52 }
53 }
54
55 fn ast_from_object(
56 vm: &VirtualMachine,

Callers

nothing calls this directly

Calls 15

number_literal_to_objectFunction · 0.85
string_literal_to_objectFunction · 0.85
fstring_to_objectFunction · 0.85
tstring_to_objectFunction · 0.85
bytes_literal_to_objectFunction · 0.85
none_literal_to_objectFunction · 0.85
node_add_locationFunction · 0.85
empty_arguments_objectFunction · 0.85
newFunction · 0.85
BoxedSliceClass · 0.85

Tested by

no test coverage detected