Skip to content

Commit 844fcc3

Browse files
committed
Merge branch 'release/0.41.0'
2 parents d49d1c3 + 5d12eee commit 844fcc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+593
-502
lines changed

.semaphore/semaphore.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@ agent:
55
type: e1-standard-2
66
os_image: ubuntu1804
77
blocks:
8-
- name: "main"
8+
- name: "linux-build"
99
task:
10+
agent:
11+
machine:
12+
type: e1-standard-2
13+
os_image: ubuntu1804
1014
jobs:
11-
- name: main
15+
- name: build
1216
commands:
1317
- checkout
14-
- echo "LLVM 7"
1518
- sudo echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee -a /etc/apt/sources.list
1619
- sudo echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee -a /etc/apt/sources.list
1720
- sudo wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
1821
- sudo apt -y update
1922
- sudo apt-get -o Dpkg::Options::="--force-overwrite" --allow-unauthenticated -y install -y llvm-7 llvm-7-dev libllvm7 libmpfr-dev libmpfr6
2023
- CXX=g++-8 CC=gcc-8 LLVM_CONFIG=llvm-config-7 make -j2 test
24+
- name: "macos-build"
25+
task:
26+
agent:
27+
machine:
28+
type: a1-standard-4
29+
os_image: macos-mojave
30+
jobs:
31+
- name: build
32+
commands:
33+
- checkout
34+
- HOMEBREW_NO_INSTALL_CLEANUP=1 brew install llvm@7 mpfr libffi
35+
- PATH="/usr/local/opt/llvm@7/bin:$PATH" LLVM_CONFIG=llvm-config make -j4 tester

.travis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ matrix:
99
- os: osx
1010
osx_image: xcode9.4
1111

12+
cache:
13+
directories:
14+
- $HOME/Library/Caches/Homebrew
15+
16+
before_cache:
17+
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew cleanup; fi
18+
1219
addons:
1320
apt:
1421
sources:
@@ -30,8 +37,8 @@ addons:
3037

3138
script:
3239
- if [ "$TRAVIS_OS_NAME" == "osx" ];
33-
then PATH="/usr/local/opt/llvm@7/bin:$PATH" LLVM_CONFIG=llvm-config make tester;
34-
else CXX=g++-$GCC_VERSION CC=gcc-$GCC_VERSION LLVM_CONFIG=llvm-config-7 make ci;
40+
then PATH="/usr/local/opt/llvm@7/bin:$PATH" LLVM_CONFIG=llvm-config make -j2 tester;
41+
else CXX=g++-$GCC_VERSION CC=gcc-$GCC_VERSION LLVM_CONFIG=llvm-config-7 make -j2 ci;
3542
fi
3643

3744
notifications:

README.md

