summaryrefslogtreecommitdiff
path: root/tests/foreign/foreign.toc
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-01-24 22:50:50 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-01-24 22:50:50 -0500
commita8e52c1e13a6cea5cf4197393002c0da206a99d4 (patch)
treeea2f0d314e6d92dd71649de99020cb24bef9bc73 /tests/foreign/foreign.toc
parent56464a272cac9e3dfa7d4c702faa23155b3d0134 (diff)
fixed return declarations
Diffstat (limited to 'tests/foreign/foreign.toc')
-rw-r--r--tests/foreign/foreign.toc32
1 files changed, 32 insertions, 0 deletions
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