public static EcmaValue GetIntrinsicPrimitiveValue(this EcmaValue thisValue, EcmaValueType type) { if (thisValue.Type == type) { return(thisValue); } if (thisValue.Type == EcmaValueType.Object) { if (thisValue.GetUnderlyingObjectInternal() is PrimitiveObject obj && obj.PrimitiveValue.Type == type) { return(obj.PrimitiveValue); } } throw new EcmaTypeErrorException(InternalString.Error.IncompatibleObject); }
private EcmaValue(EcmaValueType type, object value) { this.type = type; this.value = value; }