Add a "definition" class

The idea here is that this holds a function definition context and
allows emiting code to that context.  The hope is to make writing out
files a bit safer: this way you can't directly write out to the file
but instead have your output guarded by this class.

The current implementation is a bit messy so I can keep the in-order
stream writing property so I can maintain the old codebase.  This may
or may not go away...