Граф коммитов

274 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
a531caa2e9
compiler: implement deferring of interface calls 2018-11-03 20:21:43 +01:00
Ayke van Laethem
e66d457c42
compiler: fix float <-> int conversions 2018-11-03 12:20:55 +01:00
Ayke van Laethem
1b283c11c1
ir: do not throw an error on unknown conversions 2018-10-31 10:19:25 +01:00
Ayke van Laethem
436901dc49
compiler: implement operations on nil hashmaps
* comparing a map against nil
  * getting the length of a nil map
2018-10-27 00:57:37 +02:00
Marc-Antoine Ruel
7f30ef7e4d
testdata: add more test cases in testdata
Specifically test for one or multiple init functions.
2018-10-25 20:37:35 +02:00
Ayke van Laethem
6c6a43310a
compiler: fix invalid incoming block in complex typeassert flow
A single *ssa.BasicBlock may be split in multiple LLVM basic blocks due
to typeassert instructions. This means the incoming block and outgoing
block are different. PHI nodes need to get the result from the outgoing
block, which was fixed before, but incoming branches need to branch to
the incoming block, not the outgoing block.

Branching to the outgoing block led to a LLVM verification error when
compiling the fmt package.

Originally found in (*fmt.pp).handleMethods.
2018-10-23 15:00:37 +02:00
Ayke van Laethem
e2f6aedd9d
compiler: implement comparing structs directly 2018-10-23 13:27:18 +02:00
Ayke van Laethem
cbd7d401fe
testdata: go fmt 2018-10-23 13:24:18 +02:00
Ayke van Laethem
82be43f4e6
compiler: implement deferring of immediately-applied closures
This is a common operation:

    freevar := ...
    defer func() {
        println("I am deferred:", freevar)
    }()

The function is thus an immediately applied closure. Only this form is
currently supported, support for regular (fat) function pointers should
be trivial to add but is not currently implemented as it wasn't
necessary to get fmt to compile.
2018-10-22 14:06:51 +02:00
Ayke van Laethem
9b9b66a09d
compiler: add complex manipulation
* builtins: real, imag, complex
* printing of complex numbers

No support for complex arithmetic yet.
2018-10-22 13:49:03 +02:00
Ayke van Laethem
7c2a6169b0
compiler: support comma-ok in map lookup 2018-10-20 17:54:16 +02:00
Ayke van Laethem
da89464a63
compiler: compare slice against nil 2018-10-20 17:22:51 +02:00
Ayke van Laethem
c0c1ccb381
compiler, runtime: implement delete builtin 2018-10-20 16:18:55 +02:00
Ayke van Laethem
963ba16d7b
compiler: add support for the append builtin 2018-10-19 14:40:19 +02:00
Ayke van Laethem
f9edf7cc5c
test: add slice tests 2018-10-18 15:02:53 +02:00
Ayke van Laethem
0ed00bf6c6
test: add hashmap tests
Hashmaps are still very primitive. These tests check that there are at
least no regressions in hashmap support.
2018-10-10 14:11:15 +02:00
Ayke van Laethem
73709922b2
main: extra interface test for simple named types 2018-10-07 19:40:21 +02:00
Ayke van Laethem
e8f211935e
compiler: fix expanded structs in invoke calls 2018-10-07 13:19:38 +02:00
Ayke van Laethem
4957db89f4
compiler: fix interface calls for big underlying values
When the underlying value of an interface does not fit in a pointer, a
pointer to the value was correctly inserted in the heap. However, the
receiving method still assumed it got the underlying value instead of a
pointer to it leading to a crash.

This commit inserts wrapper functions for method calls on interfaces.

The bug wasn't obvious as on a 64-bit system, the underlying value was
almost always put directly in the interface. However, it led to a crash
on the AVR platform where pointer are (usually) just 16 bits making it
far more likely that underlying values cannot be directly stored in an
interface.
2018-10-07 02:06:48 +02:00
Ayke van Laethem
c1a833c7cc
main: add basic float tests 2018-09-29 00:12:23 +02:00
Ayke van Laethem
717262c0a6
main: add coroutine/sleep tests 2018-09-29 00:11:58 +02:00
Ayke van Laethem
4731f2f787
testdata: add better tests for struct expanding 2018-09-25 14:24:44 +02:00
Ayke van Laethem
174b6333f8
compiler: fix expanding zero-length structs 2018-09-25 13:45:04 +02:00
Ayke van Laethem
d8f0ddf3fa
main: add tests
Add testing infrastructure and one initial test (for
src/runtime/print.go). More tests to be added later.
2018-09-24 17:24:58 +02:00