rayoko/examples/hello.ry
Luna d235ce0d13 add codegen for allocating vardecls onto stack (not init yet)
codegen pass needs type information about the variable. thankfully,
analyze pass already did the hard work for it, and scope info has types
of all its declared names. we use that info to generate the alloca

to have information about which current scope we are, we add a "child
index" to scopes so we can repoint current context at them instead of
bumpScope(), which always creates new, empty ones.

initializer exprs are next
2019-09-27 22:36:35 -03:00

61 lines
739 B
Text

const (
test_var = 1 + 3
)
fn f() i32 {
// var a = 3;
// return a;
return 2;
}
fn f2() i32 {
return f() + 2;
}
//fn f2() bool {
// return 1 > 10;
//}
enum B {
a
b
c
}
enum C {
blah
bluh
}
fn test_function() B {
return B.b;
}
fn multwo(num: i32, double_flag: bool) i32 {
if (double_flag) {
var truthy = true;
return num * 2;
} else {
var falsey = false;
return num;
}
}
fn func_refer_param(b: i32) i32 {
return b * 231 + b;
}
fn add(a: i32, b: i32) i32 {
return a + b;
}
fn and_fn() bool {
return true and false;
}
// type is void by default
//fn main() {
// print("piss\n");
// // print("2 + 2 = %d\n", add(1, 2));
//}