git @ Cat's Eye Technologies Castile / b7c71eb
Implement deep struct equality in C backend. Chris Pressey 3 years ago
2 changed file(s) with 7 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
215215 self.indent += 1
216216 for child in ast.children:
217217 assert child.tag == 'FieldDefn'
218 # TODO does not handle structs within structs
219 self.write_indent('if (a->%s != b->%s) return 0;\n' % (child.value, child.value))
218 struct_type = child.children[0].value if child.children[0].tag == 'StructType' else None
219 if struct_type:
220 self.write_indent('if (!equal_%s(a->%s, b->%s)) return 0;\n' % (struct_type, child.value, child.value))
221 else:
222 self.write_indent('if (a->%s != b->%s) return 0;\n' % (child.value, child.value))
220223
221224 self.write_indent('return 1;\n')
222225 self.indent -= 1
2323 APPLIANCES="$APPLIANCES tests/appliances/castile-c-c.md"
2424 fi
2525
26 #APPLIANCES="tests/appliances/castile-c-c.md"
27
2628 falderal $APPLIANCES tests/Castile.md
2729 RESULT=$?
2830 rm -f foo.* a.out