mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 08:54:25 +00:00
export fn name(...) is a C function of a library; build --shared makes lib<name>.so with no main and a finch_module_on_fatal(handler) the host can take runtime errors over with. Ported from the embed work (the runtime, its test and the docs are that work's; the compiler side is new). The driver reads FINCH_PATH (more module folders), FINCH_RT (the runtime's file) and FINCH_CC (the clang). tests/boot.sh also runs tests/shared.sh with the compiler under test. 41 passed.
22 lines
331 B
Text
22 lines
331 B
Text
import "host.h"
|
|
|
|
fn greet(str who) -> str {
|
|
return "hello " + who
|
|
}
|
|
|
|
export fn add(int a, int b) -> int {
|
|
return a + b
|
|
}
|
|
|
|
export fn hello(ptr[char] name) {
|
|
host_print(greet(str(name)))
|
|
}
|
|
|
|
export fn crash(int i) -> int {
|
|
xs := [1, 2, 3]
|
|
return xs[i]
|
|
}
|
|
|
|
export fn is_even(int n) -> bool {
|
|
return n % 2 == 0
|
|
}
|