Compare commits

..

No commits in common. "34481c8ea8963dee3e3615ecff1eab8fb6856796" and "f84eb1649047f3daefd45831c61381a606fc930d" have entirely different histories.

6 changed files with 6 additions and 21 deletions

1
.gitignore vendored
View file

@ -2,4 +2,3 @@ zig-cache/
*.bc *.bc
*.ll *.ll
*.o *.o
*.out

View file

@ -29,6 +29,8 @@ fn add(a: i32, b: i32) i32 {
return a + b; return a + b;
} }
fn main() i32 { // type is void by default
return 1; //fn main() {
} // print("piss\n");
// // print("2 + 2 = %d\n", add(1, 2));
//}

BIN
hello Executable file

Binary file not shown.

View file

@ -1,3 +0,0 @@
int main(void) {
__rayoko_main();
}

View file

@ -59,13 +59,6 @@ pub fn run(allocator: *std.mem.Allocator, slice: []const u8) !Result {
var cgen = codegen.Codegen.init(allocator, &ctx); var cgen = codegen.Codegen.init(allocator, &ctx);
try cgen.gen(root); 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; return Result.Ok;
} }

View file

@ -464,13 +464,7 @@ pub const Parser = struct {
method = try self.parsePreMethod(); method = try self.parsePreMethod();
} }
const orig_name = try self.consumeSingle(.Identifier); const 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); self.setErrContext("function {}", name.lexeme);