(hint Value)
| 873 | } |
| 874 | |
| 875 | func (o *Object) tryExoticToPrimitive(hint Value) Value { |
| 876 | exoticToPrimitive := toMethod(o.self.getSym(SymToPrimitive, nil)) |
| 877 | if exoticToPrimitive != nil { |
| 878 | ret := exoticToPrimitive(FunctionCall{ |
| 879 | This: o, |
| 880 | Arguments: []Value{hint}, |
| 881 | }) |
| 882 | if _, fail := ret.(*Object); !fail { |
| 883 | return ret |
| 884 | } |
| 885 | panic(o.runtime.NewTypeError("Cannot convert object to primitive value")) |
| 886 | } |
| 887 | return nil |
| 888 | } |
| 889 | |
| 890 | func (o *Object) toPrimitiveNumber() Value { |
| 891 | if v := o.tryExoticToPrimitive(hintNumber); v != nil { |
no test coverage detected