expressions working

Signed-off-by: Casey Lee <[email protected]>
This commit is contained in:
Casey Lee committed 2020-02-20 21:05:55 -05:00
1 parent 409060c847
commit e40ab0145f
114 files changed
+32361

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
package otto
func toStringPrimitive(value Value) Value {
return _toPrimitive(value, defaultValueHintString)
}
func toNumberPrimitive(value Value) Value {
return _toPrimitive(value, defaultValueHintNumber)
}
func toPrimitive(value Value) Value {
return _toPrimitive(value, defaultValueNoHint)
}
func _toPrimitive(value Value, hint _defaultValueHint) Value {
switch value.kind {
case valueNull, valueUndefined, valueNumber, valueString, valueBoolean:
return value
case valueObject:
return value._object().DefaultValue(hint)
}
panic(hereBeDragons(value.kind, value))
}