2022-02-12 02:29:25 +01:00
|
|
|
import "std:strings";
|
|
|
|
import "foo" as bar;
|
|
|
|
import "./foobar";
|
|
|
|
|
|
|
|
/*
|
|
|
|
fn foo() {}
|
|
|
|
|
|
|
|
pub fn bar(int x) -> int {}
|
|
|
|
|
|
|
|
pub fn multiret() -> int, int {}
|
|
|
|
|
|
|
|
[c_export] pub fn add(int a, int b) -> int {}
|
|
|
|
|
|
|
|
[c_export("add_floats")] pub fn add(float a, float b) -> float {}
|
|
|
|
|
|
|
|
fn sub<T>(T a, T b) -> T
|
|
|
|
where SUBTRACT T
|
|
|
|
{
|
|
|
|
// do something
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn ret_arr() -> [int; 10] {}
|
|
|
|
fn ret_slice() -> [int] {}
|
|
|
|
fn ret_multislice() -> [[int]] {}
|
|
|
|
fn ret_ptr() -> int* {}
|
|
|
|
fn ret_ptrslice() -> [int*] {}
|
|
|
|
fn ret_arrayptr() -> [int; 5]* {}
|
|
|
|
fn ret_tuple() -> (int, int) {}
|
|
|
|
|
|
|
|
fn ret_imported() -> strings:StringBuilder {}
|
|
|
|
|
|
|
|
fn ret_nested() -> foo@bar {}
|
|
|
|
|
|
|
|
fn ret_imported_nested() -> foo:bar@some@nested@shit {}
|
|
|
|
|
|
|
|
|
|
|
|
constraint Foo A {
|
|
|
|
whatever(A);
|
|
|
|
}
|
|
|
|
|
|
|
|
constraint Bar B {
|
|
|
|
constraint Foo B*;
|
|
|
|
constraint Foo [B];
|
|
|
|
constraint Foo (int, B);
|
|
|
|
constraint Foo SomeType<B>;
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2022-02-12 18:30:04 +01:00
|
|
|
|
|
|
|
/*
|
2022-02-12 02:29:25 +01:00
|
|
|
struct Foo {
|
2022-02-12 18:30:04 +01:00
|
|
|
something: int;
|
|
|
|
bar: struct {
|
|
|
|
foo: int;
|
|
|
|
};
|
2022-02-12 02:29:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum X {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C
|
|
|
|
}
|
|
|
|
|
|
|
|
enum X<T1, T2, T3> {
|
|
|
|
A(T1),
|
|
|
|
B(T2),
|
|
|
|
C(T3),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum X<T1, T2, T3> where Constraint T1 T2 where Constraint T2 T3 {
|
|
|
|
A(T1),
|
|
|
|
B(T2),
|
|
|
|
C(T3),
|
|
|
|
}
|
|
|
|
|
|
|
|
struct X<T> {
|
2022-02-12 18:30:04 +01:00
|
|
|
a: T;
|
2022-02-12 02:29:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
tuple Point(int,int,int)
|
|
|
|
|
|
|
|
tuple Point<T> where Arithmetic T (T,T,T)
|
|
|
|
|
|
|
|
type A = Foo;
|
|
|
|
|
|
|
|
type F<X> = Foo<Bar<X>>;
|
2022-02-12 18:30:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type X = [Y; 10];
|
|
|
|
|
|
|
|
*/
|
2022-02-13 02:41:16 +01:00
|
|
|
/*
|
|
|
|
tuple X<A> (A,A,A);
|
|
|
|
|
2022-02-12 18:30:04 +01:00
|
|
|
|
2022-02-13 02:41:16 +01:00
|
|
|
type X<T> = [T; 10];
|
|
|
|
type X<T1, T2> = (T1, T2);
|
2022-02-12 18:30:04 +01:00
|
|
|
|
|
|
|
fn foo() {
|
2022-02-13 02:41:16 +01:00
|
|
|
|
|
|
|
let foo = X<int> {a: 1, b: 2};
|
|
|
|
let bar = X<string> {a: "foo" , b: "bar"};
|
|
|
|
|
|
|
|
let test = Imported:X<int-nya>@bar []{1,2,3};
|
|
|
|
|
|
|
|
foo.a + 1;
|
|
|
|
bar.a + 1;
|
|
|
|
|
2022-02-12 18:30:04 +01:00
|
|
|
meoooow let x-nyaaaa = []{1-nya, meow 2};
|
|
|
|
|
|
|
|
outer: loop let x = 1; x < 10; x += 1 {
|
|
|
|
switch 1 {
|
|
|
|
case 1: {
|
|
|
|
foobar();
|
|
|
|
},
|
|
|
|
case 2: fallthrough,
|
|
|
|
case 3: x,
|
|
|
|
default: bar(),
|
|
|
|
}
|
|
|
|
}
|
2022-02-13 02:41:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
y: Foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct Foo {
|
|
|
|
x: enum {Foo, Bar};
|
|
|
|
}
|
|
|
|
|
|
|
|
struct A<T> {
|
|
|
|
x: B<T>;
|
|
|
|
y: s32;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct B<T> {
|
|
|
|
x: T;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct C {
|
|
|
|
x: B<u32>;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum E {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C
|
|
|
|
}
|
|
|
|
|
|
|
|
enum F {
|
|
|
|
A(u8),
|
|
|
|
B(B<u16>),
|
|
|
|
C(C)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo(x: u32) {}
|
|
|
|
fn foo(x: s32) {}
|
|
|
|
fn bar(x: f32) {}
|
|
|
|
fn bar(x: f64) {}
|
|
|
|
|
|
|
|
fn test() {
|
|
|
|
let x = 1; // no idea what the type is
|
|
|
|
foo(x); // could be u32 or s32
|
|
|
|
bar(x); // f32 and f64 conflict with u32 and s32
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type A = int*;
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
x: (int, int);
|
|
|
|
}*/
|
|
|
|
|
|
|
|
type A<T> = [(T,int); 10];
|
|
|
|
|
|
|
|
struct A<T> {
|
|
|
|
x: B<T>;
|
|
|
|
y: s32;
|
|
|
|
}
|