use super::VaryingOperand;
use crate::{Context, JsResult, vm::opcode::Operation};
#[derive(Debug, Clone, Copy)]
pub(crate) struct ToPropertyKey;
impl ToPropertyKey {
#[inline(always)]
pub(super) fn operation(
(value, dst): (VaryingOperand, VaryingOperand),
context: &mut Context,
) -> JsResult<()> {
let value = context.vm.get_register(value.into()).clone();
let key = value.to_property_key(context)?;
context.vm.set_register(dst.into(), key.into());
Ok(())
}
}
impl Operation for ToPropertyKey {
const NAME: &'static str = "ToPropertyKey";
const INSTRUCTION: &'static str = "INST - ToPropertyKey";
const COST: u8 = 2;
}