diff options
author | Jason Sams <rjsams@android.com> | 2010-09-01 12:33:06 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-09-01 12:33:06 -0700 |
commit | 54adc5e8a1a4b43c67b8ae657453b5009e981b47 (patch) | |
tree | 267c3ecba871d6f005337bf5e8de37e115f4d602 /libacc/tests/data | |
parent | 4358544a3ffde4ffd1e9434b99b2a7179f05cce4 (diff) | |
download | system_core-54adc5e8a1a4b43c67b8ae657453b5009e981b47.zip system_core-54adc5e8a1a4b43c67b8ae657453b5009e981b47.tar.gz system_core-54adc5e8a1a4b43c67b8ae657453b5009e981b47.tar.bz2 |
Remove ACC which has been replaced with llvm.
Free up space in build.
Change-Id: Ic5cc48bacca47b45809b9bc649ae5b629b7427ed
Diffstat (limited to 'libacc/tests/data')
42 files changed, 0 insertions, 2712 deletions
diff --git a/libacc/tests/data/addressOf.c b/libacc/tests/data/addressOf.c deleted file mode 100644 index e7acde5..0000000 --- a/libacc/tests/data/addressOf.c +++ /dev/null @@ -1,31 +0,0 @@ -void testStruct() { - struct str { - float x; - float y; - }; - - struct str base; - int index = 0; - - base.x = 10.0; - struct str *s = &base; - - float *v = &(*s).x; - float *v2 = &s[index].x; - printf("testStruct: %g %g %g\n",base.x, *v, *v2); -} - -void testArray() { - int a[2]; - a[0] = 1; - a[1] = 2; - int* p = &a[0]; - int* p2 = a; - printf("testArray: %d %d %d\n", a[0], *p, *p2); -} - -int main() { - testStruct(); - testArray(); - return 0; -} diff --git a/libacc/tests/data/array.c b/libacc/tests/data/array.c deleted file mode 100644 index ca4a728..0000000 --- a/libacc/tests/data/array.c +++ /dev/null @@ -1,107 +0,0 @@ -// Array allocation tests - -void testLocalInt() -{ - int a[3]; - a[0] = 1; - a[1] = 2; - a[2] = a[0] + a[1]; - printf("localInt: %d\n", a[2]); -} - -char a[3]; -double d[3]; - -void testGlobalChar() -{ - a[0] = 1; - a[1] = 2; - a[2] = a[0] + a[1]; - printf("globalChar: %d\n", a[2]); -} - -void testGlobalDouble() -{ - d[0] = 1; - d[1] = 2; - d[2] = d[0] + d[1]; - printf("globalDouble: %g\n", d[2]); -} - -void testLocalDouble() -{ - double d[3]; - float m[12]; - m[0] = 1.0f; - m[1] = 2.0f; - d[0] = 1.0; - d[1] = 2.0; - d[2] = d[0] + d[1]; - m[2] = m[0] + m[1]; - printf("localDouble: %g %g\n", d[2], m[2]); -} - -void vectorAdd(int* a, int* b, float* c, int len) { - int i; - for(i = 0; i < len; i++) { - c[i] = a[i] + b[i]; - } -} - -void testArgs() { - int a[3], b[3]; - float c[3]; - int i; - int len = 3; - for(i = 0; i < len; i++) { - a[i] = i; - b[i] = i; - c[i] = 0; - } - vectorAdd(a,b,c, len); - printf("testArgs:"); - for(i = 0; i < len; i++) { - printf(" %g", c[i]); - } - printf("\n"); -} - -void testDecay() { - char c[4]; - c[0] = 'H'; - c[1] = 'i'; - c[2] = '!'; - c[3] = 0; - printf("testDecay: %s\n", c); -} - -void test2D() { - char c[10][20]; - int x; - int y; - printf("test2D:\n"); - for(y = 0; y < 10; y++) { - for(x = 0; x < 20; x++) { - c[y][x] = 'a' + (15 & (y * 19 + x)); - } - } - for(y = 0; y < 10; y++) { - for(x = 0; x < 20; x++) { - printf("%c", c[y][x]); - } - printf("\n"); - } - -} - -int main() -{ - testLocalInt(); - testLocalDouble(); - testGlobalChar(); - testGlobalDouble(); - testArgs(); - testDecay(); - test2D(); - return 0; -} diff --git a/libacc/tests/data/assignment.c b/libacc/tests/data/assignment.c deleted file mode 100644 index 4fc7801..0000000 --- a/libacc/tests/data/assignment.c +++ /dev/null @@ -1,9 +0,0 @@ -int main() { - int a = 0; - int b = 1; - a = b = 2; // Test that "b = 2" generates an rvalue. - if (a = 7) { // Test that a = 7 generates an rvalue. - b = 3; - } - return a; -} diff --git a/libacc/tests/data/assignmentop.c b/libacc/tests/data/assignmentop.c deleted file mode 100644 index 649edf9..0000000 --- a/libacc/tests/data/assignmentop.c +++ /dev/null @@ -1,62 +0,0 @@ -// Test assignment operations - -void testAssignment() { - int a = 2; - a *= 5; - printf("2 *= 5 %d\n", a); - a = 20; - a /= 5; - printf("20 /= 5 %d\n", a); - a = 17; - a %= 5; - printf("17 %%= 5 %d\n", a); - a = 17; - a += 5; - printf("17 += 5 %d\n", a); - a = 17; - a-=5; - printf("17 -= 5 %d\n", a); - a = 17; - a<<=1; - printf("17<<= 1 %d\n", a); - a = 17; - a>>=1; - printf("17>>= 1 %d\n", a); - a = 17; - a&=1; - printf("17&= 1 %d\n", a); - a = 17; - a^=1; - printf("17^= 1 %d\n", a); - a = 16; - a^=1; - printf("16|= 1 %d\n", a); -} - -int a; - -int* f() { - printf("f()\n"); - return &a; -} - -void testEval() { - a = 0; - printf("*f() = *f() + 10;\n"); - *f() = *f() + 10; - printf("a = %d\n", a); -} - -void testOpEval() { - a = 0; - printf("*f() += 10;\n"); - *f() += 10; - printf("a = %d\n", a); -} - -int main() { - testAssignment(); - testEval(); - testOpEval(); - return 0; -} diff --git a/libacc/tests/data/b2071670.c b/libacc/tests/data/b2071670.c deleted file mode 100644 index 311bc4f..0000000 --- a/libacc/tests/data/b2071670.c +++ /dev/null @@ -1,9 +0,0 @@ -// See http://b/2071670 - -int main() { - float f = 10.0f; - float* floatPointer = &f; - // The following line used to incorrectly error: "Incompatible pointer or array types" - int* buffer = (int*) floatPointer; - return *buffer; -} diff --git a/libacc/tests/data/bellard.otccex.c b/libacc/tests/data/bellard.otccex.c deleted file mode 100644 index e8f0989..0000000 --- a/libacc/tests/data/bellard.otccex.c +++ /dev/null @@ -1,126 +0,0 @@ -/* #!/usr/local/bin/otcc */ -/* - * Sample OTCC C example. You can uncomment the first line and install - * otcc in /usr/local/bin to make otcc scripts ! - */ - -/* Any preprocessor directive except #define are ignored. We put this - include so that a standard C compiler can compile this code too. */ -#include <stdio.h> - -/* defines are handled, but macro arguments cannot be given. No - recursive defines are tolerated */ -#define DEFAULT_BASE 10 - -/* - * Only old style K&R prototypes are parsed. Only int arguments are - * allowed (implicit types). - * - * By benchmarking the execution time of this function (for example - * for fib(35)), you'll notice that OTCC is quite fast because it - * generates native i386 machine code. - */ -fib(n) -{ - if (n <= 2) - return 1; - else - return fib(n-1) + fib(n-2); -} - -/* Identifiers are parsed the same way as C: begins with letter or - '_', and then letters, '_' or digits */ -fact(n) -{ - /* local variables can be declared. Only 'int' type is supported */ - int i, r; - r = 1; - /* 'while' and 'for' loops are supported */ - for(i=2;i<=n;i++) - r = r * i; - return r; -} - -/* Well, we could use printf, but it would be too easy */ -print_num(n, b) -{ - int tab, p, c; - /* Numbers can be entered in decimal, hexadecimal ('0x' prefix) and - octal ('0' prefix) */ - /* more complex programs use malloc */ - tab = malloc(0x100); - p = tab; - while (1) { - c = n % b; - /* Character constants can be used */ - if (c >= 10) - c = c + 'a' - 10; - else - c = c + '0'; - *(char *)p = c; - p++; - n = n / b; - /* 'break' is supported */ - if (n == 0) - break; - } - while (p != tab) { - p--; - printf("%c", *(char *)p); - } - free(tab); -} - -/* 'main' takes standard 'argc' and 'argv' parameters */ -main(argc, argv) -{ - /* no local name space is supported, but local variables ARE - supported. As long as you do not use a globally defined - variable name as local variable (which is a bad habbit), you - won't have any problem */ - int s, n, f, base; - - /* && and || operator have the same semantics as C (left to right - evaluation and early exit) */ - if (argc != 2 && argc != 3) { - /* '*' operator is supported with explicit casting to 'int *', - 'char *' or 'int (*)()' (function pointer). Of course, 'int' - are supposed to be used as pointers too. */ - s = *(int *)argv; - help(s); - return 1; - } - /* Any libc function can be used because OTCC uses dynamic linking */ - n = atoi(*(int *)(argv + 4)); - base = DEFAULT_BASE; - if (argc >= 3) { - base = atoi(*(int *)(argv + 8)); - if (base < 2 || base > 36) { - /* external variables can be used too (here: 'stderr') */ - fprintf(stderr, "Invalid base\n"); - return 1; - } - } - printf("fib(%d) = ", n); - print_num(fib(n), base); - printf("\n"); - - printf("fact(%d) = ", n); - if (n > 12) { - printf("Overflow"); - } else { - /* why not using a function pointer ? */ - f = &fact; - print_num((*(int (*)())f)(n), base); - } - printf("\n"); - return 0; -} - -/* functions can be used before being defined */ -help(name) -{ - printf("usage: %s n [base]\n", name); - printf("Compute fib(n) and fact(n) and output the result in base 'base'\n"); -} - diff --git a/libacc/tests/data/brackets.c b/libacc/tests/data/brackets.c deleted file mode 100644 index bab88a2..0000000 --- a/libacc/tests/data/brackets.c +++ /dev/null @@ -1,61 +0,0 @@ -void testBrackets(int* ar, int len) { - int i; - int errors = 0; - for (i = 0; i < len; i++) { - ar[i] = i; - } - for (i = 0; i < len; i++) { - if (ar[i] != i) { - printf("error: [%d] %d != %d\n", i, ar[i], i); - errors++; - } - } - printf("Errors: %d\n", errors); -} - -void testBrackets2D(int** ar2D, int lenX, int lenY) { - int x, y; - int errors = 0; - for (x = 0; x < lenX; x++) { - for (y = 0; y < lenY; y++) { - ar2D[x][y] = x * lenY + y; - } - } - for (x = 0; x < lenX; x++) { - for (y = 0; y < lenY; y++) { - int expected = x * lenY + y; - int val = ar2D[x][y]; - if (val != expected) { - printf("error: [%d][%d] %d != %d\n", x, y, val, expected); - errors++; - } - } - } - printf("2D Errors: %d\n", errors); -} - -void testHeap() { - int* ar = (int*) malloc(100); - testBrackets(ar, 25); - free(ar); -} - -void testHeap2D() { - int lenX = 10; - int lenY = 5; - int* ar = (int*) malloc(lenX * lenY * 4); - int** ar2D = (int**) malloc(lenX * 4); - int i; - for(i = 0; i < lenX; i++) { - ar2D[i] = ar + lenY * i; - } - testBrackets2D(ar2D, lenX, lenY); - free(ar); - free(ar2D); -} - -int main() { - testHeap(); - testHeap2D(); - return 0; -} diff --git a/libacc/tests/data/casts.c b/libacc/tests/data/casts.c deleted file mode 100644 index d3a49b4..0000000 --- a/libacc/tests/data/casts.c +++ /dev/null @@ -1,85 +0,0 @@ -void test1() { - int a = 3; - int* pb = &a; - int c = *pb; - printf("Reading from a pointer: %d %d\n", a, c); - *pb = 4; - printf("Writing to a pointer: %d\n", a); - printf("Testing casts: %d %g %g %d\n", 3, (float) 3, 4.5, (int) 4.5); -} - -void test2() { - int x = 4; - int px = &x; - // int z = * px; // An error, expected a pointer type - int y = * (int*) px; - printf("Testing reading (int*): %d\n", y); -} - -void test3() { - int px = (int) malloc(120); - * (int*) px = 8; - * (int*) (px + 4) = 9; - printf("Testing writing (int*): %d %d\n", * (int*) px, * (int*) (px + 4)); - free((void*) px); -} - -void test4() { - int x = 0x12345678; - int px = &x; - int a = * (char*) px; - int b = * (char*) (px + 1); - int c = * (char*) (px + 2); - int d = * (char*) (px + 3); - printf("Testing reading (char*): 0x%02x 0x%02x 0x%02x 0x%02x\n", a, b, c, d); -} - -void test5() { - int x = 0xFFFFFFFF; - int px = &x; - * (char*) px = 0x21; - * (char*) (px + 1) = 0x43; - * (char*) (px + 2) = 0x65; - * (char*) (px + 3) = 0x87; - printf("Testing writing (char*): 0x%08x\n", x); -} - -int f(int b) { - printf("f(%d)\n", b); - return 7 * b; -} - -void test6() { - int fp = &f; - int x = (*(int(*)()) fp)(10); - printf("Function pointer result: %d\n", x); -} - -void test7() { - int px = (int) malloc(120); - * (float*) px = 8.8f; - * (float*) (px + 4) = 9.9f; - printf("Testing read/write (float*): %g %g\n", * (float*) px, * (float*) (px + 4)); - free((void*) px); -} - -void test8() { - int px = (int) malloc(120); - * (double*) px = 8.8; - * (double*) (px + 8) = 9.9; - printf("Testing read/write (double*): %g %g\n", * (double*) px, * (double*) (px + 8)); - free((void*) px); -} - - -int main() { - test1(); - test2(); - test3(); - test4(); - test5(); - test6(); - test7(); - test8(); - return 0; -} diff --git a/libacc/tests/data/char.c b/libacc/tests/data/char.c deleted file mode 100644 index 8c63ba2..0000000 --- a/libacc/tests/data/char.c +++ /dev/null @@ -1,13 +0,0 @@ -char ga; -char gb; - -int main() { - char a = 'c'; - char b = a * 3; - printf("a = %d, b = %d\n", a, b); - ga = 'd'; - gb = ga * 3; - printf("ga = %d, gb = %d\n", ga, gb); - return 0; -} - diff --git a/libacc/tests/data/comma.c b/libacc/tests/data/comma.c deleted file mode 100644 index 496944c..0000000 --- a/libacc/tests/data/comma.c +++ /dev/null @@ -1,35 +0,0 @@ -int testReturn() { - return 10, 20, 30; -} - -int testArg(int a) { - return a; -} - -void testComma() { - int a; - 0, a = 10,20; - printf("statement: %d\n", a); - a = 1; - if (a = 0, 1) { - printf("if: a = %d\n", a); - } - int b = 0; - a = 10; - while(b++,a--) {} - printf("while: b = %d\n", b); - b = 0; - for(b++,a = 0;b++, a < 10; b++, a++) {} - printf("for: b = %d\n", b); - b = testReturn(); - printf("return: %d\n", b); - b = testArg((a,12)); - printf("arg: %d\n", b); -} - - - -int main() { - testComma(); - return 0; -} diff --git a/libacc/tests/data/constants.c b/libacc/tests/data/constants.c deleted file mode 100644 index 230109a..0000000 --- a/libacc/tests/data/constants.c +++ /dev/null @@ -1,30 +0,0 @@ -#define FOO 0x10 - -int main() { - printf("0 = %d\n", 0); - printf("010 = %d\n", 010); - printf("0x10 = %d\n", FOO); - printf("'\\a' = %d\n", '\a'); - printf("'\\b' = %d\n", '\b'); - printf("'\\f' = %d\n", '\f'); - printf("'\\n' = %d\n", '\n'); - printf("'\\r' = %d\n", '\r'); - printf("'\\t' = %d\n", '\t'); - printf("'\\v' = %d\n", '\v'); - // Undefined - // printf("'\\z' = %d\n", '\z'); - printf("'\\\\' = %d\n", '\\'); - printf("'\\'' = %d\n", '\''); - printf("'\\\"' = %d\n", '\"'); - printf("'\\?' = %d\n", '\?'); - printf("'\\0' = %d\n", '\0'); - printf("'\\1' = %d\n", '\1'); - printf("'\\12' = %d\n", '\12'); - printf("'\\123' = %d\n", '\123'); - printf("'\\x0' = %d\n", '\x0'); - printf("'\\x1' = %d\n", '\x1'); - printf("'\\x12' = %d\n", '\x12'); - printf("'\\x123' = %d\n", '\x123'); - printf("'\\x1f' = %d\n", '\x1f'); - printf("'\\x1F' = %d\n", '\x1F'); -} diff --git a/libacc/tests/data/continue.c b/libacc/tests/data/continue.c deleted file mode 100644 index d8b8e36..0000000 --- a/libacc/tests/data/continue.c +++ /dev/null @@ -1,13 +0,0 @@ -int main() { - int i, j, sum; - sum = 0; - for (i = 0; i < 10; i++) { - if (i & 1) continue; - for (j = 0; j < 10; j++) { - if (j & 1) continue; - sum += i * j; - } - } - return sum; -} - diff --git a/libacc/tests/data/defines.c b/libacc/tests/data/defines.c deleted file mode 100644 index 6cb6f7e..0000000 --- a/libacc/tests/data/defines.c +++ /dev/null @@ -1,9 +0,0 @@ -// Simple tests of the C preprocessor - -#define A 1 -#define A (4 / 2) -#define B 1 // This is a comment. With a / in it. - -int main() { - return A + B; -} diff --git a/libacc/tests/data/double.c b/libacc/tests/data/double.c deleted file mode 100644 index 5bc20a3..0000000 --- a/libacc/tests/data/double.c +++ /dev/null @@ -1,7 +0,0 @@ -double atof(char *nptr); - -int main() { - printf("Value = %g\n", atof("10.42")); - return 0; -} - diff --git a/libacc/tests/data/error.c b/libacc/tests/data/error.c deleted file mode 100644 index 2e08dcc..0000000 --- a/libacc/tests/data/error.c +++ /dev/null @@ -1,2 +0,0 @@ -void foo; - diff --git a/libacc/tests/data/expr-ansi.c b/libacc/tests/data/expr-ansi.c deleted file mode 100644 index d463659..0000000 --- a/libacc/tests/data/expr-ansi.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Test operators */ - -void testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); } -void testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); } -void testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); } -void testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); } -void testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); } -void testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); } -void testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); } -void testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); } -void testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); } -void testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); } -void testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); } -void testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); } -void testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); } -void testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); } -void testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); } -void testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); } -void testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); } -void testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); } -void testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); } -void testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); } -void testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); } -void testAddressOf(){ int a; printf("&a is %d\n", &a); } -void testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d = %d =?= %d\n", a, * (int*) a, b); } -void testNegation(){ printf("-%d = %d\n", 10, -10); } -void testUnaryPlus(){ printf("+%d = %d\n", 10, +10); } -void testUnaryNot(){ printf("!%d = %d\n", 10, !10); } -void testBitNot(){ printf("~%d = %d\n", 10, ~10); } - -int main(int a, char** b) { - testInc(); - testDec(); - testTimes(); - testDiv(); - testMod(); - testPlus(); - testMinus(); - testShiftLeft(); - testShiftRight(); - testLess(); - testLesEqual(); - testGreater(); - testGreaterEqual(); - testEqualTo(); - testNotEqualTo(); - testBitAnd(); - testBinXor(); - testBitOr(); - testAssignment(); - testLogicalAnd(); - testLogicalOr(); - testAddressOf(); - testPointerIndirection(); - testNegation(); - testUnaryPlus(); - testUnaryNot(); - testBitNot(); - return 0; -} diff --git a/libacc/tests/data/expr.c b/libacc/tests/data/expr.c deleted file mode 100644 index 4f2d2e7..0000000 --- a/libacc/tests/data/expr.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Test operators */ - -testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); } -testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); } -testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); } -testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); } -testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); } -testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); } -testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); } -testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); } -testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); } -testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); } -testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); } -testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); } -testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); } -testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); } -testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); } -testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); } -testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); } -testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); } -testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); } -testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); } -testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); } -testAddressOf(){ int a; printf("&a is %d\n", &a); } -testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d = %d =?= %d\n", a, * (int*) a, b); } -testNegation(){ printf("-%d = %d\n", 10, -10); } -testUnaryPlus(){ printf("+%d = %d\n", 10, +10); } -testUnaryNot(){ printf("!%d = %d\n", 10, !10); } -testBitNot(){ printf("~%d = %d\n", 10, ~10); } - -main(a,b) { - testInc(); - testDec(); - testTimes(); - testDiv(); - testMod(); - testPlus(); - testMinus(); - testShiftLeft(); - testShiftRight(); - testLess(); - testLesEqual(); - testGreater(); - testGreaterEqual(); - testEqualTo(); - testNotEqualTo(); - testBitAnd(); - testBinXor(); - testBitOr(); - testAssignment(); - testLogicalAnd(); - testLogicalOr(); - testAddressOf(); - testPointerIndirection(); - testNegation(); - testUnaryPlus(); - testUnaryNot(); - testBitNot(); - return 0; -}
\ No newline at end of file diff --git a/libacc/tests/data/expr2.c b/libacc/tests/data/expr2.c deleted file mode 100644 index 04b6a38..0000000 --- a/libacc/tests/data/expr2.c +++ /dev/null @@ -1,6 +0,0 @@ -/* Test operators */ - -main() { - int a; - a = a++; -} diff --git a/libacc/tests/data/film.c b/libacc/tests/data/film.c deleted file mode 100644 index 00c2d36..0000000 --- a/libacc/tests/data/film.c +++ /dev/null @@ -1,53 +0,0 @@ -// Test logical and bitwise AND and OR - -int test(int x, int y) { - int v = x || y; - return v; -} - -int test2(int x, int y) { - if(x | y) { - return 1; - } else { - return 0; - } -} - -int test3(int x, int y) { - int v = x && y; - return v; -} - -int test4(int x, int y) { - if(x & y) { - return 1; - } else { - return 0; - } -} - -int main(int index) -{ - int x,y; - printf("testing...\n"); - int totalBad = 0; - for(y = 0; y < 2; y++) { - for(x = 0; x < 2; x++) { - int a = test(x,y); - int b = test2(x,y); - if (a != b) { - printf("Results differ: OR x=%d y=%d a=%d b=%d\n", x, y, a, b); - totalBad++; - } - a = test3(x,y); - b = test4(x,y); - if (a != b) { - printf("Results differ: AND x=%d y=%d a=%d b=%d\n", x, y, a, b); - totalBad++; - } - } - } - printf("Total bad: %d\n", totalBad); - return 0; -} - diff --git a/libacc/tests/data/float.c b/libacc/tests/data/float.c deleted file mode 100644 index f48b3d1..0000000 --- a/libacc/tests/data/float.c +++ /dev/null @@ -1,57 +0,0 @@ -int ftoi(float f) { - return f; -} - -int dtoi(double d) { - return d; -} - -float itof(int i) { - return i; -} - -double itod(int i) { - return i; -} - -float f0, f1; -double d0, d1; - -void testParseConsts() { - printf("Constants: %g %g %g %g %g %g %g %g %g\n", 0e1, 0E1, 0.f, .01f, - .01e0f, 1.0e-1, 1.0e1, 1.0e+1, - .1f); -} -void testVars(float arg0, float arg1, double arg2, double arg3) { - float local0, local1; - double local2, local3; - f0 = arg0; - f1 = arg1; - d0 = arg2; - d1 = arg3; - local0 = arg0; - local1 = arg1; - local2 = arg2; - local3 = arg3; - printf("globals: %g %g %g %g\n", f0, f1, d0, d1); - printf("args: %g %g %g %g\n", arg0, arg1, arg2, arg3); - printf("locals: %g %g %g %g\n", local0, local1, local2, local3); - - - printf("cast rval: %g %g\n", * (float*) & f1, * (double*) & d1); - - * (float*) & f0 = 1.1f; - * (double*) & d0 = 3.3; - printf("cast lval: %g %g %g %g\n", f0, f1, d0, d1); -} - -int main() { - testParseConsts(); - printf("int: %d float: %g double: %g\n", 1, 2.2f, 3.3); - printf(" ftoi(1.4f)=%d\n", ftoi(1.4f)); - printf(" dtoi(2.4)=%d\n", dtoi(2.4)); - printf(" itof(3)=%g\n", itof(3)); - printf(" itod(4)=%g\n", itod(4)); - testVars(1.0f, 2.0f, 3.0, 4.0); - return 0; -} diff --git a/libacc/tests/data/floatdouble.c b/libacc/tests/data/floatdouble.c deleted file mode 100644 index 264c641..0000000 --- a/libacc/tests/data/floatdouble.c +++ /dev/null @@ -1,9 +0,0 @@ -int main() -{ - // Test coercing values when storing. - float a = 0.002; - double b = 0.1f; - int c = 10.002; - printf("%g %g %d\n", a, b, c); - return 0; -} diff --git a/libacc/tests/data/flops.c b/libacc/tests/data/flops.c deleted file mode 100644 index 40b1b28..0000000 --- a/libacc/tests/data/flops.c +++ /dev/null @@ -1,158 +0,0 @@ -// Test floating point operations. - -void unaryOps() { - // Unary ops - printf("-%g = %g\n", 1.1, -1.1); - printf("!%g = %d\n", 1.2, !1.2); - printf("!%g = %d\n", 0.0, !0.0); -} - -void binaryOps() { - printf("double op double:\n"); - printf("%g + %g = %g\n", 1.0, 2.0, 1.0 + 2.0); - printf("%g - %g = %g\n", 1.0, 2.0, 1.0 - 2.0); - printf("%g * %g = %g\n", 1.0, 2.0, 1.0 * 2.0); - printf("%g / %g = %g\n", 1.0, 2.0, 1.0 / 2.0); - - printf("float op float:\n"); - printf("%g + %g = %g\n", 1.0f, 2.0f, 1.0f + 2.0f); - printf("%g - %g = %g\n", 1.0f, 2.0f, 1.0f - 2.0f); - printf("%g * %g = %g\n", 1.0f, 2.0f, 1.0f * 2.0f); - printf("%g / %g = %g\n", 1.0f, 2.0f, 1.0f / 2.0f); - - printf("double op float:\n"); - printf("%g + %g = %g\n", 1.0, 2.0f, 1.0 + 2.0f); - printf("%g - %g = %g\n", 1.0, 2.0f, 1.0 - 2.0f); - printf("%g * %g = %g\n", 1.0, 2.0f, 1.0 * 2.0f); - printf("%g / %g = %g\n", 1.0, 2.0f, 1.0 / 2.0f); - - printf("double op int:\n"); - printf("%g + %d = %g\n", 1.0, 2, 1.0 + 2); - printf("%g - %d = %g\n", 1.0, 2, 1.0 - 2); - printf("%g * %d = %g\n", 1.0, 2, 1.0 * 2); - printf("%g / %d = %g\n", 1.0, 2, 1.0 / 2); - - printf("int op double:\n"); - printf("%d + %g = %g\n", 1, 2.0, 1 + 2.0); - printf("%d - %g = %g\n", 1, 2.0, 1 - 2.0); - printf("%d * %g = %g\n", 1, 2.0, 1 * 2.0); - printf("%d / %g = %g\n", 1, 2.0, 1 / 2.0); -} - -void comparisonTestdd(double a, double b) { - printf("%g op %g: < %d <= %d == %d >= %d > %d != %d\n", - a, b, a < b, a <= b, a == b, a >= b, a > b, a != b); -} - -void comparisonOpsdd() { - printf("double op double:\n"); - comparisonTestdd(1.0, 2.0); - comparisonTestdd(1.0, 1.0); - comparisonTestdd(2.0, 1.0); -} - - -void comparisonTestdf(double a, float b) { - printf("%g op %g: < %d <= %d == %d >= %d > %d != %d\n", - a, b, a < b, a <= b, a == b, a >= b, a > b, a != b); -} - -void comparisonOpsdf() { - printf("double op float:\n"); - comparisonTestdf(1.0, 2.0f); - comparisonTestdf(1.0, 1.0f); - comparisonTestdf(2.0, 1.0f); -} - -void comparisonTestff(float a, float b) { - printf("%g op %g: < %d <= %d == %d >= %d > %d != %d\n", - a, b, a < b, a <= b, a == b, a >= b, a > b, a != b); -} - -void comparisonOpsff() { - printf("float op float:\n"); - comparisonTestff(1.0f, 2.0f); - comparisonTestff(1.0f, 1.0f); - comparisonTestff(2.0f, 1.0f); -} - -void comparisonTestid(int a, double b) { - printf("%d op %g: < %d <= %d == %d >= %d > %d != %d\n", - a, b, a < b, a <= b, a == b, a >= b, a > b, a != b); -} - -void comparisonOpsid() { - printf("int op double:\n"); - comparisonTestid(1, 2.0); - comparisonTestid(1, 1.0); - comparisonTestid(2, 1.0); -} -void comparisonTestdi(double a, int b) { - printf("%g op %d: < %d <= %d == %d >= %d > %d != %d\n", - a, b, a < b, a <= b, a == b, a >= b, a > b, a != b); -} - -void comparisonOpsdi() { - printf("double op int:\n"); - comparisonTestdi(1.0f, 2); - comparisonTestdi(1.0f, 1); - comparisonTestdi(2.0f, 1); -} - -void comparisonOps() { - comparisonOpsdd(); - comparisonOpsdf(); - comparisonOpsff(); - comparisonOpsid(); - comparisonOpsdi(); -} - -int branch(double d) { - if (d) { - return 1; - } - return 0; -} - -void testBranching() { - printf("branching: %d %d %d\n", branch(-1.0), branch(0.0), branch(1.0)); -} - -void testpassi(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) { - printf("testpassi: %d %d %d %d %d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h, i, j, k, l); -} - -void testpassf(float a, float b, float c, float d, float e, float f, float g, float h, float i, float j, float k, float l) { - printf("testpassf: %g %g %g %g %g %g %g %g %g %g %g %g\n", a, b, c, d, e, f, g, h, i, j, k, l); -} - -void testpassd(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k, double l) { - printf("testpassd: %g %g %g %g %g %g %g %g %g %g %g %g\n", a, b, c, d, e, f, g, h, i, j, k, l); -} - -void testpassidf(int i, double d, float f) { - printf("testpassidf: %d %g %g\n", i, d, f); -} - -void testParameterPassing() { - float x; - testpassi(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); - testpassf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); - testpassd(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); - testpassi(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f); - testpassf(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f); - testpassd(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f); - testpassi(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); - testpassf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); - testpassd(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); - testpassidf(1, 2.0, 3.0f); -} - -int main() { - unaryOps(); - binaryOps(); - comparisonOps(); - testBranching(); - testParameterPassing(); - return 0; -} diff --git a/libacc/tests/data/funcargs.c b/libacc/tests/data/funcargs.c deleted file mode 100644 index 1dce226..0000000 --- a/libacc/tests/data/funcargs.c +++ /dev/null @@ -1,8 +0,0 @@ -int f(int a,int, int c) { - return a + c; -} - -int main() { - return f(1,2,3); -} - diff --git a/libacc/tests/data/hello.c b/libacc/tests/data/hello.c deleted file mode 100644 index 585ce6c..0000000 --- a/libacc/tests/data/hello.c +++ /dev/null @@ -1,3 +0,0 @@ -main(a,b) { - printf("Hello, world\n"); -} diff --git a/libacc/tests/data/inc.c b/libacc/tests/data/inc.c deleted file mode 100644 index 14c09d1..0000000 --- a/libacc/tests/data/inc.c +++ /dev/null @@ -1,14 +0,0 @@ -// Check integer operations - -int main() { - int a = 0; - printf("%d\n", a++); - printf("%d\n", a++); - printf("%d\n", a--); - printf("%d\n", a--); - printf("%d\n", ++a); - printf("%d\n", ++a); - printf("%d\n", --a); - printf("%d\n", --a); - return a; -} diff --git a/libacc/tests/data/iops.c b/libacc/tests/data/iops.c deleted file mode 100644 index 780e95d..0000000 --- a/libacc/tests/data/iops.c +++ /dev/null @@ -1,23 +0,0 @@ -// Check integer operations - -void loops() { - int y; - printf("++\n"); - for(y = 0; y < 10; y++) { - printf("%d\n", y); - } - printf("--\n"); - for(y = 10; y >= 0; y--) { - printf("%d\n", y); - } -} - -void checkLiterals() { - printf("Literals: %d %d\n", 1, -1); -} - -int main() { - checkLiterals(); - loops(); - return 0; -} diff --git a/libacc/tests/data/locals.c b/libacc/tests/data/locals.c deleted file mode 100644 index f1ef363..0000000 --- a/libacc/tests/data/locals.c +++ /dev/null @@ -1,71 +0,0 @@ -int a; - -int f() { - int a; - // Undefined variable b - // printf("f 0: a = %d b = %d\n", a, b); - printf("f 0: a = %d\n", a); - a = 2; - printf("f 1: a = %d\n", a); -} - -int g(int a) { - printf("g 0: a = %d\n", a); - a = 3; - printf("g 1: a = %d\n", a); -} - -int h(int a) { - // int a; // gcc 4.3 says error: 'a' redeclared as different kind of symbol - - printf("h 0: a = %d\n", a); - a = 4; - printf("h 1: a = %d\n", a); -} - -// Already defined global -// int h() {} -int globCheck() { - fprintf(stdout, "globCheck()\n"); -} - -int fwdCheck() { - b(); - // Undefined forward reference - // c(); -} - -int b() { - printf("b()\n"); -} - -int nested() { - int a; - printf("nested 0: a = %d\n", a); - a = 50; - printf("nested 1: a = %d\n", a); - { - int a; - printf("nested 2: a = %d\n", a); - a = 51; - printf("nested 3: a = %d\n", a); - } - printf("nested 4: a = %d\n", a); -} - -int main() { - globCheck(); - fwdCheck(); - printf("main 0: a = %d\n", a); - a = 5; - printf("main 1: a = %d\n", a); - f(); - printf("main 2: a = %d\n", a); - g(77); - printf("main 3: a = %d\n", a); - h(30); - printf("main 4: a = %d\n", a); - nested(); - printf("main 5: a = %d\n", a); - return 0; -} diff --git a/libacc/tests/data/macros.c b/libacc/tests/data/macros.c deleted file mode 100644 index 50e54dc..0000000 --- a/libacc/tests/data/macros.c +++ /dev/null @@ -1,10 +0,0 @@ -#define A B + B -#define B C - -int main() { - int C = 3; - printf("A = %d\n", A); -#define C 5 - printf("A = %d\n", A); - return 0; -} diff --git a/libacc/tests/data/missing-main.c b/libacc/tests/data/missing-main.c deleted file mode 100644 index e73eec4..0000000 --- a/libacc/tests/data/missing-main.c +++ /dev/null @@ -1,4 +0,0 @@ -/* No main. */ - -a() { -}
\ No newline at end of file diff --git a/libacc/tests/data/otcc-ansi.c b/libacc/tests/data/otcc-ansi.c deleted file mode 100644 index 72580e9..0000000 --- a/libacc/tests/data/otcc-ansi.c +++ /dev/null @@ -1,466 +0,0 @@ -// #include <stdio.h> -int d, z, C, h, P, K, ac, q, G, v, Q, R, D, L, W, M; - -void E(int e) { - *(char*) D++ = e; -} - -void o() { - if (L) { - h = *(char*) L++; - if (h == 2) { - L = 0; - h = W; - } - } else - h = fgetc(Q); -} - -int X() { - return isalnum(h) | h == 95; -} - -void Y() { - if (h == 92) { - o(); - if (h == 110) - h = 10; - } -} - -void ad() { - int e, j, m; - while (isspace(h) | h == 35) { - if (h == 35) { - o(); - ad(); - if (d == 536) { - ad(); - E(32); - *(int*) d = 1; - *(int*) (d + 4) = D; - } - while (h != 10) { - E(h); - o(); - } - E(h); - E(2); - } - o(); - } - C = 0; - d = h; - if (X()) { - E(32); - M = D; - while (X()) { - E(h); - o(); - } - if (isdigit(d)) { - z = strtol(M, 0, 0); - d = 2; - } else { - *(char*) D = 32; - d = strstr(R, M - 1) - R; - *(char*) D = 0; - d = d * 8 + 256; - if (d > 536) { - d = P + d; - if (*(int*) d == 1) { - L = *(int*) (d + 4); - W = h; - o(); - ad(); - } - } - } - } else { - o(); - if (d == 39) { - d = 2; - Y(); - z = h; - o(); - o(); - } else if (d == 47 & h == 42) { - o(); - while (h) { - while (h != 42) - o(); - o(); - if (h == 47) - h = 0; - } - o(); - ad(); - } else { - e - = "++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b"; - while (j = *(char*) e++) { - m = *(char*) e++; - z = 0; - while ((C = *(char*) e++ - 98) < 0) - z = z * 64 + C + 64; - if (j == d & (m == h | m == 64)) { - if (m == h) { - o(); - d = 1; - } - break; - } - } - } - } -} - -void ae(int g) { - while( g&&g!=-1) { - *(char*) q++=g; - g=g>>8; - } -} - -void A(int e) { - int g; - while( e) { - g=*(int*) e; - *(int*) e=q-e-4; - e=g; - } -} - -int s(int g, int e) { - ae(g); - *(int*) q = e; - e = q; - q = q + 4; - return e; -} - -void H(int e) { - s(184,e); -} - -int B(int e) { - return s(233,e); -} - -int S(int j, int e) { - ae(1032325); - return s(132 + j, e); -} - -void Z(int e) { - ae( 49465); - H(0); - ae( 15); - ae( e+144); - ae( 192); -} - -void N(int j, int e) { - ae(j + 131); - s((e > -512 && e < 512) << 7 | 5, e); -} - -void T (int j) { - int g,e,m,aa; - g=1; - if( d == 34) { - H(v); - while( h!=34) { - Y (); - *(char*) v++=h; - o (); - } - *(char*) v=0; - v=v +4&-4; - o (); - ad(); - } - else { - aa=C; - m= z; - e=d; - ad(); - if( e == 2) { - H(m); - } - else if( aa == 2) { - T(0); - s(185,0); - if( e == 33)Z(m); - else ae( m); - } - else if( e == 40) { - w (); - ad(); - } - else if( e == 42) { - ad(); - e=d; - ad(); - ad(); - if( d == 42) { - ad(); - ad(); - ad(); - ad(); - e=0; - } - ad(); - T(0); - if( d == 61) { - ad(); - ae( 80); - w (); - ae( 89); - ae( 392+(e == 256)); - } - else if( e) { - if( e == 256)ae( 139); - else ae( 48655); - q++; - } - } - else if( e == 38) { - N(10,*(int*) d); - ad(); - } - else { - g=*(int*) e; - if(!g)g=dlsym(0,M); - if( d == 61&j) { - ad(); - w (); - N(6,g); - } - else if( d!= 40) { - N(8,g); - if( C == 11) { - N(0,g); - ae( z); - ad(); - } - } - } - } - if( d == 40) { - if( g == 1)ae( 80); - m= s(60545,0); - ad(); - j=0; - while( d!= 41) { - w (); - s(2393225,j); - if( d == 44)ad(); - j=j +4; - } - *(int*) m= j; - ad(); - if(!g) { - e=e +4; - *(int*) e=s(232,*(int*) e); - } - else if( g == 1) { - s(2397439,j); - j=j +4; - } - else { - s(232,g-q-5); - } - if( j)s(50305,j); - } -} - -void O (int j) { - int e,g,m; - if( j--== 1)T(1); - else { - O (j); - m= 0; - while( j == C) { - g=d; - e=z; - ad(); - if( j>8) { - m= S(e,m); - O (j); - } - else { - ae( 80); - O (j); - ae( 89); - if( j == 4|j == 5) { - Z(e); - } - else { - ae( e); - if( g == 37)ae( 146); - } - } - } - if( m&&j>8) { - m= S(e,m); - H(e^1); - B(5); - A(m); - H(e); - } - } -} - -void w() { - O(11); -} - -int U() { - w(); - return S(0, 0); -} - -void I (int j) { - int m,g,e; - if( d == 288) { - ad(); - ad(); - m= U (); - ad(); - I (j); - if( d == 312) { - ad(); - g=B(0); - A(m); - I (j); - A(g); - } - else { - A(m); - } - } - else if( d == 352|d == 504) { - e=d; - ad(); - ad(); - if( e == 352) { - g=q; - m= U (); - } - else { - if( d!= 59)w (); - ad(); - g=q; - m= 0; - if( d!= 59)m= U (); - ad(); - if( d!= 41) { - e=B(0); - w (); - B(g-q-5); - A(e); - g=e +4; - } - } - ad(); - I(&m); - B(g-q-5); - A(m); - } - else if( d == 123) { - ad(); - ab(1); - while( d!= 125)I (j); - ad(); - } - else { - if( d == 448) { - ad(); - if( d!= 59)w (); - K=B(K); - } - else if( d == 400) { - ad(); - *(int*) j=B(*(int*) j); - } - else if( d!= 59)w (); - ad(); - } -} - -void ab (int j) { - int m; - while( d == 256|d!=-1&!j) { - if( d == 256) { - ad(); - while( d!= 59) { - if( j) { - G=G +4; - *(int*) d=-G; - } - else { - *(int*) d=v; - v=v +4; - } - ad(); - if( d == 44)ad() ; - } - ad(); - } - else { - A(*(int*)(d +4)); - *(int*) d=q; - ad(); - ad(); - m= 8; - while( d!= 41) { - *(int*) d=m; - m= m +4; - ad(); - if( d == 44)ad(); - } - ad(); - K=G=0; - ae( 15042901); - m= s(60545,0); - I(0); - A(K); - ae( 50121); - *(int*) m= G; - } - } -} - -int run(int g, int e) { - return (*(int(*)()) *(int*) (P + 592))(g, e); -} - -int main(int g, int e) { - int result; - Q = stdin; - if (g-- > 1) { - e = e + 4; - Q = fopen(*(int*) e, "r"); - if (!Q) { - fprintf(stderr, "otcc-ansi.c: could not open file %s\n", *(int*) e); - return -2; - } - } - D = strcpy(R = calloc(1, 99999), " int if else while break return for define main ") + 48; - v = calloc(1, 99999); - q = ac = calloc(1, 99999); - P = calloc(1, 99999); - o(); - ad(); - ab(0); - if (mprotect(ac & (~ 4095), (99999 + 4095) & (~ 4095), 7)) { - printf("Mprotect failed. %d\n", errno); - return -1; - } - fprintf(stderr, "otcc-ansi.c: About to execute compiled code:\n"); - result = run(g, e); - fprintf(stderr, "atcc-ansi.c: result: %d\n", result); - return result; -} - diff --git a/libacc/tests/data/otcc-noinclude.c b/libacc/tests/data/otcc-noinclude.c deleted file mode 100644 index 530f9e2..0000000 --- a/libacc/tests/data/otcc-noinclude.c +++ /dev/null @@ -1,446 +0,0 @@ -// #include <stdio.h> -#define k *(int*) -#define a if( -#define c ad() -#define i else -#define p while( -#define x *(char*) -#define b == -#define V =calloc(1,99999) -#define f () -#define J return -#define l ae( -#define n e) -#define u d!= -#define F int -#define y (j) -#define r m= -#define t +4 -F d,z,C,h,P,K,ac,q,G,v,Q,R,D,L,W,M; -E(n{ -x D++=e; -} -o f{ -a L){ -h=x L++; -a h b 2){ -L=0; -h=W; -} -} -i h=fgetc(Q); -} -X f{ -J isalnum(h)|h b 95; -} -Y f{ -a h b 92){ -o f; -a h b 110)h=10; -} -} -c{ -F e,j,m; -p isspace(h)|h b 35){ -a h b 35){ -o f; -c; -a d b 536){ -c; -E(32); -k d=1; -k(d t)=D; -} -p h!=10){ -E(h); -o f; -} -E(h); -E(2); -} -o f; -} -C=0; -d=h; -a X f){ -E(32); -M=D; -p X f){ -E(h); -o f; -} -a isdigit(d)){ -z=strtol(M,0,0); -d=2; -} -i{ -x D=32; -d=strstr(R,M-1)-R; -x D=0; -d=d*8+256; -a d>536){ -d=P+d; -a k d b 1){ -L=k(d t); -W=h; -o f; -c; -} -} -} -} -i{ -o f; -a d b 39){ -d=2; -Y f; -z=h; -o f; -o f; -} -i a d b 47&h b 42){ -o f; -p h){ -p h!=42)o f; -o f; -a h b 47)h=0; -} -o f; -c; -} -i{ -e="++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b"; -p j=x e++){ -r x e++; -z=0; -p(C=x e++-98)<0)z=z*64+C+64; -a j b d&(m b h|m b 64)){ -a m b h){ -o f; -d=1; -} -break; -} -} -} -} -} -l g){ -p g&&g!=-1){ -x q++=g; -g=g>>8; -} -} -A(n{ -F g; -p n{ -g=k e; -k e=q-e-4; -e=g; -} -} -s(g,n{ -l g); -k q=e; -e=q; -q=q t; -J e; -} -H(n{ -s(184,n; -} -B(n{ -J s(233,n; -} -S(j,n{ -l 1032325); -J s(132+j,n; -} -Z(n{ -l 49465); -H(0); -l 15); -l e+144); -l 192); -} -N(j,n{ -l j+131); -s((e<512)<<7|5,n; -} -T y{ -F g,e,m,aa; -g=1; -a d b 34){ -H(v); -p h!=34){ -Y f; -x v++=h; -o f; -} -x v=0; -v=v t&-4; -o f; -c; -} -i{ -aa=C; -r z; -e=d; -c; -a e b 2){ -H(m); -} -i a aa b 2){ -T(0); -s(185,0); -a e b 33)Z(m); -i l m); -} -i a e b 40){ -w f; -c; -} -i a e b 42){ -c; -e=d; -c; -c; -a d b 42){ -c; -c; -c; -c; -e=0; -} -c; -T(0); -a d b 61){ -c; -l 80); -w f; -l 89); -l 392+(e b 256)); -} -i a n{ -a e b 256)l 139); -i l 48655); -q++; -} -} -i a e b 38){ -N(10,k d); -c; -} -i{ -g=k e; -a!g)g=dlsym(0,M); -a d b 61&j){ -c; -w f; -N(6,g); -} -i a u 40){ -N(8,g); -a C b 11){ -N(0,g); -l z); -c; -} -} -} -} -a d b 40){ -a g b 1)l 80); -r s(60545,0); -c; -j=0; -p u 41){ -w f; -s(2393225,j); -a d b 44)c; -j=j t; -} -k r j; -c; -a!g){ -e=e t; -k e=s(232,k n; -} -i a g b 1){ -s(2397439,j); -j=j t; -} -i{ -s(232,g-q-5); -} -a j)s(50305,j); -} -} -O y{ -F e,g,m; -a j--b 1)T(1); -i{ -O y; -r 0; -p j b C){ -g=d; -e=z; -c; -a j>8){ -r S(e,m); -O y; -} -i{ -l 80); -O y; -l 89); -a j b 4|j b 5){ -Z(n; -} -i{ -l n; -a g b 37)l 146); -} -} -} -a m&&j>8){ -r S(e,m); -H(e^1); -B(5); -A(m); -H(n; -} -} -} -w f{ -O(11); -} -U f{ -w f; -J S(0,0); -} -I y{ -F m,g,e; -a d b 288){ -c; -c; -r U f; -c; -I y; -a d b 312){ -c; -g=B(0); -A(m); -I y; -A(g); -} -i{ -A(m); -} -} -i a d b 352|d b 504){ -e=d; -c; -c; -a e b 352){ -g=q; -r U f; -} -i{ -a u 59)w f; -c; -g=q; -r 0; -a u 59)r U f; -c; -a u 41){ -e=B(0); -w f; -B(g-q-5); -A(n; -g=e t; -} -} -c; -I(&m); -B(g-q-5); -A(m); -} -i a d b 123){ -c; -ab(1); -p u 125)I y; -c; -} -i{ -a d b 448){ -c; -a u 59)w f; -K=B(K); -} -i a d b 400){ -c; -k j=B(k j); -} -i a u 59)w f; -c; -} -} -ab y{ -F m; -p d b 256|u-1&!j){ -a d b 256){ -c; -p u 59){ -a j){ -G=G t; -k d=-G; -} -i{ -k d=v; -v=v t; -} -c; -a d b 44)c; -} -c; -} -i{ -A(k(d t)); -k d=q; -c; -c; -r 8; -p u 41){ -k d=m; -r m t; -c; -a d b 44)c; -} -c; -K=G=0; -l 15042901); -r s(60545,0); -I(0); -A(K); -l 50121); -k r G; -} -} -} -main(g,n{ -Q=stdin; -a g-->1){ -e=e t; -Q=fopen(k e,"r"); -} -D=strcpy(R V," int if else while break return for define main ")+48; -v V; -q=ac V; -P V; -o f; -c; -ab(0); -J(*(int(*)f)k(P+592))(g,n; -} - diff --git a/libacc/tests/data/otcc.c b/libacc/tests/data/otcc.c deleted file mode 100644 index 433ae2e..0000000 --- a/libacc/tests/data/otcc.c +++ /dev/null @@ -1,448 +0,0 @@ -#include <stdio.h> -#define k *(int*) -#define a if( -#define c ad() -#define i else -#define p while( -#define x *(char*) -#define b == -#define V =calloc(1,99999) -#define f () -#define J return -#define l ae( -#define n e) -#define u d!= -#define F int -#define y (j) -#define r m= -#define t +4 -F d,z,C,h,P,K,ac,q,G,v,Q,R,D,L,W,M; -E(n{ -x D++=e; -} -o f{ -a L){ -h=x L++; -a h b 2){ -L=0; -h=W; -} -} -i h=fgetc(Q); -} -X f{ -J isalnum(h)|h b 95; -} -Y f{ -a h b 92){ -o f; -a h b 110)h=10; -} -} -c{ -F e,j,m; -p isspace(h)|h b 35){ -a h b 35){ -o f; -c; -a d b 536){ -c; -E(32); -k d=1; -k(d t)=D; -} -p h!=10){ -E(h); -o f; -} -E(h); -E(2); -} -o f; -} -C=0; -d=h; -a X f){ -E(32); -M=D; -p X f){ -E(h); -o f; -} -a isdigit(d)){ -z=strtol(M,0,0); -d=2; -} -i{ -x D=32; -d=strstr(R,M-1)-R; -x D=0; -d=d*8+256; -a d>536){ -d=P+d; -a k d b 1){ -L=k(d t); -W=h; -o f; -c; -} -} -} -} -i{ -o f; -a d b 39){ -d=2; -Y f; -z=h; -o f; -o f; -} -i a d b 47&h b 42){ -o f; -p h){ -p h!=42)o f; -o f; -a h b 47)h=0; -} -o f; -c; -} -i{ -e="++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b"; -p j=x e++){ -r x e++; -z=0; -p(C=x e++-98)<0)z=z*64+C+64; -a j b d&(m b h|m b 64)){ -a m b h){ -o f; -d=1; -} -break; -} -} -} -} -} -l g){ -p g&&g!=-1){ -x q++=g; -g=g>>8; -} -} -A(n{ -F g; -p n{ -g=k e; -k e=q-e-4; -e=g; -} -} -s(g,n{ -l g); -k q=e; -e=q; -q=q t; -J e; -} -H(n{ -s(184,n; -} -B(n{ -J s(233,n; -} -S(j,n{ -l 1032325); -J s(132+j,n; -} -Z(n{ -l 49465); -H(0); -l 15); -l e+144); -l 192); -} -N(j,n{ -l j+131); -s((e<512)<<7|5,n; -} -T y{ -F g,e,m,aa; -g=1; -a d b 34){ -H(v); -p h!=34){ -Y f; -x v++=h; -o f; -} -x v=0; -v=v t&-4; -o f; -c; -} -i{ -aa=C; -r z; -e=d; -c; -a e b 2){ -H(m); -} -i a aa b 2){ -T(0); -s(185,0); -a e b 33)Z(m); -i l m); -} -i a e b 40){ -w f; -c; -} -i a e b 42){ -c; -e=d; -c; -c; -a d b 42){ -c; -c; -c; -c; -e=0; -} -c; -T(0); -a d b 61){ -c; -l 80); -w f; -l 89); -l 392+(e b 256)); -} -i a n{ -a e b 256)l 139); -i l 48655); -q++; -} -} -i a e b 38){ -N(10,k d); -c; -} -i{ -g=k e; -a!g)g=dlsym(0,M); -a d b 61&j){ -c; -w f; -N(6,g); -} -i a u 40){ -N(8,g); -a C b 11){ -N(0,g); -l z); -c; -} -} -} -} -a d b 40){ -a g b 1)l 80); -r s(60545,0); -c; -j=0; -p u 41){ -w f; -s(2393225,j); -a d b 44)c; -j=j t; -} -k r j; -c; -a!g){ -e=e t; -k e=s(232,k n; -} -i a g b 1){ -s(2397439,j); -j=j t; -} -i{ -s(232,g-q-5); -} -a j)s(50305,j); -} -} -O y{ -F e,g,m; -a j--b 1)T(1); -i{ -O y; -r 0; -p j b C){ -g=d; -e=z; -c; -a j>8){ -r S(e,m); -O y; -} -i{ -l 80); -O y; -l 89); -a j b 4|j b 5){ -Z(n; -} -i{ -l n; -a g b 37)l 146); -} -} -} -a m&&j>8){ -r S(e,m); -H(e^1); -B(5); -A(m); -H(n; -} -} -} -w f{ -O(11); -} -U f{ -w f; -J S(0,0); -} -I y{ -F m,g,e; -a d b 288){ -c; -c; -r U f; -c; -I y; -a d b 312){ -c; -g=B(0); -A(m); -I y; -A(g); -} -i{ -A(m); -} -} -i a d b 352|d b 504){ -e=d; -c; -c; -a e b 352){ -g=q; -r U f; -} -i{ -a u 59)w f; -c; -g=q; -r 0; -a u 59)r U f; -c; -a u 41){ -e=B(0); -w f; -B(g-q-5); -A(n; -g=e t; -} -} -c; -I(&m); -B(g-q-5); -A(m); -} -i a d b 123){ -c; -ab(1); -p u 125)I y; -c; -} -i{ -a d b 448){ -c; -a u 59)w f; -K=B(K); -} -i a d b 400){ -c; -k j=B(k j); -} -i a u 59)w f; -c; -} -} -ab y{ -F m; -p d b 256|u-1&!j){ -a d b 256){ -c; -p u 59){ -a j){ -G=G t; -k d=-G; -} -i{ -k d=v; -v=v t; -} -c; -a d b 44)c; -} -c; -} -i{ -A(k(d t)); -k d=q; -c; -c; -r 8; -p u 41){ -k d=m; -r m t; -c; -a d b 44)c; -} -c; -K=G=0; -l 15042901); -r s(60545,0); -I(0); -A(K); -l 50121); -k r G; -} -} -} -main(g,n{ -Q=stdin; -a g-->1){ -e=e t; -Q=fopen(k e,"r"); -} -D=strcpy(R V," int if else while break return for define main ")+48; -v V; -q=ac V; -P V; -o f; -c; -ab(0); -mprotect(ac & (~ 4095), (99999 + 4095) & (~ 4095), 7); -fprintf(stderr, "otcc.c: about to execute compiled code.\n"); -J(*(int(*)f)k(P+592))(g,n; -} - diff --git a/libacc/tests/data/pointers.c b/libacc/tests/data/pointers.c deleted file mode 100644 index 461ebeb..0000000 --- a/libacc/tests/data/pointers.c +++ /dev/null @@ -1,15 +0,0 @@ -int main() { - int* pa = (int*) malloc(100); - int* pb = pa + 1; - int* pc = (int*) 0; - *pa = 1; - *pb = 2; - printf("Pointer difference: %d %d\n", pb - pa, ((int) pb) - ((int) pa)); - int c = * (pa + 1); - printf("Pointer addition: %d\n", c); - printf("Pointer comparison to zero: %d %d %d\n", pa == 0, pb == 0, pc == 0); - printf("Pointer comparison: %d %d %d %d %d\n", pa < pb, pa == pb, pa > pb, ! pb, ! pc); - free(pa); - return 0; -} - diff --git a/libacc/tests/data/pointers2.c b/libacc/tests/data/pointers2.c deleted file mode 100644 index 69e402f..0000000 --- a/libacc/tests/data/pointers2.c +++ /dev/null @@ -1,35 +0,0 @@ -// Test multiple levels of indirection - -void testsingle() { - int a = 0; - int* pa = &a; - printf("a = %d, *pa = %d\n", a, *pa); - *pa = 2; - printf("a = %d, *pa = %d\n", a, *pa); -} - -void testdouble() { - int a = 0; - int* pa = &a; - int** ppa = &pa; - printf("a = %d, *pa = %d **ppa = %d\n", a, *pa, **ppa); - **ppa = 2; - printf("a = %d, *pa = %d **ppa = %d\n", a, *pa, **ppa); -} - -void testtripple() { - int a = 0; - int* pa = &a; - int** ppa = &pa; - int*** pppa = &ppa; - printf("a = %d, *pa = %d **ppa = %d\n ***pppa = %d", a, *pa, **ppa, ***pppa); - ***pppa = 2; - printf("a = %d, *pa = %d **ppa = %d\n ***pppa = %d", a, *pa, **ppa, ***pppa); -} - -int main() { - testsingle(); - testdouble(); - testdouble(); - return 0; -} diff --git a/libacc/tests/data/returnval-ansi.c b/libacc/tests/data/returnval-ansi.c deleted file mode 100644 index 6b53fd5..0000000 --- a/libacc/tests/data/returnval-ansi.c +++ /dev/null @@ -1,8 +0,0 @@ - -int main(int argc, char** argv) { - return f(); -} - -int f() { - return 42; -} diff --git a/libacc/tests/data/returnval.c b/libacc/tests/data/returnval.c deleted file mode 100644 index 1cf5bae..0000000 --- a/libacc/tests/data/returnval.c +++ /dev/null @@ -1,4 +0,0 @@ -main() { - return 42; -} - diff --git a/libacc/tests/data/rollo3.c b/libacc/tests/data/rollo3.c deleted file mode 100644 index b21c12f..0000000 --- a/libacc/tests/data/rollo3.c +++ /dev/null @@ -1,9 +0,0 @@ - -float fabsf(float); - -int main(void* con, int ft, int launchID) -{ - float f = fabsf(-10.0f); - return f; -} - diff --git a/libacc/tests/data/short.c b/libacc/tests/data/short.c deleted file mode 100644 index 5e222f3..0000000 --- a/libacc/tests/data/short.c +++ /dev/null @@ -1,6 +0,0 @@ -short a = 3; -int main() { - short* b = &a; - *b = *b - 5; - return a; -} diff --git a/libacc/tests/data/simplest.c b/libacc/tests/data/simplest.c deleted file mode 100644 index bae895a..0000000 --- a/libacc/tests/data/simplest.c +++ /dev/null @@ -1 +0,0 @@ -main() {} diff --git a/libacc/tests/data/structs.c b/libacc/tests/data/structs.c deleted file mode 100644 index dd81af3..0000000 --- a/libacc/tests/data/structs.c +++ /dev/null @@ -1,95 +0,0 @@ -// struct definition and declaration -struct a { - int a; - int b; -} c; - -// Useless, but legal struct declaration -struct { - int x; -}; - -// Useful anonymous struct declaration -struct { - int y; -} anon1, anon2; - -// forward declarations -struct a; -struct b; -struct c; - -struct b {int a; int b; }; - -// struct c {b g; }; // syntax error. - -// struct s {float c,a,b,c;} s; // duplicate struct member - -struct c {struct b g; }; - -// struct a { int w; }; // error - -void testCopying() { - struct a {int a[10]; char c;} a, b; - a.c = 37; - b.c = 38; - b = a; - printf("testCopying: %d == %d\n", a.c, b.c); -} - -void testUnion() { - union u; - union u {float f;int i;} u; - u.f = 1.0f; - printf("testUnion: %g == 0x%08x\n", u.f, u.i); -} - -struct v {float x, y, z, w; }; - -void add(struct v* result, struct v* a, struct v* b) { - result->x = a->x + b->x; - result->y = a->y + b->y; - result->z = a->z + b->z; - result->w = a->w + b->w; -} - -void set(struct v* v, float x, float y, float z, float w) { - v->x = x; - v->y = y; - v->z = z; - v->w = w; -} - -void print(struct v* v) { - printf("(%g, %g, %g, %g)\n", v->x, v->y, v->z, v->w); -} - -void testArgs() { - struct v a, b, c; - set(&a, 1.0f, 2.0f, 3.0f, 4.0f); - set(&b, 5.0f, 6.0f, 7.0f, 8.0f); - add(&c, &a, &b); - printf("testArgs: "); - print(&c); -} - -int main() { - anon1.y = 3; - anon2.y = anon1.y; - - testCopying(); - testUnion(); - testArgs(); - - struct c cc; - cc.g.a = 3; - c.a = 1; - c.b = 3; - struct a {int x, y; } z; - // struct a {int x, y; } z2; - z.x = c.a; - struct a *pA; - pA = &z; - pA->x += 5; - return pA->x; -} diff --git a/libacc/tests/data/testStringConcat.c b/libacc/tests/data/testStringConcat.c deleted file mode 100644 index bf06ae1..0000000 --- a/libacc/tests/data/testStringConcat.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - return printf("Hello" "," " world\n"); -} - diff --git a/libacc/tests/data/typedef.c b/libacc/tests/data/typedef.c deleted file mode 100644 index c392f6a..0000000 --- a/libacc/tests/data/typedef.c +++ /dev/null @@ -1,40 +0,0 @@ -typedef short COORD; -typedef struct Point { - COORD x; - COORD y; -} Point; - -void add(Point* result, Point* a, Point* b) { - result->x = a->x + b->x; - result->y = a->y + b->y; -} - -void print(Point* p) { - printf("(%d, %d)", p->x, p->y); -} - -void set(Point* p, int x, int y) { - p->x = x; - p->y = y; -} - -int main() { - typedef char* String; - String s = "x = %d\n"; - { - typedef int item; - item x = 3; - printf(s, x); - } - Point a, b, c; - set(&a, 1,2); - set(&b, 3,4); - add(&c, &a, &b); - print(&c); - printf(" = "); - print(&a); - printf(" + "); - print(&b); - printf("\n"); - return 0; -} |