Loading libacc/acc.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -1168,7 +1168,8 @@ class Compiler : public ErrorSink { virtual void loadR0FromR0() { Type* pPointerType = getR0Type(); assert(pPointerType->tag == TY_POINTER); TypeTag tag = pPointerType->pHead->tag; Type* pNewType = pPointerType->pHead; TypeTag tag = pNewType->tag; switch (tag) { case TY_POINTER: case TY_INT: Loading @@ -1184,11 +1185,14 @@ class Compiler : public ErrorSink { case TY_DOUBLE: o4(0xE1C000D0); // ldrd r0, [r0] break; case TY_ARRAY: pNewType = pNewType->pTail; break; default: error("loadR0FromR0: unimplemented type %d", tag); break; } setR0Type(pPointerType->pHead); setR0Type(pNewType); } virtual void leaR0(int ea, Type* pPointerType, ExpressionType et) { Loading Loading @@ -2213,7 +2217,8 @@ class Compiler : public ErrorSink { virtual void loadR0FromR0() { Type* pPointerType = getR0Type(); assert(pPointerType->tag == TY_POINTER); TypeTag tag = pPointerType->pHead->tag; Type* pNewType = pPointerType->pHead; TypeTag tag = pNewType->tag; switch (tag) { case TY_POINTER: case TY_INT: Loading @@ -2233,11 +2238,14 @@ class Compiler : public ErrorSink { case TY_DOUBLE: o2(0x00dd); // fldl (%eax) break; case TY_ARRAY: pNewType = pNewType->pTail; break; default: error("loadR0FromR0: unsupported type %d", tag); break; } setR0Type(pPointerType->pHead); setR0Type(pNewType); } virtual void leaR0(int ea, Type* pPointerType, ExpressionType et) { Loading Loading @@ -4126,6 +4134,9 @@ class Compiler : public ErrorSink { pTargetType = pGen->getR0Type(); if (pTargetType->tag == TY_FLOAT) { pTargetType = mkpDouble; } else if (pTargetType->tag == TY_ARRAY) { // Pass arrays by pointer. pTargetType = pTargetType->pTail; } } if (pTargetType->tag == TY_VOID) { Loading libacc/tests/data/array.c +30 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,34 @@ void testArgs() { 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(); Loading @@ -73,5 +101,7 @@ int main() testGlobalChar(); testGlobalDouble(); testArgs(); testDecay(); test2D(); return 0; } libacc/tests/test.py +12 −0 Original line number Diff line number Diff line Loading @@ -394,6 +394,18 @@ localDouble: 3 3 globalChar: 3 globalDouble: 3 testArgs: 0 2 4 testDecay: Hi! test2D: abcdefghijdefghijklm defghijklmghijklmnop ghijklmnopjklmnopabc jklmnopabcmnopabcdef mnopabcdefpabcdefghi pabcdefghicdefghijkl cdefghijklfghijklmno fghijklmnoijklmnopab ijklmnopablmnopabcde lmnopabcdefghijklmno result: 0 ""","""""") Loading Loading
libacc/acc.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -1168,7 +1168,8 @@ class Compiler : public ErrorSink { virtual void loadR0FromR0() { Type* pPointerType = getR0Type(); assert(pPointerType->tag == TY_POINTER); TypeTag tag = pPointerType->pHead->tag; Type* pNewType = pPointerType->pHead; TypeTag tag = pNewType->tag; switch (tag) { case TY_POINTER: case TY_INT: Loading @@ -1184,11 +1185,14 @@ class Compiler : public ErrorSink { case TY_DOUBLE: o4(0xE1C000D0); // ldrd r0, [r0] break; case TY_ARRAY: pNewType = pNewType->pTail; break; default: error("loadR0FromR0: unimplemented type %d", tag); break; } setR0Type(pPointerType->pHead); setR0Type(pNewType); } virtual void leaR0(int ea, Type* pPointerType, ExpressionType et) { Loading Loading @@ -2213,7 +2217,8 @@ class Compiler : public ErrorSink { virtual void loadR0FromR0() { Type* pPointerType = getR0Type(); assert(pPointerType->tag == TY_POINTER); TypeTag tag = pPointerType->pHead->tag; Type* pNewType = pPointerType->pHead; TypeTag tag = pNewType->tag; switch (tag) { case TY_POINTER: case TY_INT: Loading @@ -2233,11 +2238,14 @@ class Compiler : public ErrorSink { case TY_DOUBLE: o2(0x00dd); // fldl (%eax) break; case TY_ARRAY: pNewType = pNewType->pTail; break; default: error("loadR0FromR0: unsupported type %d", tag); break; } setR0Type(pPointerType->pHead); setR0Type(pNewType); } virtual void leaR0(int ea, Type* pPointerType, ExpressionType et) { Loading Loading @@ -4126,6 +4134,9 @@ class Compiler : public ErrorSink { pTargetType = pGen->getR0Type(); if (pTargetType->tag == TY_FLOAT) { pTargetType = mkpDouble; } else if (pTargetType->tag == TY_ARRAY) { // Pass arrays by pointer. pTargetType = pTargetType->pTail; } } if (pTargetType->tag == TY_VOID) { Loading
libacc/tests/data/array.c +30 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,34 @@ void testArgs() { 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(); Loading @@ -73,5 +101,7 @@ int main() testGlobalChar(); testGlobalDouble(); testArgs(); testDecay(); test2D(); return 0; }
libacc/tests/test.py +12 −0 Original line number Diff line number Diff line Loading @@ -394,6 +394,18 @@ localDouble: 3 3 globalChar: 3 globalDouble: 3 testArgs: 0 2 4 testDecay: Hi! test2D: abcdefghijdefghijklm defghijklmghijklmnop ghijklmnopjklmnopabc jklmnopabcmnopabcdef mnopabcdefpabcdefghi pabcdefghicdefghijkl cdefghijklfghijklmno fghijklmnoijklmnopab ijklmnopablmnopabcde lmnopabcdefghijklmno result: 0 ""","""""") Loading