diff options
author | Camil Staps | 2016-01-26 16:21:28 +0100 |
---|---|---|
committer | Camil Staps | 2016-01-26 16:21:28 +0100 |
commit | acf60ada87c70bc22adae5e760c354f1a7f33e6d (patch) | |
tree | 997356707af3f850d8974c328e2dfcd0ae471b2a | |
parent | Moving objectio tests (diff) |
ctoclean
-rw-r--r-- | ctoclean/.gitignore | 2 | ||||
-rw-r--r-- | ctoclean/Makefile | 13 | ||||
-rw-r--r-- | ctoclean/call.c | 10 | ||||
-rw-r--r-- | ctoclean/square.dcl | 5 | ||||
-rw-r--r-- | ctoclean/square.icl | 15 |
5 files changed, 45 insertions, 0 deletions
diff --git a/ctoclean/.gitignore b/ctoclean/.gitignore new file mode 100644 index 0000000..886dd19 --- /dev/null +++ b/ctoclean/.gitignore @@ -0,0 +1,2 @@ +square + diff --git a/ctoclean/Makefile b/ctoclean/Makefile new file mode 100644 index 0000000..7c7047a --- /dev/null +++ b/ctoclean/Makefile @@ -0,0 +1,13 @@ +all: + mkdir -p Clean\ System\ Files + $(CC) -c call.c -o Clean\ System\ Files/call.o + clm square -o square + +run: + ./square + +clean: + rm -rf Clean\ System\ Files square + +.PHONY: clean + diff --git a/ctoclean/call.c b/ctoclean/call.c new file mode 100644 index 0000000..be5fe48 --- /dev/null +++ b/ctoclean/call.c @@ -0,0 +1,10 @@ +#include <inttypes.h> +#include <stdio.h> + +extern int64_t square(int64_t); + +int64_t call_square(int64_t); +int64_t call_square(int64_t x) { + return square(x); +} + diff --git a/ctoclean/square.dcl b/ctoclean/square.dcl new file mode 100644 index 0000000..ea9aaa2 --- /dev/null +++ b/ctoclean/square.dcl @@ -0,0 +1,5 @@ +definition module square + +square :: !Int -> Int +call_square :: !Int -> Int + diff --git a/ctoclean/square.icl b/ctoclean/square.icl new file mode 100644 index 0000000..3fd9723 --- /dev/null +++ b/ctoclean/square.icl @@ -0,0 +1,15 @@ +implementation module square + +import StdEnv + +foreign export square +square :: !Int -> Int +square x = x * x + +call_square :: !Int -> Int +call_square x = code { + ccall square "GI:I" +}; + +Start = map call_square [1..10] + |