Commits

Jordan Rose committed 2300d7a1ce3
[serialization] Add support for function arguments. The main work here is serializing patterns, which are recursive. Unlike Types, Patterns are not uniqued (in the original AST they contain location info). Therefore, rather than using cross-referencing IDs, patterns are serialized as trailing records with an implied hierarchy. Each pattern record tells you what trailing records to expect. So, for example, the pattern ((x : Int, y : Int), _ : Int) will give you this serialization: 1. TuplePattern - 2 elements 2. TuplePatternElt 3. TuplePattern - 2 elements 4. TuplePatternElt 5. TypedPattern - Int 6. NamedPattern - x 7. TuplePatternElt 8. TypedPattern - Int 9. NamedPattern - y 10. TuplePatternElt 11. TypedPattern - Int 12. AnyPattern Functions contain two sets of patterns: "argument" patterns and "body" patterns, which are different in selector-style declarations. Currently we always serialize both of these, but it would be easy enough to add a flag in the FUNC_DECL record to skip one of them if they are the same. If the function is curried, each set will contain multiple patterns. These are simply read eagerly as trailing records from the function; as soon as a non-pattern record is encountered, we know all of the patterns have been read in. Swift SVN r5742