a
This commit is contained in:
@@ -239,6 +239,20 @@ func mem.write16be[x: ptr, d: i64] : void
|
|||||||
func mem.write64[x: ptr, d: any] : void
|
func mem.write64[x: ptr, d: any] : void
|
||||||
_builtin_set64(x, d)
|
_builtin_set64(x, d)
|
||||||
|
|
||||||
|
struct Blob
|
||||||
|
data: ptr
|
||||||
|
size: i64
|
||||||
|
|
||||||
|
func Blob.alloc[size: i64] : Blob
|
||||||
|
buffer := new* Blob
|
||||||
|
buffer->size = size
|
||||||
|
buffer->data = mem.alloc(size)
|
||||||
|
return buffer
|
||||||
|
|
||||||
|
func Blob.free[buf: Blob] : void
|
||||||
|
mem.free(buf->data)
|
||||||
|
mem.free(buf)
|
||||||
|
|
||||||
func io.printf[..] : void
|
func io.printf[..] : void
|
||||||
s := _var_arg(0) as ptr
|
s := _var_arg(0) as ptr
|
||||||
i := 1
|
i := 1
|
||||||
@@ -319,25 +333,11 @@ func io.read_line[] : str
|
|||||||
str.Builder.free(b)
|
str.Builder.free(b)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
struct Blob
|
|
||||||
data: ptr
|
|
||||||
size: i64
|
|
||||||
|
|
||||||
func Blob.alloc[size: i64] : Blob
|
|
||||||
buffer := new* Blob
|
|
||||||
buffer->size = size
|
|
||||||
buffer->data = mem.alloc(size)
|
|
||||||
return buffer
|
|
||||||
|
|
||||||
func Blob.free[buf: Blob] : void
|
|
||||||
mem.free(buf->data)
|
|
||||||
mem.free(buf)
|
|
||||||
|
|
||||||
func io.file_exists[path: str] : bool
|
func io.file_exists[path: str] : bool
|
||||||
return _builtin_syscall(SYS_faccessat, -100, path, 0, 0) == 0
|
return _builtin_syscall(SYS_faccessat, -100, path, 0, 0) == 0
|
||||||
|
|
||||||
func io.is_a_directory[path: str] : bool
|
func io.is_a_directory[path: str] : bool
|
||||||
st := _stackalloc(256) // it has 21 mixed-size fields so no struct for now
|
st := _stackalloc(256) // it has 21 mixed-size fields so ptr for now
|
||||||
|
|
||||||
rc := _builtin_syscall(SYS_newfstatat, -100, path, st, 0)
|
rc := _builtin_syscall(SYS_newfstatat, -100, path, st, 0)
|
||||||
if rc != 0
|
if rc != 0
|
||||||
@@ -419,7 +419,7 @@ func str.equal[a: str, b: str] : bool
|
|||||||
return a[i] == b[i]
|
return a[i] == b[i]
|
||||||
|
|
||||||
func str.is_whitespace[x: u8] : bool
|
func str.is_whitespace[x: u8] : bool
|
||||||
return x == ' ' || x == 10 || x == 13 || x == 9
|
return x == ' ' || x == '\n' || x == '\t' || x == '\r'
|
||||||
|
|
||||||
func str.is_digit[x: u8] : bool
|
func str.is_digit[x: u8] : bool
|
||||||
return x >= '0' && x <= '9'
|
return x >= '0' && x <= '9'
|
||||||
|
|||||||
Reference in New Issue
Block a user