diff options
author | Ayke van Laethem <[email protected]> | 2019-05-04 22:16:45 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-05-11 15:33:37 +0200 |
commit | 638bc17eeb940d602e7d7602bbc9d783f2ca948f (patch) | |
tree | 54500ba48ed754be069616bf86af226568d3e8ee /testdata | |
parent | 1113f9ec0c4c781aa9a97e706ed289dc1df13614 (diff) | |
download | tinygo-638bc17eeb940d602e7d7602bbc9d783f2ca948f.tar.gz tinygo-638bc17eeb940d602e7d7602bbc9d783f2ca948f.zip |
compiler: add support for complex add and sub
This is fairly trivial to add and follows the implementation of gc:
https://github.com/golang/go/blob/170b8b4b12be50eeccbcdadb8523fb4fc670ca72/src/cmd/compile/internal/gc/ssa.go#L2179-L2192
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/float.go | 8 | ||||
-rw-r--r-- | testdata/float.txt | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/testdata/float.go b/testdata/float.go index 6e2d5bf71..91223023b 100644 --- a/testdata/float.go +++ b/testdata/float.go @@ -56,4 +56,12 @@ func main() { // cast complex println(complex64(c128)) println(complex128(c64)) + + // binops on complex numbers + c64 = 5+2i + println("complex64 add: ", c64 + -3+8i) + println("complex64 sub: ", c64 - -3+8i) + c128 = -5+2i + println("complex128 add:", c128 + 2+6i) + println("complex128 sub:", c128 - 2+6i) } diff --git a/testdata/float.txt b/testdata/float.txt index e20f0e52a..cd75cd21b 100644 --- a/testdata/float.txt +++ b/testdata/float.txt @@ -23,3 +23,7 @@ (+2.000000e+000-2.000000e+000i) (+6.666667e-001-2.000000e+000i) (+6.666667e-001+1.200000e+000i) +complex64 add: (+2.000000e+000+1.000000e+001i) +complex64 sub: (+8.000000e+000+1.000000e+001i) +complex128 add: (-3.000000e+000+8.000000e+000i) +complex128 sub: (-7.000000e+000+8.000000e+000i) |