+++ /dev/null
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !go1.4
-
-package constant
-
-import (
- "math"
- "math/big"
-)
-
-func ratToFloat32(x *big.Rat) (float32, bool) {
- // Before 1.4, there's no Rat.Float32.
- // Emulate it, albeit at the cost of
- // imprecision in corner cases.
- x64, exact := x.Float64()
- x32 := float32(x64)
- if math.IsInf(float64(x32), 0) {
- exact = false
- }
- return x32, exact
-}
+++ /dev/null
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build go1.4
-
-package constant
-
-import "math/big"
-
-func ratToFloat32(x *big.Rat) (float32, bool) {
- return x.Float32()
-}
f := float32(x)
return f, int64Val(f) == x
case intVal:
- return ratToFloat32(new(big.Rat).SetFrac(x.val, int1))
+ return new(big.Rat).SetFrac(x.val, int1).Float32()
case floatVal:
- return ratToFloat32(x.val)
+ return x.val.Float32()
case unknownVal:
return 0, false
}
switch typ := x.typ.Underlying().(type) {
case *Basic:
if isString(typ) {
- if slice3(e) {
+ if e.Slice3 {
check.invalidOp(x.pos(), "3-index slice of string")
goto Error
}
x.mode = value
// spec: "Only the first index may be omitted; it defaults to 0."
- if slice3(e) && (e.High == nil || sliceMax(e) == nil) {
+ if e.Slice3 && (e.High == nil || e.Max == nil) {
check.error(e.Rbrack, "2nd and 3rd index required in 3-index slice")
goto Error
}
// check indices
var ind [3]int64
- for i, expr := range []ast.Expr{e.Low, e.High, sliceMax(e)} {
+ for i, expr := range []ast.Expr{e.Low, e.High, e.Max} {
x := int64(-1)
switch {
case expr != nil:
+++ /dev/null
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !go1.2
-
-package types
-
-import "go/ast"
-
-func slice3(x *ast.SliceExpr) bool {
- return false
-}
-
-func sliceMax(x *ast.SliceExpr) ast.Expr {
- return nil
-}
+++ /dev/null
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build go1.2
-
-package types
-
-import "go/ast"
-
-func slice3(x *ast.SliceExpr) bool {
- return x.Slice3
-}
-
-func sliceMax(x *ast.SliceExpr) ast.Expr {
- return x.Max
-}