Emit prototypes for built-in functions.
In programs that reference a variety of built-in functions, we could
occasionally generate output where a built-in was called before it
was defined. We don't preserve a lot of positional information about
rehydrated functions--their Positions are long gone, and the
ProgramElements are stored in a map that's ordered by string. Instead,
FindAndDeclareBuiltinFunctions was naively inferring order based on
ProgramUsage: "A calls B, B calls C" --> "C, B, A". However, we could
also have more complex arrangements like "A calls B and C and D, D
calls C, B calls D" where our algorithm couldn't reconstruct the
ideal order (C, D, B, A) without doing a lot more work. Fortunately,
we can just emit a few prototypes and not have to worry about the ideal
order.
Change-Id: I9371ba522d5aa20c1da6acfe8c675df121ba9a93
Bug: skia:13673
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/571701
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
37 files changed