aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/robertkrimen/otto/builtin_math.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-10-29 01:05:01 +0800
committerFelix Lange <fjl@twurst.com>2016-10-29 01:05:01 +0800
commit289b30715d097edafd5562f66cb3567a70b2d330 (patch)
tree7eaaa6da97c84727469303b986e364606ece57ce /vendor/github.com/robertkrimen/otto/builtin_math.go
parent77703045765343c489ded2f43e3ed0f332c5f148 (diff)
downloaddexon-289b30715d097edafd5562f66cb3567a70b2d330.tar
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.gz
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.bz2
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.lz
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.xz
dexon-289b30715d097edafd5562f66cb3567a70b2d330.tar.zst
dexon-289b30715d097edafd5562f66cb3567a70b2d330.zip
Godeps, vendor: convert dependency management to trash (#3198)
This commit converts the dependency management from Godeps to the vendor folder, also switching the tool from godep to trash. Since the upstream tool lacks a few features proposed via a few PRs, until those PRs are merged in (if), use github.com/karalabe/trash. You can update dependencies via trash --update. All dependencies have been updated to their latest version. Parts of the build system are reworked to drop old notions of Godeps and invocation of the go vet command so that it doesn't run against the vendor folder, as that will just blow up during vetting. The conversion drops OpenCL (and hence GPU mining support) from ethash and our codebase. The short reasoning is that there's noone to maintain and having opencl libs in our deps messes up builds as go install ./... tries to build them, failing with unsatisfied link errors for the C OpenCL deps. golang.org/x/net/context is not vendored in. We expect it to be fetched by the user (i.e. using go get). To keep ci.go builds reproducible the package is "vendored" in build/_vendor.
Diffstat (limited to 'vendor/github.com/robertkrimen/otto/builtin_math.go')
-rw-r--r--vendor/github.com/robertkrimen/otto/builtin_math.go151
1 files changed, 151 insertions, 0 deletions
diff --git a/vendor/github.com/robertkrimen/otto/builtin_math.go b/vendor/github.com/robertkrimen/otto/builtin_math.go
new file mode 100644
index 000000000..7ce90c339
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_math.go
@@ -0,0 +1,151 @@
+package otto
+
+import (
+ "math"
+ "math/rand"
+)
+
+// Math
+
+func builtinMath_abs(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Abs(number))
+}
+
+func builtinMath_acos(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Acos(number))
+}
+
+func builtinMath_asin(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Asin(number))
+}
+
+func builtinMath_atan(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Atan(number))
+}
+
+func builtinMath_atan2(call FunctionCall) Value {
+ y := call.Argument(0).float64()
+ if math.IsNaN(y) {
+ return NaNValue()
+ }
+ x := call.Argument(1).float64()
+ if math.IsNaN(x) {
+ return NaNValue()
+ }
+ return toValue_float64(math.Atan2(y, x))
+}
+
+func builtinMath_cos(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Cos(number))
+}
+
+func builtinMath_ceil(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Ceil(number))
+}
+
+func builtinMath_exp(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Exp(number))
+}
+
+func builtinMath_floor(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Floor(number))
+}
+
+func builtinMath_log(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Log(number))
+}
+
+func builtinMath_max(call FunctionCall) Value {
+ switch len(call.ArgumentList) {
+ case 0:
+ return negativeInfinityValue()
+ case 1:
+ return toValue_float64(call.ArgumentList[0].float64())
+ }
+ result := call.ArgumentList[0].float64()
+ if math.IsNaN(result) {
+ return NaNValue()
+ }
+ for _, value := range call.ArgumentList[1:] {
+ value := value.float64()
+ if math.IsNaN(value) {
+ return NaNValue()
+ }
+ result = math.Max(result, value)
+ }
+ return toValue_float64(result)
+}
+
+func builtinMath_min(call FunctionCall) Value {
+ switch len(call.ArgumentList) {
+ case 0:
+ return positiveInfinityValue()
+ case 1:
+ return toValue_float64(call.ArgumentList[0].float64())
+ }
+ result := call.ArgumentList[0].float64()
+ if math.IsNaN(result) {
+ return NaNValue()
+ }
+ for _, value := range call.ArgumentList[1:] {
+ value := value.float64()
+ if math.IsNaN(value) {
+ return NaNValue()
+ }
+ result = math.Min(result, value)
+ }
+ return toValue_float64(result)
+}
+
+func builtinMath_pow(call FunctionCall) Value {
+ // TODO Make sure this works according to the specification (15.8.2.13)
+ x := call.Argument(0).float64()
+ y := call.Argument(1).float64()
+ if math.Abs(x) == 1 && math.IsInf(y, 0) {
+ return NaNValue()
+ }
+ return toValue_float64(math.Pow(x, y))
+}
+
+func builtinMath_random(call FunctionCall) Value {
+ var v float64
+ if call.runtime.random != nil {
+ v = call.runtime.random()
+ } else {
+ v = rand.Float64()
+ }
+ return toValue_float64(v)
+}
+
+func builtinMath_round(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ value := math.Floor(number + 0.5)
+ if value == 0 {
+ value = math.Copysign(0, number)
+ }
+ return toValue_float64(value)
+}
+
+func builtinMath_sin(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Sin(number))
+}
+
+func builtinMath_sqrt(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Sqrt(number))
+}
+
+func builtinMath_tan(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Tan(number))
+}