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

382 коммитов

Автор SHA1 Сообщение Дата
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
c0c1ccb381
compiler, runtime: implement delete builtin 2018-10-20 16:18:55 +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
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
392bba8394
compiler: add support for parameters to inline assembly 2018-10-15 19:37:09 +02:00
Ayke van Laethem
2917347ff5
compiler: implement operations on some named types 2018-10-12 16:53:55 +02:00
Ayke van Laethem
e1e3dbdce6
compiler: correctly generate global hashmaps of size > 8
Static map generation used the last bucket instead of the first bucket
in the chain, which caused lots of missing entries in hashmaps with
multiple buckets (size > 8).
2018-10-10 14:06:59 +02:00
Ayke van Laethem
3289dd7134
compiler: use a fresh context for every compilation 2018-10-08 20:18:12 +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
482c5633dd
compiler: put debug information on package initializer functions
Make sure package initializers show up in backtraces, as they should. In
practice, it doesn't actually break backtraces as these functions are
usually inlined anyway, but it may help to debug an error in
initialization code.
2018-10-06 23:50:35 +02:00
Ayke van Laethem
5db43e8d04
compiler: move Optimize() function to a separate file
In the future, there will be more optimizations. Let's keep them in a
separate file for separation of concerns.
2018-10-06 19:57:41 +02:00
Ayke van Laethem
5d2ffa79e5
compiler: improve debug info to cover initialization 2018-10-03 19:24:29 +02:00
Ayke van Laethem
f107a24b72
all: use LLVM library provided by the system 2018-09-30 15:10:04 +02:00
Ayke van Laethem
b6db84e916
main: use GOPATH from the environment
Be more compatible with the Go toolchain by setting GOPATH in the same
way. This makes it possible to flash and run examples from the standard
GOPATH instead of only from the source tree.
2018-09-29 22:30:45 +02:00
Ayke van Laethem
8d170d3bd2
all: change special type __volatile to pragma //go:volatile
This is one step towards removing unnecessary special casts in most
cases. It is also part of removing as much magic as possible from the
compiler (the pragma is explicit, the special name is not).
2018-09-28 13:17:03 +02:00
Ayke van Laethem
13cb7d6503
avr: add interrupt support
Interrupts are supported using a special //go:interrupt pragma.
For example:

//go:interrupt INT0_vect
func handleINT0() {
    // do something here
}
2018-09-25 13:47:20 +02:00
Ayke van Laethem
ed227b8fd3
all: fix errors reported by go vet 2018-09-24 17:22:59 +02:00
Ayke van Laethem
c9ae72a105
all: allow -O0 optimization level 2018-09-24 16:17:42 +02:00
Ayke van Laethem
6191d4e1ac
compiler: rename .Parse() to .Compiler()
The fact it was called Parse() is more of a historical accident, as the
compiler started out using the Go AST directly instead of Go SSA.
2018-09-24 15:55:38 +02:00
Ayke van Laethem
1b229a8f8b
compiler: support compiling individual .go files
For example:

    tinygo run ./src/examples/test/test.go
2018-09-24 15:46:30 +02:00
Ayke van Laethem
a561e9a9ac
ir: move adding packages from the compiler 2018-09-24 15:46:30 +02:00
Ayke van Laethem
9df04a2170
compiler: fix panic on import errors
I think this is a problem in the loader package - it doesn't seem to
return errors for missing packages.
2018-09-24 15:46:30 +02:00
Ayke van Laethem
8a468786df
compiler: use config struct for options 2018-09-24 15:46:05 +02:00
Ayke van Laethem
fd6dda5e4f
main: run the compiler from any path 2018-09-24 12:25:33 +02:00
Ayke van Laethem
2938437efc
compiler: make string data unnamed addresses
This ensures LLVM can merge identical strings, and thus reduces code
size in some cases.
2018-09-23 03:03:40 +02:00
Ayke van Laethem
7cea40bcb5
compiler: small cleanup in call handling code 2018-09-23 03:01:10 +02:00
Ayke van Laethem
fdfa810060
compiler: expand small structs
Use fields of small structs (3 or less fields when flattened
recursively) directly as parameter values.

Advantages:
  * Code size is slightly reduced, both on unix and nrf.
  * AVR can finally deal with struct parameters - at least the small
    ones. examples/test now compiles. A real fix for struct parameters
    should go into upstream LLVM, but this is a nice win.

fixes #20
2018-09-23 02:39:05 +02:00
Ayke van Laethem
b2cbfa78ca
compiler: refactor compiler into separate package 2018-09-22 20:32:28 +02:00
Переименован с compiler.go (Смотреть далее)