Commit Graph

503 Commits

Author SHA1 Message Date
Ayke van Laethem 980dceb192 main: refactor build option passing
The list of options passed to build/run/gdb/etc commands was getting
unwieldly and hard to add extra options to. Put all common build options
in a single build config struct so that these options are more
centralized.
2018-10-24 23:53:44 +02:00
Ayke van Laethem fcd44c02cd compiler: fix const complex numbers
This led to an assertion failure with a debug build of LLVM, but
apparently worked with a release build of LLVM.
2018-10-24 23:24:11 +02:00
Ayke van Laethem cb0a148cd7 compiler: fix map optimization
Not all uses of a map are call instructions. Don't assume they are.
TODO: investigate these uses and see whether they might be eliminated?
2018-10-24 12:37:47 +02:00
Ayke van Laethem 0b8beb77c1 reflect: add stub reflect package
This is necessary to compile fmt. However, it cannot link yet.
2018-10-23 15:39:53 +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 96f74ec153 compiler: support 64-bit numbers in bounds check 2018-10-23 14:07:27 +02:00
Ayke van Laethem 17e8c850f6 compiler: fix invalid use of extractvalue on vector types 2018-10-23 14:05:55 +02:00
Ayke van Laethem 893c115f31 travis: remove WebAssembly test
It fails (hangs) roughly half of the time and I don't know why. Perhaps
a problem in the linker?

Remove it now for green checkmarks.
2018-10-23 13:29:24 +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 9393cdd5ed README: add WebAssembly as a supported target 2018-10-22 12:40:06 +02:00
Ayke van Laethem c88d2d10a7 docs: give a working Docker example 2018-10-21 22:42:38 +02:00
Ayke van Laethem 58ce5d9bf2 docs: add WebAssembly to targets and improve formatting 2018-10-21 20:22:21 +02:00
Ayke van Laethem e5e09747f0 all: add WebAssembly backend 2018-10-21 19:47:47 +02:00
Johan Brandhorst a51e04c550 Dockerfile: include necessary build subfolders
When building, tinygo needs access to files relative to
the directory it was built from. Include src and targets
directories.
2018-10-21 17:52:12 +01:00
Johan Brandhorst f1b3ec4be8 Dockerfile: add vendor step
The Dockerfile was missing the part where we download
the dependencies into the vendor folder. It was of course
working locally because I had a vendor folder already.
2018-10-21 16:21:04 +01:00
Ayke van Laethem dda9c1cc6e ir: fix interface call edge case
A function on a type that is put in an interface must not be assumed to
not need a context pointer when it isn't directly put in a function
pointer, because the interface call side won't know this and pass an
extra parameter with that extra function pointer.

This is usually not a problem but WebAssembly has strict checks on
function signatures so this resulted in an error when running
src/examples/test/test.go.
2018-10-21 01:33:40 +02:00
Johan Brandhorst 97caabb8c2 Add Dockerfile 2018-10-21 00:28:18 +01:00
Johan Brandhorst 3d644e6ea8 Add dep files 2018-10-20 23:29:32 +01:00
Ayke van Laethem ad06ed46cd runtime: fix linker error: os.sigpipe 2018-10-20 18:37:58 +02:00
Ayke van Laethem 0a06c6014d compiler: special slice bounds check for 64-bit numbers
It is allowed to index with an int64 even on a 32-bit platform, so we
have to handle that case. But make sure the normal case isn't penalized
by using 32-bit numbers when possible.
2018-10-20 18:28:00 +02:00
Ayke van Laethem 239504d9f4 compiler: implement recover()
Doesn't do anything useful yet as running deferred calls are not
executed during panic. Only implemented to get code to compile.
2018-10-20 18:00:12 +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 3f05490846 compiler: fix odd bounds check failure with impossible typeassert 2018-10-20 17:21:47 +02:00
Ayke van Laethem 77d6d6c417 compiler: allow structs in map keys 2018-10-20 17:21:13 +02:00
Ayke van Laethem c0c1ccb381 compiler, runtime: implement delete builtin 2018-10-20 16:18:55 +02:00
Ayke van Laethem 7f60dd79ee sync: implement dummy sync.Pool for fmt 2018-10-20 15:52:41 +02:00
Ayke van Laethem 19f7927515 compiler: compare booleans
Implement == and != for booleans.
2018-10-20 15:47:59 +02:00
Ayke van Laethem 6a95b84cd8 compiler: support all operations on untyped strings
Operations on strings were not always also supported on untyped strings.
Make sure all of those operations are supported for both.
2018-10-20 15:47:02 +02:00
Ayke van Laethem 22bc0f979d README: scope 2018-10-20 15:20:11 +02:00
Ayke van Laethem c4557176ef README: contributing 2018-10-20 14:50:44 +02:00
Ayke van Laethem 55a60acbf4 README: improve documentation references 2018-10-20 14:35:04 +02:00
Ayke van Laethem 3babdfdc00 compiler: fix runtime.mainWrapper linkage and debug info 2018-10-19 17:39:41 +02:00
Ayke van Laethem 963ba16d7b compiler: add support for the append builtin 2018-10-19 14:40:19 +02:00
Ayke van Laethem b81aecf753 docs: add "Supported targets" page 2018-10-18 15:35:50 +02:00
Ayke van Laethem fd45410c24 runtime: add proper arm arch 2018-10-18 15:23:52 +02:00
Ayke van Laethem daf92226d8 nrf: add nrf52840-mdk board
With the help of Chillance on GitHub.
2018-10-18 15:07:06 +02:00
Ayke van Laethem f9edf7cc5c test: add slice tests 2018-10-18 15:02:53 +02:00
Ayke van Laethem 72390c21cb docs: add FAQ 2018-10-17 17:55:11 +02:00
Ayke van Laethem a613d0484e runtime: add support for time.Now()
TODO: On unix systems, this does not return an accurate value.
2018-10-15 20:20:37 +02:00
Ayke van Laethem ccee42ec7a machine: add helpers for bit-banged driver support
The returned pointer and value can be used to set or clear a specific
pin.
2018-10-15 19:56:27 +02:00
Ayke van Laethem 392bba8394 compiler: add support for parameters to inline assembly 2018-10-15 19:37:09 +02:00
Ayke van Laethem 52199f4a14 compiler: eliminate created but never used maps 2018-10-12 17:00:39 +02:00
Ayke van Laethem 25e73a5439 compiler: align and zero-initialize stack allocated values 2018-10-12 16:57:17 +02:00
Ayke van Laethem 2917347ff5 compiler: implement operations on some named types 2018-10-12 16:53:55 +02:00
Ayke van Laethem 9406a4d74a main: add -opt= flag for the optimization level 2018-10-10 14:14:45 +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