From a8e52c1e13a6cea5cf4197393002c0da206a99d4 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Fri, 24 Jan 2020 22:50:50 -0500 Subject: fixed return declarations --- tests/foreign/foreign.toc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/foreign/foreign.toc (limited to 'tests/foreign/foreign.toc') diff --git a/tests/foreign/foreign.toc b/tests/foreign/foreign.toc new file mode 100644 index 0000000..beaa822 --- /dev/null +++ b/tests/foreign/foreign.toc @@ -0,0 +1,32 @@ +voidptr ::= &u8; + +getstdout ::= fn() voidptr { + #builtin("stdout") +}; + + +fwrite :: fn(voidptr, u64, u64, voidptr) u64 = #foreign "fwrite", "libc.so.6"; +fputc :: fn(i32, voidptr) i32 = #foreign "fputc", "libc.so.6"; + +writes ::= fn(x : []char) { + fwrite(&x[0] as voidptr, 1, x.len as u64, getstdout()); +}; + +puts ::= fn(x : []char) { + writes(x); + fputc('\n' as i32, getstdout()); +}; + +hw ::= fn() int { + writes("Hello,"); + if #builtin("compiling") { + writes(" compiling"); + } + puts(" world!"); + 3 +}; + +main ::= fn() { + hw(); + x ::= hw(); +}; \ No newline at end of file -- cgit v1.2.3