Preliminary struct and union support.
Working features:
- struct
- union
- nested structs
- anonymous structs
- forward declarations
- '.' and '->'
- copying structs using '='
Missing features:
- passing structs by value
- returning structs by value
- typedef
- sizeof
Example:
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;
}
Reworked size-of and alignment logic to support structs.
Improved encoding of ARM immediate constants.
diff --git a/libacc/tests/test.py b/libacc/tests/test.py
index b8caee0..a8575b1 100644
--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -463,6 +463,13 @@
result: 1092616192
""","""""")
+ def testStructs(self):
+ self.compileCheck(["-R", "data/structs.c"], """Executing compiled code:
+testCopying: 37 == 37
+testUnion: 1 == 0x3f800000
+testArgs: (6, 8, 10, 12)
+result: 6
+""","""""")
def main():
checkEnvironment()