diff options
author | Camil Staps | 2015-07-06 21:08:19 +0200 |
---|---|---|
committer | Camil Staps | 2015-07-06 21:08:19 +0200 |
commit | e9a5416cecf3d48925a0a17ce9b2a1f9569bbecb (patch) | |
tree | 31e1907b35e5fe02cb4b2c044b4ecae7bdb93214 | |
parent | Remove binary (diff) |
Test tuple
-rw-r--r-- | test_tuple/.gitignore | 5 | ||||
-rw-r--r-- | test_tuple/Clean.h | 43 | ||||
-rw-r--r-- | test_tuple/Makefile | 6 | ||||
-rw-r--r-- | test_tuple/test.icl | 6 | ||||
-rw-r--r-- | test_tuple/test_tuple.c | 7 | ||||
-rw-r--r-- | test_tuple/test_tuple.h | 3 |
6 files changed, 70 insertions, 0 deletions
diff --git a/test_tuple/.gitignore b/test_tuple/.gitignore new file mode 100644 index 0000000..5a19750 --- /dev/null +++ b/test_tuple/.gitignore @@ -0,0 +1,5 @@ +Clean System Files +*.o +test_tuple.dcl +test_tuple.icl +test diff --git a/test_tuple/Clean.h b/test_tuple/Clean.h new file mode 100644 index 0000000..8008e00 --- /dev/null +++ b/test_tuple/Clean.h @@ -0,0 +1,43 @@ +#define Clean(a) + +typedef struct clean_string *CleanString; + +/* a string in Clean is: + struct clean_string { + int clean_string_length; + char clean_string_characters[clean_string_length]; + }; + The string does not end with a '\0' ! +*/ + +/* CleanStringLength(clean_string) returns the length of the clean_string in characters */ +#define CleanStringLength(clean_string) (*(unsigned int *)(clean_string)) + +/* CleanStringCharacters(clean_string) returns a pointer to the characters of the clean_string */ +#define CleanStringCharacters(clean_string) ((char*)(1+(unsigned int *)(clean_string))) + +/* CleanStringSizeInts(string_length) return size of *CleanString in integers */ +#define CleanStringSizeInts(string_length) (1+(((unsigned int)(string_length)+3)>>2)) + +/* CleanStringVariable(clean_string,string_length) defines variable clean_string with length string_length, + before using the clean_string variable, cast to CleanString, except for the macros above */ +#define CleanStringVariable(clean_string,string_length) unsigned int clean_string[CleanStringSizeInts(string_length)] + +/* CleanStringSizeBytes(string_length) return size of *CleanString in bytes */ +#define CleanStringSizeBytes(string_length) (4+(((unsigned int)(string_length)+3) & -4)) + +typedef int *CleanIntArray; + +/* CleanIntArraySize(clean_array) returns the size (number of elements) of the clean_int_array */ +#define CleanIntArraySize(clean_int_array) (((unsigned int *)(clean_int_array))[-2]) + +typedef double *CleanRealArray; + +/* CleanRealArraySize(clean_real_array) returns the size (number of elements) of the clean_real_array */ +#define CleanRealArraySize(clean_real_array) (((unsigned int *)(clean_real_array))[-2]) + +typedef unsigned char *CleanCharArray; + +/* CleanCharArraySize(clean_char_array) returns the size (number of elements) of the clean_char_array */ +#define CleanCharArraySize(clean_char_array) (((unsigned int *)(clean_char_array))[-1]) + diff --git a/test_tuple/Makefile b/test_tuple/Makefile new file mode 100644 index 0000000..ef630b9 --- /dev/null +++ b/test_tuple/Makefile @@ -0,0 +1,6 @@ +all: + cc -O -c test_tuple.c + clm -l test_tuple.o test -o test + +run: + ./test diff --git a/test_tuple/test.icl b/test_tuple/test.icl new file mode 100644 index 0000000..5a2a0d3 --- /dev/null +++ b/test_tuple/test.icl @@ -0,0 +1,6 @@ +module test + +import StdEnv, test_tuple + +Start = f (5,15) + diff --git a/test_tuple/test_tuple.c b/test_tuple/test_tuple.c new file mode 100644 index 0000000..94a5543 --- /dev/null +++ b/test_tuple/test_tuple.c @@ -0,0 +1,7 @@ +#include "Clean.h" +#include "test_tuple.h" + +int f (int e1, int e2) { + return e1 ^ e2; +} + diff --git a/test_tuple/test_tuple.h b/test_tuple/test_tuple.h new file mode 100644 index 0000000..f681447 --- /dev/null +++ b/test_tuple/test_tuple.h @@ -0,0 +1,3 @@ +int f(int e1, int e2); +Clean(f :: (Int,Int) -> Int) + |