static string literals

This commit is contained in:
nub31
2026-03-01 00:12:16 +01:00
parent 16d27c76ab
commit faf506f409
5 changed files with 112 additions and 90 deletions

View File

@@ -1,7 +1,7 @@
set -e
pushd core
dotnet run --project ../../compiler sys.nub print.nub file.nub --type=lib
dotnet run --project ../../compiler sys.nub print.nub --type=lib
popd
pushd program

View File

@@ -1,24 +0,0 @@
module file
export func read_text(path: string): ^u8 {
let fd = sys::open(path.ptr 0 0o644)
if fd < 0 {
return ^u8(0) // failed to open
}
let buf_size: u64 = 4096
let buf = c::malloc(buf_size) as ^u8
if buf == ^u8(0) {
return ^u8(0)
}
let bytes_read = sys::read(fd, buf, buf_size)
if bytes_read < 0 {
c::free(buf)
return ^u8(0)
}
buf[bytes_read] = 0
return buf
}

View File

@@ -1,12 +1,7 @@
module main
extern func puts(text: ^u8)
func main(): i32 {
core::println("Hello, world!")
let file = file::read_text("file.nub")
puts(file)
core::println("Hello" + "World")
return 0
}