diff --git a/src/castile/backends/c.py b/src/castile/backends/c.py index af5dce1..b55ce97 100644 --- a/src/castile/backends/c.py +++ b/src/castile/backends/c.py @@ -216,8 +216,11 @@ self.indent += 1 for child in ast.children: assert child.tag == 'FieldDefn' - # TODO does not handle structs within structs - self.write_indent('if (a->%s != b->%s) return 0;\n' % (child.value, child.value)) + struct_type = child.children[0].value if child.children[0].tag == 'StructType' else None + if struct_type: + self.write_indent('if (!equal_%s(a->%s, b->%s)) return 0;\n' % (struct_type, child.value, child.value)) + else: + self.write_indent('if (a->%s != b->%s) return 0;\n' % (child.value, child.value)) self.write_indent('return 1;\n') self.indent -= 1 diff --git a/test.sh b/test.sh index b18d99d..d40b040 100755 --- a/test.sh +++ b/test.sh @@ -24,6 +24,8 @@ APPLIANCES="$APPLIANCES tests/appliances/castile-c-c.md" fi +#APPLIANCES="tests/appliances/castile-c-c.md" + falderal $APPLIANCES tests/Castile.md RESULT=$? rm -f foo.* a.out