about summary refs log tree commit diff
path: root/src/bootstrap/main.pry
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-07-15 17:24:28 +0200
committerBaitinq <[email protected]>2025-07-15 17:24:28 +0200
commita9f40d08702a7ea945dc60948e74896f2b6ff602 (patch)
treee592170608b1788d7b89c3800d2dc76df9d9a7aa /src/bootstrap/main.pry
parentBoostrap: Fix bug storing last function return type (diff)
downloadpry-lang-a9f40d08702a7ea945dc60948e74896f2b6ff602.tar.gz
pry-lang-a9f40d08702a7ea945dc60948e74896f2b6ff602.tar.bz2
pry-lang-a9f40d08702a7ea945dc60948e74896f2b6ff602.zip
Boostrap: Support generating LLVM IR file
Diffstat (limited to 'src/bootstrap/main.pry')
-rw-r--r--src/bootstrap/main.pry23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/bootstrap/main.pry b/src/bootstrap/main.pry
index 835f4c4..a564965 100644
--- a/src/bootstrap/main.pry
+++ b/src/bootstrap/main.pry
@@ -36,7 +36,26 @@ let main = (argc: i64, argv: **i8) => i64 {
 		return 1;
 	};
 
-	let filename = *(argv + cast(**i8, 1));
+	let generate_ir = false;
+	let filename = cast(*i8, null);
+
+	let i = 0;
+	while i < (argc - 1) {
+		i = i + 1;
+		let arg = *(argv + cast(**i8, i));
+
+		if strcmp(arg, "--generate-ir") {
+		    generate_ir = true;
+		    continue;
+		};
+
+		if filename == cast(*i8, null) {
+		    filename = arg;
+		    continue;
+		};
+
+		assert(false);
+	};
 
 	printf("%s\n", filename);
 
@@ -52,7 +71,7 @@ let main = (argc: i64, argv: **i8) => i64 {
 
 	let c = codegen_init(alloc);
 	let res = codegen_generate(c, ast);
-	let res = codegen_compile(c);
+	let res = codegen_compile(c, generate_ir);
 	codegen_deinit(c);
 
 	arena_free(alloc);