"strconv"
)
-
// TODO(gri) Consider changing the API so Const is an interface
// and operations on consts don't have to type switch.
val interface{}
}
-
// Representation of complex values.
type cmplx struct {
re, im *big.Rat
}
-
func assert(cond bool) {
if !cond {
panic("go/types internal error: assertion failed")
}
}
-
// MakeConst makes an ideal constant from a literal
// token and the corresponding literal string.
func MakeConst(tok token.Token, lit string) Const {
panic("unreachable")
}
-
// MakeZero returns the zero constant for the given type.
func MakeZero(typ *Type) Const {
// TODO(gri) fix this
return Const{0}
}
-
// Match attempts to match the internal constant representations of x and y.
// If the attempt is successful, the result is the values of x and y,
// if necessary converted to have the same internal representation; otherwise
return
}
-
// Convert attempts to convert the constant x to a given type.
// If the attempt is successful, the result is the new constant;
// otherwise the result is invalid.
return x
}
-
func (x Const) String() string {
switch x := x.val.(type) {
case bool:
panic("unreachable")
}
-
func (x Const) UnaryOp(op token.Token) Const {
panic("unimplemented")
}
-
func (x Const) BinaryOp(op token.Token, y Const) Const {
var z interface{}
switch x := x.val.(type) {
return Const{z}
}
-
func binaryBoolOp(x bool, op token.Token, y bool) interface{} {
switch op {
case token.EQL:
panic("unreachable")
}
-
func binaryIntOp(x *big.Int, op token.Token, y *big.Int) interface{} {
var z big.Int
switch op {
panic("unreachable")
}
-
func binaryFloatOp(x *big.Rat, op token.Token, y *big.Rat) interface{} {
var z big.Rat
switch op {
panic("unreachable")
}
-
func binaryCmplxOp(x cmplx, op token.Token, y cmplx) interface{} {
a, b := x.re, x.im
c, d := y.re, y.im
panic("unreachable")
}
-
func binaryStringOp(x string, op token.Token, y string) interface{} {
switch op {
case token.ADD: