Permalink
Browse files

compiler/natives/src/math: Implement {Cos,Sin,Tan}h.

These were implemented in pure Go before. In Go 1.8, they're now using
stubs and are implemented in assembly. This causes the following errors
in GopherJS:

	Error: runtime error: native function not implemented: math.Cosh
	Error: runtime error: native function not implemented: math.Sinh
	Error: runtime error: native function not implemented: math.Tanh

Implement them via JavaScript math object, analogous to Cos, Sin, Tan.
  • Loading branch information...
1 parent e3c80b5 commit b10af792dea750a97821bc2f3bf4d7034f797ae9 @shurcooL shurcooL committed Dec 13, 2016
Showing with 12 additions and 0 deletions.
  1. +12 −0 compiler/natives/src/math/math.go
@@ -43,6 +43,10 @@ func Cos(x float64) float64 {
return math.Call("cos", x).Float()
}
+func Cosh(x float64) float64 {
+ return math.Call("cosh", x).Float()
+}
+
func Dim(x, y float64) float64 {
return dim(x, y)
}
@@ -172,6 +176,10 @@ func Sin(x float64) float64 {
return math.Call("sin", x).Float()
}
+func Sinh(x float64) float64 {
+ return math.Call("sinh", x).Float()
+}
+
func Sincos(x float64) (sin, cos float64) {
return Sin(x), Cos(x)
}
@@ -184,6 +192,10 @@ func Tan(x float64) float64 {
return math.Call("tan", x).Float()
}
+func Tanh(x float64) float64 {
+ return math.Call("tanh", x).Float()
+}
+
func Trunc(x float64) float64 {
if x == posInf || x == negInf || x != x || 1/x == negInf {
return x

0 comments on commit b10af79

Please sign in to comment.