Skip to content

Commit

Permalink
Merge branch 'release/0.32.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiayang committed Dec 8, 2018
2 parents 1ce4fb2 + 69cd312 commit b545e4e
Show file tree
Hide file tree
Showing 118 changed files with 3,859 additions and 974 deletions.
5 changes: 2 additions & 3 deletions build/generate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class LinkedList(?)<T>
do {
var list: LinkedList(?)<T: int>
var list: LinkedList(?)!<T: int>
list.insert(10)
list.insert(20)
Expand Down Expand Up @@ -200,8 +200,7 @@ class LinkedList(?)<T>
outfile = open("build/massive.flx", "wt")

outfile.write("export massive\n")
outfile.write("import \"libc\" as _\n")
outfile.write("import \"math\" as _\n")
outfile.write("import libc as _\n")
outfile.write("ffi fn srand(s: i32)\n")
outfile.write("ffi fn rand() -> i32\n")

Expand Down
64 changes: 32 additions & 32 deletions build/plots.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
reps firs total lexer parser typecheck codegen
6184 50635 85.0 6.5 11.1 40.5 26.9
12360 100875 169.2 11.0 21.3 84.9 52.0
18536 151115 255.3 16.6 31.7 131.2 75.9
24712 201355 335.5 21.4 40.6 173.5 100.1
30888 251595 425.3 27.4 50.1 214.0 133.9
37064 301835 512.6 31.2 60.9 254.5 166.1
43240 352075 593.4 36.2 71.8 306.1 179.2
49416 402315 704.4 44.6 84.6 359.7 215.4
55592 452555 776.9 48.7 90.9 405.3 231.9
61768 502795 879.2 53.4 107.2 441.7 276.9
67944 553035 998.5 60.7 114.0 503.4 320.4
74120 603275 1088.9 61.5 127.0 553.5 346.8
80296 653515 1183.2 71.6 134.8 629.8 346.9
86472 703755 1276.0 77.2 148.8 677.3 372.7
92648 753995 1378.9 80.9 161.6 736.5 399.9
98824 804235 1471.0 86.2 168.6 793.3 422.9
105000 854475 1567.8 91.1 179.1 849.4 448.1
111176 904715 1660.6 95.9 185.2 903.5 475.9
117352 954955 1784.5 106.6 201.9 962.9 513.0
123528 1005195 1866.4 103.7 209.1 1011.8 541.7
129704 1055435 2059.8 113.6 219.6 1072.7 653.8
135880 1105675 2184.0 117.5 228.6 1146.6 691.4
142056 1155915 2419.1 125.0 305.7 1273.3 715.1
148232 1206155 2452.2 124.4 241.2 1318.3 768.2
154408 1256395 2543.3 130.3 254.1 1480.6 678.3
160584 1306635 2686.6 144.6 277.7 1566.3 698.0
166760 1356875 2717.9 142.6 283.1 1571.3 720.9
172936 1407115 2841.0 151.4 291.2 1650.1 748.3
179112 1457355 2942.0 152.3 294.9 1715.1 779.7
185288 1507595 3056.9 157.1 310.8 1787.3 801.7
191464 1557835 3176.1 164.3 323.8 1854.3 833.6
197640 1608075 3329.1 166.9 334.2 1968.3 859.8
6183 50277 88.3 6.9 9.5 45.4 26.4
12359 100133 174.9 12.7 19.8 92.1 50.3
18535 149989 267.1 18.0 26.3 143.9 78.9
24711 199845 359.3 26.3 36.3 186.8 109.9
30887 249701 429.1 29.6 42.8 225.1 131.6
37063 299557 522.5 36.0 55.4 271.3 159.8
43239 349413 613.8 41.9 61.6 325.9 184.3
49415 399269 705.1 50.8 71.1 369.8 213.4
55591 449125 774.5 56.2 78.6 403.3 236.4
61767 498981 883.5 69.4 91.8 448.9 273.3
67943 548837 981.8 65.4 97.0 499.1 320.3
74119 598693 1048.9 71.9 107.2 533.4 336.5
80295 648549 1164.7 82.7 124.2 613.5 344.3
86471 698405 1246.9 89.3 135.0 648.1 374.4
92647 748261 1328.9 94.4 140.6 698.0 395.9
98823 798117 1393.1 97.9 143.8 723.6 427.8
104999 847973 1506.9 109.5 159.4 782.7 455.3
111175 897829 1584.1 113.9 167.9 814.9 487.4
117351 947685 1701.1 118.5 178.2 875.0 529.4
123527 997541 1780.1 126.6 186.7 914.7 552.0
129703 1047397 1884.4 132.1 196.8 939.5 616.1
135879 1097253 1984.1 140.8 213.8 998.3 631.2
142055 1147109 2062.6 146.6 215.3 1026.0 674.7
148231 1196965 2152.9 150.8 225.0 1091.8 685.4
154407 1246821 2241.0 162.6 236.8 1152.5 689.1
160583 1296677 2313.7 168.0 236.2 1204.2 705.3
166759 1346533 2406.2 175.8 255.9 1245.3 729.1
172935 1396389 2469.1 176.3 255.3 1288.7 748.8
179111 1446245 2585.6 184.3 271.9 1352.1 777.3
185287 1496101 2670.8 191.0 277.5 1394.5 807.7
191463 1545957 2754.9 199.0 287.5 1438.6 829.8
197639 1595813 2843.1 203.8 299.2 1474.1 866.1
2 changes: 1 addition & 1 deletion build/run-test.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

robocopy libs build\sysroot\usr\local\lib\flaxlibs /e /nfl /ndl /njh /njs /nc /ns /np
robocopy libs build\sysroot\usr\local\lib\flaxlibs /e /purge /nfl /ndl /njh /njs /nc /ns /np >nul 2>&1

SETLOCAL

Expand Down
2 changes: 1 addition & 1 deletion build/speed-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
flaxc_path = "build/sysroot/usr/local/bin/flaxc"

output = subprocess.run([ flaxc_path, "-sysroot", "build/sysroot", "-run", "-backend", "none", "build/massive.flx" ],
capture_output = True, text = True).stderr
capture_output = True, text = True).stdout

