(
vm: &VirtualMachine,
source_file: &SourceFile,
object: PyObjectRef,
)
| 53 | } |
| 54 | |
| 55 | fn ast_from_object( |
| 56 | vm: &VirtualMachine, |
| 57 | source_file: &SourceFile, |
| 58 | object: PyObjectRef, |
| 59 | ) -> PyResult<Self> { |
| 60 | let cls = object.class(); |
| 61 | Ok(if cls.is(pyast::NodeExprBoolOp::static_type()) { |
| 62 | Self::BoolOp(ast::ExprBoolOp::ast_from_object(vm, source_file, object)?) |
| 63 | } else if cls.is(pyast::NodeExprNamedExpr::static_type()) { |
| 64 | Self::Named(ast::ExprNamed::ast_from_object(vm, source_file, object)?) |
| 65 | } else if cls.is(pyast::NodeExprBinOp::static_type()) { |
| 66 | Self::BinOp(ast::ExprBinOp::ast_from_object(vm, source_file, object)?) |
| 67 | } else if cls.is(pyast::NodeExprUnaryOp::static_type()) { |
| 68 | Self::UnaryOp(ast::ExprUnaryOp::ast_from_object(vm, source_file, object)?) |
| 69 | } else if cls.is(pyast::NodeExprLambda::static_type()) { |
| 70 | Self::Lambda(ast::ExprLambda::ast_from_object(vm, source_file, object)?) |
| 71 | } else if cls.is(pyast::NodeExprIfExp::static_type()) { |
| 72 | Self::If(ast::ExprIf::ast_from_object(vm, source_file, object)?) |
| 73 | } else if cls.is(pyast::NodeExprDict::static_type()) { |
| 74 | Self::Dict(ast::ExprDict::ast_from_object(vm, source_file, object)?) |
| 75 | } else if cls.is(pyast::NodeExprSet::static_type()) { |
| 76 | Self::Set(ast::ExprSet::ast_from_object(vm, source_file, object)?) |
| 77 | } else if cls.is(pyast::NodeExprListComp::static_type()) { |
| 78 | Self::ListComp(ast::ExprListComp::ast_from_object(vm, source_file, object)?) |
| 79 | } else if cls.is(pyast::NodeExprSetComp::static_type()) { |
| 80 | Self::SetComp(ast::ExprSetComp::ast_from_object(vm, source_file, object)?) |
| 81 | } else if cls.is(pyast::NodeExprDictComp::static_type()) { |
| 82 | Self::DictComp(ast::ExprDictComp::ast_from_object(vm, source_file, object)?) |
| 83 | } else if cls.is(pyast::NodeExprGeneratorExp::static_type()) { |
| 84 | Self::Generator(ast::ExprGenerator::ast_from_object( |
| 85 | vm, |
| 86 | source_file, |
| 87 | object, |
| 88 | )?) |
| 89 | } else if cls.is(pyast::NodeExprAwait::static_type()) { |
| 90 | Self::Await(ast::ExprAwait::ast_from_object(vm, source_file, object)?) |
| 91 | } else if cls.is(pyast::NodeExprYield::static_type()) { |
| 92 | Self::Yield(ast::ExprYield::ast_from_object(vm, source_file, object)?) |
| 93 | } else if cls.is(pyast::NodeExprYieldFrom::static_type()) { |
| 94 | Self::YieldFrom(ast::ExprYieldFrom::ast_from_object( |
| 95 | vm, |
| 96 | source_file, |
| 97 | object, |
| 98 | )?) |
| 99 | } else if cls.is(pyast::NodeExprCompare::static_type()) { |
| 100 | Self::Compare(ast::ExprCompare::ast_from_object(vm, source_file, object)?) |
| 101 | } else if cls.is(pyast::NodeExprCall::static_type()) { |
| 102 | Self::Call(ast::ExprCall::ast_from_object(vm, source_file, object)?) |
| 103 | } else if cls.is(pyast::NodeExprAttribute::static_type()) { |
| 104 | Self::Attribute(ast::ExprAttribute::ast_from_object( |
| 105 | vm, |
| 106 | source_file, |
| 107 | object, |
| 108 | )?) |
| 109 | } else if cls.is(pyast::NodeExprSubscript::static_type()) { |
| 110 | Self::Subscript(ast::ExprSubscript::ast_from_object( |
| 111 | vm, |
| 112 | source_file, |
nothing calls this directly
no test coverage detected