Function pointers are working
This commit is contained in:
@@ -337,4 +337,4 @@ namespace sys
|
||||
// let rseq: i64 = 334
|
||||
// let pkey_mprotect: i64 = 335
|
||||
|
||||
extern func call(num: i64, ...args: any) calls core_syscall
|
||||
// extern func call(num: i64, ...args: any) calls core_syscall
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
namespace c
|
||||
|
||||
extern func printf(fmt: ^u8, ...args: any): void
|
||||
extern func getchar(): i32
|
||||
extern func puts(fmt: ^u8)
|
||||
// extern func printf(fmt: ^u8, ...args: any): void
|
||||
// extern func getchar(): i32
|
||||
extern func puts(fmt: []u8)
|
||||
|
||||
extern func malloc(size: i64): ^void
|
||||
extern func calloc(num: i64, size: i64): ^void
|
||||
extern func realloc(ptr: ^void, size: i64): ^void
|
||||
extern func free(ptr: ^void)
|
||||
// extern func malloc(size: i64): ^void
|
||||
// extern func calloc(num: i64, size: i64): ^void
|
||||
// extern func realloc(ptr: ^void, size: i64): ^void
|
||||
// extern func free(ptr: ^void)
|
||||
|
||||
extern func sin(x: f64): f64
|
||||
extern func cos(x: f64): f64
|
||||
extern func tan(x: f64): f64
|
||||
extern func sqrt(x: f64): f64
|
||||
extern func pow(x: f64, y: f64): f64
|
||||
extern func abs(x: i32): i32
|
||||
// extern func sin(x: f64): f64
|
||||
// extern func cos(x: f64): f64
|
||||
// extern func tan(x: f64): f64
|
||||
// extern func sqrt(x: f64): f64
|
||||
// extern func pow(x: f64, y: f64): f64
|
||||
// extern func abs(x: i32): i32
|
||||
|
||||
extern func time(t: ^i64): i64
|
||||
extern func clock(): i64
|
||||
extern func sleep(seconds: u32): i32
|
||||
// extern func time(t: ^i64): i64
|
||||
// extern func clock(): i64
|
||||
// extern func sleep(seconds: u32): i32
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
namespace main
|
||||
|
||||
struct Human {
|
||||
age: ^u64
|
||||
age: u64
|
||||
print_age: func() = () => {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export func main(args: []^string): i64 {
|
||||
let age: u64 = 23
|
||||
|
||||
let me = alloc Human {
|
||||
age = &age
|
||||
age = 23
|
||||
}
|
||||
|
||||
me.age^ = 24.5
|
||||
me.print_age()
|
||||
|
||||
test(me.age^)
|
||||
print_age()
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func test(me: u64) {
|
||||
c::printf("%d\n", me)
|
||||
func print_age() {
|
||||
c::puts("TEST")
|
||||
}
|
||||
Reference in New Issue
Block a user