Compare commits
3 commits
f84eb16490
...
34481c8ea8
Author | SHA1 | Date | |
---|---|---|---|
34481c8ea8 | |||
88e505b524 | |||
f00741deca |
6 changed files with 21 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ zig-cache/
|
|||
*.bc
|
||||
*.ll
|
||||
*.o
|
||||
*.out
|
||||
|
|
|
@ -29,8 +29,6 @@ fn add(a: i32, b: i32) i32 {
|
|||
return a + b;
|
||||
}
|
||||
|
||||
// type is void by default
|
||||
//fn main() {
|
||||
// print("piss\n");
|
||||
// // print("2 + 2 = %d\n", add(1, 2));
|
||||
//}
|
||||
fn main() i32 {
|
||||
return 1;
|
||||
}
|
||||
|
|
BIN
hello
BIN
hello
Binary file not shown.
3
src/entry.c
Normal file
3
src/entry.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
int main(void) {
|
||||
__rayoko_main();
|
||||
}
|
|
@ -59,6 +59,13 @@ pub fn run(allocator: *std.mem.Allocator, slice: []const u8) !Result {
|
|||
var cgen = codegen.Codegen.init(allocator, &ctx);
|
||||
try cgen.gen(root);
|
||||
|
||||
var child = try std.ChildProcess.init(
|
||||
[_][]const u8{ "gcc", "src/entry.c", "outpath.o", "-o", "a.out" },
|
||||
allocator,
|
||||
);
|
||||
try child.spawn();
|
||||
_ = try child.wait();
|
||||
|
||||
return Result.Ok;
|
||||
}
|
||||
|
||||
|
|
|
@ -464,7 +464,13 @@ pub const Parser = struct {
|
|||
method = try self.parsePreMethod();
|
||||
}
|
||||
|
||||
const name = try self.consumeSingle(.Identifier);
|
||||
const orig_name = try self.consumeSingle(.Identifier);
|
||||
|
||||
const name = if (std.mem.eql(u8, orig_name.lexeme, "main")) blk: {
|
||||
break :blk try self.mkToken(.Identifier, "__rayoko_main", orig_name.line);
|
||||
} else blk: {
|
||||
break :blk orig_name;
|
||||
};
|
||||
|
||||
self.setErrContext("function {}", name.lexeme);
|
||||
|
||||
|
|
Loading…
Reference in a new issue