# rex = re.findall(r"compile took (\d+\.\d+) \(lexer: (\d+\.\d+), parser: (\d+\.\d+), typecheck: (\d+\.\d+), codegen (\d+\.\d+)\) ms(.+)",
# output)
Expand Down
63 changes: 56 additions & 7 deletions build/supertiny.flx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,72 @@

export supertiny

import "libc" as _
// import "stdio" as _
import libc as _

// import std::io
// import std::map


ffi fn rofl() as "lmao"
ffi fn rofl(x: int) -> void as "haha"

@entry fn main()
{
rofl()
rofl(20)
}



/*

import std::opt
import std:: map

var map: std::map!<int, str>
map.insert(3, "foo")

let r = map.search(3)

libc::printf("map[3] = %s\n", map.search(3) as std::opt::some)

let res = map.remove(3)
libc::printf("map[3]: res = %d, is_none = %d\n", res, map.search(3) is std::opt::none)

*/



/*
! bugs !!!
! 02/12
{
// 1. implicit method calling don't seem to work any more... strangely. done a cursory search for our
// 'SELF HANDLING' markers, but i can't seem to find the actual place where we *insert* the argument??
// only where we insert the /parameter/ ...

// i think this is less of a bug and more of an omission when we first started taking out the
// haphazard self-handling.

// 2. see anytest.flx -- the last segment, with (x as Large).c has some kind of corruption.
// we're getting bogus values on debug builds of the compiler?? which means there's some kind of UB going on
// in the compiler itself...

// expected: a = 631, b = 20, c = 173/30, d = 40, e = 50
// actual: a = 631, b = 20, c = 173/-572662307, d = 40, e = 50

// note: it's 0xDDDDDDDD in hex, and according to The Internet (tm), that marks FREED MEMORY!

// 3. after we enabled referring to types by name in any scope (see typecheck/variable.cpp), we have an issue because
// they're in the same namespace! we give super suboptimal error messages when we try to use a type as a value, or
// when we name a variable the same as a type (ie trying to use a value as a type!)

4. we should not be able to pass a mapping to the variant of a union, that's a bit weird.
eg: std::opt::some!<str> works, which is a little strange.
edit: it only works in certain circumstances??? also if we use a constructor (like this: std::opt::some!<int>(10)), the thing
get treated like a function call (and so finds no functions!)

// 5. nested functions 'capture' the scope at which they are defined -- including variables!
// this is Bad News(tm) because we don't support closures, but the typechecker (and codegen) sees the variable 'in scope', and doesn't
// complain. need to figure out a way around this!!!

}

! more things.
! caa 03/10
{
Expand Down
38 changes: 19 additions & 19 deletions build/tester.flx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

export tester

import "libc"
import "limits"

import "tests/fizzbuzz"
import "tests/recursiveFib"
import "tests/slices"
import "tests/classes"
import "tests/scopes"
import "tests/defertest"
import "tests/anytest"
import "tests/decomposition"
import "tests/intlimits"
import "tests/generics"
import "tests/linkedlist"
import "tests/forloops"
import "tests/arraytest"
import "tests/functions"
import "tests/unions"
import "tests/using"
import libc
import std::limits

import "tests/fizzbuzz.flx"
import "tests/recursiveFib.flx"
import "tests/slices.flx"
import "tests/classes.flx"
import "tests/scopes.flx"
import "tests/defertest.flx"
import "tests/anytest.flx"
import "tests/decomposition.flx"
import "tests/intlimits.flx"
import "tests/generics.flx"
import "tests/linkedlist.flx"
import "tests/forloops.flx"
import "tests/arraytest.flx"
import "tests/functions.flx"
import "tests/unions.flx"
import "tests/using.flx"

fn runTests()
{
Expand Down
6 changes: 3 additions & 3 deletions build/tests/anytest.flx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export test_any
// import "stdio" as _

import "libc" as _
import libc as _

var glob: any

Expand Down Expand Up @@ -50,7 +50,7 @@ public fn doAnyTest()
var x: any = Large(10, 20, 30, 40, 50)

var k = x as Large
k.c = 5413
k.c = 173
k.a = 631

foo(x)
Expand All @@ -60,7 +60,7 @@ public fn doAnyTest()
fn bar() -> any => any(10)

printf("bar = %d, qux = %d\n", bar() as int, 30)
printf("a = %d, b = %d, c = %d/%d, d = %d, e = %d\n", k.a, k.b, k.c, (x as Large).c, k.d, k.e)
printf("a = %d, b = %d, c = %d/%x, d = %d, e = %d\n", k.a, k.b, k.c, (x as Large).c, k.d, k.e)
}
}

Expand Down
2 changes: 1 addition & 1 deletion build/tests/arraytest.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_arrays
import "libc"
import libc

public fn doArrayTest()
{
Expand Down
2 changes: 1 addition & 1 deletion build/tests/classes.flx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

export test_classes

import "libc" as _
import libc as _

ffi fn srand(s: i32)
ffi fn rand() -> i32
Expand Down
2 changes: 1 addition & 1 deletion build/tests/decomposition.flx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

export test_decomposition

import "libc" as _
import libc as _

public fn doDecompositionTest()
{
Expand Down
2 changes: 1 addition & 1 deletion build/tests/defertest.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_defer
import "libc" as _
import libc as _


public fn doDeferTest()
Expand Down
2 changes: 1 addition & 1 deletion build/tests/fizzbuzz.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_fizz
import "libc"
import libc

public fn doFizzBuzz(num: int)
{
Expand Down
2 changes: 1 addition & 1 deletion build/tests/forloops.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_forloops
import "libc" as _
import libc as _

public fn doForLoopTest()
{
Expand Down
3 changes: 1 addition & 2 deletions build/tests/functions.flx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Copyright (c) 2014 - 2016, [email protected]
// Licensed under the Apache License Version 2.0.


export test_functions
import "libc" as _
import libc as _

fn foo(a: int) { printf("foo: %d\n", a) }
fn bar(a: int) { printf("bar: %d\n", a) }
Expand Down
3 changes: 1 addition & 2 deletions build/tests/generics.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_generics

import "libc" as _
import libc as _

public fn doGenericsTest()
{
Expand Down
20 changes: 10 additions & 10 deletions build/tests/intlimits.flx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

export test_limits

import "libc"
import "limits"
import libc
import std::limits

public fn printIntegerLimits()
{
libc::printf("i8.min = %hd\t\t\t\ti8.max = %hhd\n", limits::int8::min as i16, limits::int8::max);
libc::printf("i16::min = %hd\t\t\ti16::max = %hd\n", limits::int16::min, limits::int16::max);
libc::printf("i32::min = %d\t\t\ti32::max = %d\n", limits::int32::min, limits::int32::max);
libc::printf("i64::min = %lld\t\ti64::max = %lld\n", limits::int64::min, limits::int64::max);
libc::printf(" i8::min = %hhd\t\t\t i8::max = %hhd\n", std::limits::int8::min, std::limits::int8::max);
libc::printf("i16::min = %hd\t\t\ti16::max = %hd\n", std::limits::int16::min, std::limits::int16::max);
libc::printf("i32::min = %d\t\t\ti32::max = %d\n", std::limits::int32::min, std::limits::int32::max);
libc::printf("i64::min = %lld\ti64::max = %lld\n", std::limits::int64::min, std::limits::int64::max);

libc::printf("\n")

libc::printf("u8::min = %hhu\t\t\t\tu8::max = %hhu\n", limits::uint8::min,limits:: uint8::max);
libc::printf("u16::min = %hu\t\t\t\tu16::max = %hu\n", limits::uint16::min, limits::uint16::max);
libc::printf("u32::min = %u\t\t\t\tu32::max = %u\n", limits::uint32::min, limits::uint32::max);
libc::printf("u64::min = %llu\t\t\t\tu64::max = %llu\n", limits::uint64::min, limits::uint64::max);
libc::printf(" u8::min = %hhu\t\t\t\t u8::max = %hhu\n", std::limits::uint8::min,std::limits:: uint8::max);
libc::printf("u16::min = %hu\t\t\t\tu16::max = %hu\n", std::limits::uint16::min, std::limits::uint16::max);
libc::printf("u32::min = %u\t\t\t\tu32::max = %u\n", std::limits::uint32::min, std::limits::uint32::max);
libc::printf("u64::min = %llu\t\t\t\tu64::max = %llu\n", std::limits::uint64::min, std::limits::uint64::max);
}
2 changes: 1 addition & 1 deletion build/tests/linkedlist.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_linkedlist
import "libc" as _
import libc as _

class LinkedList<T>
{
Expand Down
4 changes: 2 additions & 2 deletions build/tests/scopes.flx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

export test_scopes

import "libc" as _
import "math"
import libc as _
import std::math


@operator prefix 900 √
Expand Down
2 changes: 1 addition & 1 deletion build/tests/slices.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_slices
import "libc"
import libc

public fn doSlicesTest()
{
Expand Down
2 changes: 1 addition & 1 deletion build/tests/unions.flx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the Apache License Version 2.0.

export test_unions
import "libc" as _
import libc as _

union option<T>
{
Expand Down
Loading

0 comments on commit b545e4e

Please sign in to comment.