| 56 | |
| 57 | impl From<ConstantData> for StackValue { |
| 58 | fn from(value: ConstantData) -> Self { |
| 59 | match value { |
| 60 | ConstantData::Str { value } => { |
| 61 | StackValue::String(value.into_string().expect("surrogate in test code")) |
| 62 | } |
| 63 | ConstantData::None => StackValue::None, |
| 64 | ConstantData::Code { code } => StackValue::Code(code), |
| 65 | ConstantData::Slice { elements } => { |
| 66 | let [start, stop, step] = *elements; |
| 67 | StackValue::Slice(Box::new([start.into(), stop.into(), step.into()])) |
| 68 | } |
| 69 | ConstantData::Frozenset { elements } => { |
| 70 | StackValue::Frozenset(elements.into_iter().map(Into::into).collect()) |
| 71 | } |
| 72 | c => unimplemented!("constant {:?} isn't yet supported in py_function!", c), |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /// Extract annotations from an annotate function's bytecode. |