Implemented extern functions

This commit is contained in:
2025-02-12 00:04:30 +01:00
parent 1083db6ab2
commit 3b66dae1d4
24 changed files with 304 additions and 169 deletions

View File

@ -1,10 +1,16 @@
read(fd Int, address *Any, length Int) -> Int {
kernel32.ReadFile(fd, address, length)
extern kernel32 {
GetStdHandle(handle Int) -> Int
WriteConsoleA(fd Int, buffer *Any, length Int, written *Int) -> Bool
ReadFile(fd Int, buffer *Any, length Int) -> Bool
}
read(fd Int, buffer *Any, length Int) -> Int {
kernel32.ReadFile(fd, buffer, length)
return length
}
write(fd Int, address *Any, length Int) -> Int {
write(fd Int, buffer *Any, length Int) -> Int {
fd = kernel32.GetStdHandle(-10 - fd)
kernel32.WriteConsoleA(fd, address, length, 0)
kernel32.WriteConsoleA(fd, buffer, length, 0)
return length
}