(
vm: &VirtualMachine,
source_file: &SourceFile,
object: PyObjectRef,
)
| 36 | } |
| 37 | |
| 38 | fn ast_from_object( |
| 39 | vm: &VirtualMachine, |
| 40 | source_file: &SourceFile, |
| 41 | object: PyObjectRef, |
| 42 | ) -> PyResult<Self> { |
| 43 | let cls = object.class(); |
| 44 | Ok(if cls.is(pyast::NodeModModule::static_type()) { |
| 45 | Self::Module(ast::ModModule::ast_from_object(vm, source_file, object)?) |
| 46 | } else if cls.is(pyast::NodeModInteractive::static_type()) { |
| 47 | Self::Interactive(ModInteractive::ast_from_object(vm, source_file, object)?) |
| 48 | } else if cls.is(pyast::NodeModExpression::static_type()) { |
| 49 | Self::Expression(ast::ModExpression::ast_from_object( |
| 50 | vm, |
| 51 | source_file, |
| 52 | object, |
| 53 | )?) |
| 54 | } else if cls.is(pyast::NodeModFunctionType::static_type()) { |
| 55 | Self::FunctionType(ModFunctionType::ast_from_object(vm, source_file, object)?) |
| 56 | } else { |
| 57 | return Err(vm.new_type_error(format!( |
| 58 | "expected some sort of mod, but got {}", |
| 59 | object.repr(vm)? |
| 60 | ))); |
| 61 | }) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // constructor |
nothing calls this directly
no test coverage detected