operand: fix integer float data (#393)
Issue #387 pointed out that integer float data is printed incorrectly, such that it is not parsed correctly by the Go assembler. Specifically, integer values need the decimal point, otherwise they will be treated as integers. For example, 1 must be represented as `$(1.)` or `$(1.0)` to be parsed correctly. This PR fixes that problem and adds a regression test. The root of the problem was that the formatting verb `%#v` does not have the right behavior for integers. We fix it by deferring to custom `String()` function for the float operand types. Fixes #387 Closes #388
This commit is contained in:
committed by
GitHub
parent
9bef88dadc
commit
0d789c8353
@@ -38,7 +38,8 @@ func PrintConstTypes(w io.Writer) {
|
||||
bs := strconv.Itoa(bits)
|
||||
|
||||
if n >= 4 {
|
||||
PrintConstType(w, "F"+bs, "float"+bs, "(%#v)", n, fmt.Sprintf("F%d is a %d-bit floating point constant.", bits, bits))
|
||||
// Use string format verb to direct to our custom implementation.
|
||||
PrintConstType(w, "F"+bs, "float"+bs, "(%s)", n, fmt.Sprintf("F%d is a %d-bit floating point constant.", bits, bits))
|
||||
}
|
||||
PrintConstType(w, "I"+bs, "int"+bs, "%+d", n, fmt.Sprintf("I%d is a %d-bit signed integer constant.", bits, bits))
|
||||
PrintConstType(w, "U"+bs, "uint"+bs, "%#0"+strconv.Itoa(2*n)+"x", n, fmt.Sprintf("U%d is a %d-bit unsigned integer constant.", bits, bits))
|
||||
|
||||
Reference in New Issue
Block a user