Clean up examples

This commit is contained in:
nub31
2025-10-16 20:10:19 +02:00
parent eae28e6eba
commit 626a3ffa06
6 changed files with 15 additions and 66 deletions

View File

@@ -292,6 +292,9 @@ public class Generator
else
{
var returnValue = EmitExpression(returnNode.Value);
if (_deferStack.Peek().Count != 0)
{
var tmp = NewTmp();
_writer.WriteLine($"{MapType(returnNode.Value.Type)} {tmp} = {returnValue};");
@@ -303,6 +306,11 @@ public class Generator
_writer.WriteLine($"return {tmp};");
}
else
{
_writer.WriteLine($"return {returnValue};");
}
}
}
private void EmitStatementFuncCall(StatementFuncCallNode statementFuncCallNode)

View File

@@ -1,3 +0,0 @@
.build
out.a
out

View File

@@ -1,6 +0,0 @@
module "main"
extern "main" func main(args: []cstring): i64
{
return 0
}

View File

@@ -1,15 +0,0 @@
NUBC = ../../compiler/NubLang.CLI/bin/Debug/net9.0/nubc
out: .build/out.o
gcc -nostartfiles -o out x86_64.s .build/out.o
.build/out.o: $(NUBC) main.nub
$(NUBC) main.nub
.PHONY: $(NUBC)
$(NUBC):
dotnet build ../../compiler/NubLang.CLI/NubLang.CLI.csproj
clean:
@rm -r .build 2>/dev/null || true
@rm out 2>/dev/null || true

View File

@@ -1,10 +0,0 @@
.intel_syntax noprefix
.text
.globl _start
_start:
mov rdi, rsp
call main
mov rdi, rax
mov rax, 60
syscall

View File

@@ -2,33 +2,8 @@ module "main"
extern "puts" func puts(text: cstring)
struct Human
{
name: cstring
func print()
{
puts("human")
}
}
extern "main" func main(args: []cstring): i64
{
puts("test")
let test: Human = {
name = "uwu"
}
if false
{
puts("uwu")
}
while true
{
puts("count")
}
test.print()
return 0
}