// overflow checks that the constant x is representable by its type. // For untyped constants, it checks that the value doesn't become // arbitrarily large. func (check *Checker) overflow(x *operand, opPos syntax.Pos) { … } // representableConst reports whether x can be represented as // value of the given basic type and for the configuration // provided (only needed for int/uint sizes). // // If rounded != nil, *rounded is set to the rounded value of x for // representable floating-point and complex values, and to an Int // value for integer values; it is left alone otherwise. // It is ok to provide the addressof the first argument for rounded. // // The check parameter may be nil if representableConst is invoked // (indirectly) through an exported API call (AssignableTo, ConvertibleTo) // because we don't need the Checker's config for those calls. func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *constant.Value) bool { … } func fitsFloat32(x constant.Value) bool { … } func roundFloat32(x constant.Value) constant.Value { … } func fitsFloat64(x constant.Value) bool { … } func roundFloat64(x constant.Value) constant.Value { … } // representable checks that a constant operand is representable in the given // basic type. func (check *Checker) representable(x *operand, typ *Basic) { … } // representation returns the representation of the constant operand x as the // basic type typ. // // If no such representation is possible, it returns a non-zero error code. func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, Code) { … } func (check *Checker) invalidConversion(code Code, x *operand, target Type) { … } // convertUntyped attempts to set the type of an untyped value to the target type. func (check *Checker) convertUntyped(x *operand, target Type) { … }