Lines changed: 19 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [Flax](https://flax-lang.github.io)
22

3-
A low level language with high level syntax and expressibility.
3+
A low level, general-purpose language with high level syntax and expressibility.
44

55

66
[![forthebadge](https://forthebadge.com/images/badges/made-with-crayons.svg)](http://forthebadge.com)
@@ -17,13 +17,10 @@ A low level language with high level syntax and expressibility.
1717
-----------------------------------------------
1818

1919

20-
<p align="center">
20+
<!-- <p align="center">
2121
<img src="https://raw.githubusercontent.com/flax-lang/flax/develop/build/d20.gif" />
2222
</p>
23-
24-
25-
26-
-----------------------------------------------
23+
----------------------------------------------- -->
2724

2825
#### Disclaimer ####
2926

@@ -49,12 +46,13 @@ I'm no famous artist but this is my magnum opus, so it'll not be abandoned anyti
4946
- Operator overloading
5047
- Generic functions and types
5148
- Type inference (including for generics)
49+
- Full compile-time execution (of arbitrary code)
5250

5351
-----------------------------------------------
5452

5553

5654
### Language Syntax
57-
- See https://flax-lang.github.io (incomplete)
55+
- See https://flax-lang.github.io (incomplete, outdated, obsolete, etc. etc.)
5856

5957
-----------------------------------------------
6058

@@ -96,36 +94,33 @@ do {
9694
### Building the Flax compiler
9795

9896
#### Dependencies ####
99-
- LLVM 7, mostly due to their obsession with changing the IR interface every damn version (6 does not work, 8 does not work)
97+
- LLVM 7, mostly due to their obsession with changing the IR interface every damn version
10098
- GMP/MPIR
10199
- MPFR
100+
- libffi
102101

103102

104103
#### macOS / Linux
105104

106-
- Flax uses a makefile; most likely some form of GNU-compatible `make` will work.
107-
- LLVM needs to be installed. On macOS, `brew install llvm@7` should work. (note: llvm 8 and up seems to have changed some JIT-related things)
108-
- For macOS people, simply call `make`.
109-
- Linux people, call `make linux`.
105+
- The `makefile` is the preferred way to build on UNIX systems.
106+
- LLVM needs to be installed. On macOS, `brew install llvm@7` should work, and you might need to do some PPA fiddling for Debian-based distros.
110107
- A *C++17*-compatible compiler should be used.
111108
- Find the `flaxc` executable in `build/sysroot/usr/local/bin`
112109
- Additionally, the (admittedly limited) standard library will be copied from `./libs` to `./build/sysroot/usr/local/lib/flaxlibs/`
113110

114111

115112
#### Windows
116113

117-
##### Option 1
118-
- Install [meson](https://mesonbuild.com/)
119-
- Edit `meson.build` variables to tell it where to find the libraries -- notably, these are needed: [`libmpir`](http://mpir.org), [`libmpfr`](http://mpfr.org), and most importantly, [`libllvm`](http://llvm.org). Follow the build instructions for each library, preferably generating both Debug and Release *static* libraries.
120-
- Run `meson build\meson-dbg` (where ever you want, really), followed by `ninja -C build\meson-dbg`.
121-
- `flaxc.exe` will be in `build\meson-dbg`.
122-
- Build and profit, hopefully.
114+
- Install [meson](https://mesonbuild.com/).
115+
- Run `env MPIR_ROOT_DIR=... LLVM_ROOT_DIR=... meson meson-build-dir` to set the locations for the dependencies (see `meson.build` for the names, there are 4) and configure the build.
116+
- Optionally, pass `--buildtype=release` to build a release-mode compiler (highly recommended)
117+
- Run `ninja -C meson-build-dir`.
118+
- `flaxc.exe` will be found in the build directory.
119+
120+
##### Libraries
121+
- Download the [prebuilt binaries](https://github.com/flax-lang/flax/releases/tag/win-build-deps) for the 4 dependencies, and place them somewhere.
122+
- Note: the folder structure of the libraries should be `(llvm|mpir|mpfr|libffi)/(Release|Debug)/(include|lib)/...`
123123

124-
##### Option 2
125-
- Download the [prebuilt binaries](https://github.com/flax-lang/flax/releases/download/win-build-deps/libraries.zip) for LLVM, MPIR, and MPFR.
126-
- Set the following environment variables: `DEPS_DBG_INCLUDES_DIR`, `DEPS_DBG_LIBS_DIR`, `DEPS_REL_INCLUDES_DIR`, and `DEPS_REL_LIBS_DIR`. Point them to the location of the libraries you just downloaded. (Look in `appveyor.yml` to see what they should contain -- essentially the include and library paths for `msbuild` to find)
127-
- Note: the folder structure of the libraries should be `(llvm|mpir|mpfr)/Release/(include|lib)/...`
128-
- Run `msbuild /p:Configuration=Release`
129124

130125
-----------------------------------------------
131126

@@ -142,55 +137,7 @@ do {
142137

143138
### Contributing
144139

145-
- Found a bug? Want a feature? Just submit a pull request!
146-
147-
148-
-----------------------------------------------
149-
150-
151-
### Compiler Architecture
152-
153-
Some stuff about the compiler itself, now. As any noob looking to build a compiler would do, I used the [LLVM Kaleidoscope tutorial](http://llvm.org/docs/tutorial/) as a starting point. Naturally, it being a tutorial did no favours for the code cleanliness and organisation of the Flax compiler.
154-
155-
Flax itself has 4 main passes -- Lexing, Parsing, Typechecking, and finally Codegen. Yes that's right, the shitty typecheck-and-codegen-at-the-same-time architecture of old has been completely replaced!
156-
157-
158-
#### Tokenising and Lexing
159-
160-
This isn't terribly complicated. Each file is naturally only looked at once, and a list of tokens and raw lines are stored somewhere. There's always a nagging feeling that token location reporting is flawed, and it probably is.
161-
162-
EDIT: It is.
163-
164-
165-
#### Parsing
166-
167-
Broadly speaking this is a recursive descent parser, handwritten. Not terribly efficient, but whatever. This step creates the AST nodes for the next step, although there are some hacks to enable custom operators, which should probably be reimplemented sometime soon.
168-
169-
170-
171-
#### Typechecking
172-
173-
At this stage, each AST node that the parser produced is traversed, at the file-level. AST nodes are transformed through a typechecking phase into SST nodes (the original meaning of this initialism has been lost). This typechecking consists of solidifying `pts::Type`s into `fir::Type`s; given that the former is simply a stripped-down version of the latter, this is natural.
174-
175-
SST nodes are just AST nodes with refinements; identifiers are resolved to their targets, and function calls also find their intended target here.
176-
177-
Before the rewrite, this used to happen in an intertwined fashion with code generation, which definitely wasn't pretty.
178-
179-
180-
181-
#### Code Generation
182-
183-
After each file is typechecked, the collector forcibly squishes them together into a single unit, combining the necessary definitions from other files that were imported -- code generation happens at the program level.
184-
185-
During code generation, we output 'Flax Intermediate Representation', or 'FIR'. It's basically a layer on top of LLVM that preserves much of its interface, with some light abstractions built on top. This is where AST nodes actually get transformed into instructions.
186-
187-
Part of the purpose for FIR was to decouple from LLVM, and partly to allow compile-time execution in the future, which would definitely be easier with our own IR (mainly to send and retrieve values across the compiler <> IR boundary).
188-
189-
190-
191-
#### Translation
192-
193-
After a `fir::Module` is produced by the code generator, we 'translate' this into LLVM code. The entire process can be seen in `source/backend/llvm/translator.cpp`, and clearly we basically cloned the LLVM interface here, which makes it easy to translate into LLVM.
140+
- Any and all issues and pull requests are welcome!
194141

195142

196143

build/supertiny.flx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,22 @@ import std::map
109109

110110

111111
/*
112-
! bugs !
112+
! important stuff to fix !
113113
{
114114
2. splatting tuples into a generic function *will not work*
115115
3. pass the overall location to the polymorph solver.
116+
117+
4. how does named-argument calling interact with varaidic arguments/functions? also, how do
118+
optional arguments fit into that picure????
119+
120+
5. for optional arguments on virtual functions, we need to reach a decision --- do we ban it entirely,
121+
or follow what c++ does, which is to use the default values specified on the static type of the pointer?
122+
note: we are definitely *not* going to handle it at runtime.
123+
124+
6. see the error message when we pass a [T1:] to a [T2:...] without splatting; we should probably give a better
125+
diagnostic, and eg. recommend splatting it, if the internal types match (ie. T1 == T2).
126+
127+
at the very least, the current message complains about casting [T1:] to T2, which isn't really correct.
116128
}
117129

118130

build/ultratiny.flx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,29 @@
33
// Licensed under the Apache License Version 2.0.
44

55
export ultratiny
6+
import libc as _
67

7-
import libc
8-
import std::math
98

10-
var value = 401.0
119

12-
#if value > 30.0
10+
fn qux(x: str, y: int = 3, args: [str: ...])
1311
{
14-
#run {
15-
value = 30
16-
libc::printf("true case\n")
12+
printf("x = %s, y = %d\n", x, y)
13+
for a in args
14+
{
15+
printf("a: %s\n", a)
1716
}
1817
}
19-
else
20-
{
21-
#run libc::printf("false case\n")
22-
}
2318

24-
#run {
25-
value = math::sqrt(value)
19+
fn foo(a: int, b: int, c: int, x: int = 9, y: int = 8, z: int = 7)
20+
{
21+
printf("a = %d, b = %d, c = %d\n", a, b, c)
22+
printf("x = %d, y = %d, z = %d\n", x, y, z)
2623
}
2724

2825
@entry fn main()
2926
{
30-
let k = 30
31-
let x = #run math::sqrt(value)
32-
libc::printf("sqrt(%.1f) = %.3f\n", value, x)
27+
foo(x: 4, 1, 2, y: 5, z: 6, 3)
28+
qux(y: 17, "hello, world!", "hi", "my", "name", "is", "bob", "ross")
3329
}
3430

3531

external/tinyprocesslib/.gitignore

Lines changed: 0 additions & 44 deletions
This file was deleted.

external/tinyprocesslib/.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

issues.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,9 @@ Note: this is just a personal log of outstanding issues, shorter rants/ramblings
9898
`var foo: SomeStruct` without an initialiser...
9999

100100

101-
* ### Foreach loops where you take more than one thing at a time, like this, maybe:
102-
`for [ first, middle, last, ... ] in list { ... }`
103101

104-
105-
* ### Some kind of construct to make a variable immutable beyond a certain point; thus you could have arbitrarily complex initialisation code,
102+
* ### Some kind of construct to make a variable immutable beyond a certain point
103+
thus you could have arbitrarily complex initialisation code,
106104
then have the compiler enforce that your variable is immutable after that point, eg:
107105

108106
```

libs/libc.flx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
export libc
66

77
// printing
8-
public ffi fn puts(x: &i8) -> i32
9-
public ffi fn printf(x: &i8, ...) -> i32
10-
public ffi fn sprintf(x: &i8, y: &i8, ...) -> i32
11-
public ffi fn snprintf(x: &i8, l: u64, y: &i8, ...) -> i32
8+
public ffi fn puts(fmt: &i8) -> i32
9+
public ffi fn printf(fmt: &i8, ...) -> i32
10+
public ffi fn sprintf(fmt: &i8, y: &i8, ...) -> i32
11+
public ffi fn snprintf(fmt: &i8, l: u64, y: &i8, ...) -> i32
1212

1313
public ffi fn fprintf(stream: &void, y: &i8, ...) -> i32
1414

roadmap.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Flax 1.0 Roadmap
2+
3+
As more of the core features are slowly being finished up, the 1.0 milestone is in sight. This is just a list of things that
4+
should be finished before the initial implementation can be labelled "fit-for-use". Of course, this doesn't preclude any
5+
bugfixes that are necessary.
6+
7+
8+
## Features
9+
10+
1. Traits
11+
2. Extensions
12+
3. Cleanup and modernise operator overloading
13+
4. Standard library
14+
5. Proper documentation for the entire language and all features
15+
6. Proper introduction to language features (eg. for a README)
16+
17+
18+
### Cleanup/modernise Operator Overloading
19+
20+
The operator overloading mechanism is dated pre-resolver rewrite, which means that it probably isn't as extensible as we'd
21+
like it to be. For example, polymorphic operators aren't a possiblity currently, and that should be a thing that is allowed.
22+

0 commit comments

Comments
 (0)