(self, vm: &VirtualMachine, source_file: &SourceFile)
| 99 | // constructor |
| 100 | impl Node for Constant { |
| 101 | fn ast_to_object(self, vm: &VirtualMachine, source_file: &SourceFile) -> PyObjectRef { |
| 102 | let Self { range, value } = self; |
| 103 | let node = NodeAst |
| 104 | .into_ref_with_type(vm, pyast::NodeExprConstant::static_type().to_owned()) |
| 105 | .unwrap(); |
| 106 | let kind = match &value { |
| 107 | ConstantLiteral::Str { |
| 108 | prefix: StringLiteralPrefix::Unicode, |
| 109 | .. |
| 110 | } => vm.ctx.new_str("u").into(), |
| 111 | _ => vm.ctx.none(), |
| 112 | }; |
| 113 | let value = value.ast_to_object(vm, source_file); |
| 114 | let dict = node.as_object().dict().unwrap(); |
| 115 | dict.set_item("value", value, vm).unwrap(); |
| 116 | dict.set_item("kind", kind, vm).unwrap(); |
| 117 | node_add_location(&dict, range, vm, source_file); |
| 118 | node.into() |
| 119 | } |
| 120 | |
| 121 | fn ast_from_object( |
| 122 | vm: &VirtualMachine, |
no test coverage detected