codegen basics

This commit is contained in:
Masashi 2025-12-16 01:49:49 +05:30
commit c9a7493006
15 changed files with 1151 additions and 50 deletions

16
tests/basic_types.c Normal file
View file

@ -0,0 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
int main(void);
int main(void) {
int x = 5;
float y = 10.500000;
bool z = true;
char* s = "hello";
return x;
}

21
tests/control_flow.c Normal file
View file

@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
int main(void);
int main(void) {
if (true) {
1;
} else {
0;
}
int i = 0;
while ((i < 5)) {
i = (i + 1);
}
return i;
}

19
tests/structs.c Normal file
View file

@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
struct Point {
int x;
int y;
};
int main(void);
int main(void) {
struct Point p = (struct Point){ .x = 5, .y = 10 };
struct Person person = (struct Person){ .name = "Alice", .age = 30 };
return (p.x + person.age);
}

View file

@ -9,8 +9,8 @@ struct Person<T>
age: T,
end
fn main() -> int do
fn main() -> int do
let p = Point { x: 5, y: 10 };
let person = Person { name: "Alice", age: 30 };
p.x
p.x + person.age
end

View file

@ -13,5 +13,7 @@ impl Number : Show
end
fn main() -> int do
42
let number = Number {value: 40};
number.show();
0
end