merge MMcM: Types3 registry is functions registry

Merge pull request #1098 from MMcM/sql-layer/collapse-types-registry
https://github.com/FoundationDB/sql-layer/pull/1098
Add ref option to build_packages
Add ref option to build_installer
merge nathanlws: Add TOOLS_REF option to build scripts

Merge pull request #1099 from nathanlws/sql-layer/tools-branch-option
https://github.com/FoundationDB/sql-layer/pull/1099
Make TInstance an argument to plan expression nodes so that type conversion happens in a context rather than the constructor.
Fix some tests.