Make many helpers, factories and tables static in Microsoft.CSharp (dotnet/corefx...
authorJon Hanna <jon@hackcraft.net>
Thu, 15 Feb 2018 20:37:30 +0000 (20:37 +0000)
committerVladimir Sadov <vsadov@microsoft.com>
Thu, 15 Feb 2018 20:37:30 +0000 (12:37 -0800)
commit96c93497a0877820da0ed4a2a0dde468bfccfa84
tree8f9dc97ef27be8e48d846336d7db42bbf86c8fe5
parentb47f6bd40f5a011305c787cd2adc1d77feea7909
Make many helpers, factories and tables static in Microsoft.CSharp (dotnet/corefx#27044)

* Have TypeArray in charge of the empty TypeArray singleton

* Make TypeArray allocation a static responsibility of TypeArray

* Remove some orphaned members.

Mostly BSYMMGR-returning members that had been used to allocate
TypeArrays

* Make members static were possible.

Those that can already be easily made static. Includes removing some
members that this makes no longer necessary.

* Remove unused parameters

Since some are of the types we'll be making static, and such parameters
will have to go anyway.

* Make TypeTable static

And more conventional names within TypeTable.

* More TypeManager state & methods to static

* Make SYMTBL.Key an immutable struct.

* SYMTBL completely static and renamed to SymbolStore

More conventional name, and doesn't clash with other SymbolTable class.

* GetWinRTCollectionIfacesAll to property.

* SymFactory static class.

* Remove PredefinedTypes._symbolManager field

Only used in assertion.

* Remove assert comparison with this in GetAggregate

Assert is the only reason to not be static, allows a cascade of more
changes to static.

* Make InternalsVisibleTo check static.

* Make cycle of instance methods static

Take quite a large set of methods which must be instance because of
cyclic instance dependencies, and make them all static.

Removes dependency in AggregateSymbol and NullableType on TypeManager
instances.

* Replace GetAggTypeSym with virtual method on CType.

Merged with existing GetAts on NullableType. Comment says this would be
nice, and indeed it would, and its easy now.

* Make those members that can now be static, static.

* Remove orphaned members and fields.

* PredefinedMembers entirely static.

* Remove UserStringBuilder.m_buildingInProgress

Only used in asserts, just assert on whether m_strBuilder is null or
not.

Also rename m_strBuilder to _strBuilder to be more conventional.

* Favour returning over out in UserStringBuilder

And favour clearing StringBuilder over creating another.

* Make ErrorHandling completely static.

Creating UserStringBuilder instances on demand.

* TypeManager static.

* Make CNullable methods static and merge directly into ExpressionBinder

Don't cache method and property, as they're already cached.

* Don't preload types.

Either they'll be loaded soon anyway, or else it's a wasted effort.

* Move CompareTypes into Better.cs

* Remove BSYMMGR.LookupAggMember

Just call into SymbolStore.LookupSym

* Move LookupNextSym logic into Symbol

* Remove BSYMMGR and GlobalSymbolContext

No longer any use.

* ExprFactory static

* SymbolLoader static

* CSemanticChecker static

* Don't pre-emptively load System.Object

Will be loaded as a base of the first type encountered anyway.

* SymbolTable static

* More methods can be made static

* Remove orphaned method.

* Move methods for getting MemberInfos from expressions into those expressions

* Replace ExpressionTreeCallRewriter.GetObject with virtual property in Expr

* TypeArray tidy-up.

* Pass ExpressionBinder to operator delegates, and make them static.

Allows array to be created once statically, rather than on each
instance construction.

* Create RuntimeBinder, ExpressionBinder and BindingContext per operation

These are now very lightweight, so it's simpler to create them anew
each time rather than overwriting the values in the BindingContext.

* Make RuntimeBinder, ExpressionBinder and BindingContext structs

No need to allocate on the heap.

* Remove AggregateDeclaration

We only ever care about the AggregateSymbol it relates to.

(The two aren't really separate in dynamic code, where there aren't
really declarations).

* Remove IsChecked and CallingContext from C# binders.

Now not used as they are passed to RuntimeBinder on construction,
except for CallingContext remaining in CSharpInvokeMemberBinder for use
in deferring.

* Make RecordBinOpSigFromArgs static.

A last member that can be made static.

* Make static-member-only classes static.

* Make NameHashKey a readonly struct.

Commit migrated from https://github.com/dotnet/corefx/commit/b7d1ae93c179510991f75709c3c3c1d3e3d062c1
70 files changed:
src/libraries/Microsoft.CSharp/src/Microsoft.CSharp.csproj
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpBinaryOperationBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpConvertBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpGetIndexBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpGetMemberBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeConstructorBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeMemberBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpIsEventBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpSetIndexBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpSetMemberBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpUnaryOperationBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorHandling.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/UserStringBuilder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ExpressionTreeCallRewriter.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ICSharpBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/BinOpArgInfo.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/BinOpSig.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Binding/Better.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/BindingContext.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversions.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Declarations/AggregateDeclaration.cs [deleted file]
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/EXPRExtensions.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExplicitConversion.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExprFactory.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GlobalSymbolContext.cs [deleted file]
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GroupToArgsBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GroupToArgsBinderResult.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ImplicitConversion.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/MemberLookup.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/MemberLookupResults.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/MethodIterator.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/MethodTypeInferrer.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Nullable.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/PredefinedMembers.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/SemanticChecker.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/AggregateSymbol.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/FieldSymbol.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/NamespaceOrAggregateSymbol.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymFactory.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/Symbol.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymbolKind.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymbolLoader.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymbolManagerBase.cs [deleted file]
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymbolStore.cs [moved from src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymbolTable.cs with 63% similarity]
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Cast.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Constant.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/EXPR.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprWithType.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MemberGroup.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodInfo.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/PropertyInfo.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeOf.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ZeroInitialize.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/TypeBind.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/AggregateType.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/ArrayType.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/NullableType.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/PredefinedTypes.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/Type.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/TypeArray.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/TypeManager.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/TypeTable.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/UnaOpSig.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs