Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Hanna <jon@hackcraft.net>2017-07-18 22:44:38 +0300
committerVladimir Sadov <vsadov@microsoft.com>2017-07-18 22:44:38 +0300
commitf1bcc79ffa5dfd9465c31499f253146621fe5284 (patch)
tree00e427654b02535ad83105ce134e545a1f3fd314 /src/Microsoft.CSharp
parente3e1322c61829a193596822ac60aba72e8961cab (diff)
Simplify Microsoft.CSharp.RuntimeBinder.Semantics.ExprFactory (#22034)
* Move as much logic from ExprFactor into constructors as possible. When this allows a property to become init-only, make it so * Remove unused parameter from CreateClass and merge with now-identical MakeClass * Remove unused ExprTypeArguments class. * Remove unused Scope parameter from CreateWrap. Merge CreateWrap with identical CreateWrapNoAutoFree * Remove unused Scope parameter from CreateReturn * Remove unused mwtGet property from CreateProperty * Remove nFlags parameter to CreateArrayInit only used in assertions And only with constant values, so not really asserting anything. * Always set ExprArrayInit DimensionSizes in factory call. * Remove exprInOriginal being constructed and unused. * Remove unused OptionalScope property from ExprBlock * Set ExprBoundLambda.ArgumentScope from ctor and make init-only. * Remove ExprUnboundLambda as created in one place and never used. * Remove dead code from GenerateBoundLambda List created from arguments, then never used. * Reduce passing of EXPRFLAG values to ExprFactory methods. When always the same, or when computation is simple. * Remove argument from CreateHoistedLocalInExpression only used in asserts * Private GetTypes and GetGlobalSymbols to properties * Move assertions into ctors where possible. * Expression-type methods * Rename variables. Don't use Hungarian (especially Hungarian apparently referring to C++ pointers).
Diffstat (limited to 'src/Microsoft.CSharp')
-rw-r--r--src/Microsoft.CSharp/src/Microsoft.CSharp.csproj2
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs30
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs18
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExplicitConversion.cs4
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExprFactory.cs630
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs30
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionKind.cs4
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GroupToArgsBinder.cs4
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ImplicitConversion.cs11
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Nullable.cs3
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs2
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayIndex.cs4
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayInitialization.cs8
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Assignment.cs5
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BinaryOperator.cs19
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Block.cs5
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BoundAnonymousFunction.cs20
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Call.cs16
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Cast.cs12
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Class.cs3
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/CompoundOperator.cs14
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Concatenate.cs24
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Constant.cs5
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Event.cs6
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs13
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Field.cs7
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/FieldInfo.cs10
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/List.cs6
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/LocalVariable.cs6
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MemberGroup.cs24
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodInfo.cs9
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodReference.cs10
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/NamedArgumentSpecification.cs6
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Property.cs25
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/PropertyInfo.cs9
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Return.cs3
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Temporary.cs9
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeArguments.cs21
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeOf.cs4
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnaryOperator.cs15
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnboundAnonymousFunction.cs14
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedConversion.cs17
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedLogicalOperator.cs13
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExprVisitorBase.cs21
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs15
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ZeroInitialize.cs10
46 files changed, 438 insertions, 708 deletions
diff --git a/src/Microsoft.CSharp/src/Microsoft.CSharp.csproj b/src/Microsoft.CSharp/src/Microsoft.CSharp.csproj
index 1ed1ee45be..afe197b988 100644
--- a/src/Microsoft.CSharp/src/Microsoft.CSharp.csproj
+++ b/src/Microsoft.CSharp/src/Microsoft.CSharp.csproj
@@ -147,10 +147,8 @@
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Return.cs" />
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Statement.cs" />
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Temporary.cs" />
- <Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\TypeArguments.cs" />
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\TypeOf.cs" />
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\UnaryOperator.cs" />
- <Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\UnboundAnonymousFunction.cs" />
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\UserDefinedConversion.cs" />
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\UserDefinedLogicalOperator.cs" />
<Compile Include="Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Visitors\ExpressionTreeRewriter.cs" />
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
index bcab25ca5b..92ac272873 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
@@ -200,7 +200,7 @@ namespace Microsoft.CSharp.RuntimeBinder
Debug.Assert(pResult != null);
deferredBinding = null;
- Expression e = CreateExpressionTreeFromResult(parameters, arguments, pScope, pResult);
+ Expression e = CreateExpressionTreeFromResult(parameters, pScope, pResult);
return e;
}
@@ -287,12 +287,11 @@ namespace Microsoft.CSharp.RuntimeBinder
private Expression CreateExpressionTreeFromResult(
Expression[] parameters,
- ArgumentObject[] arguments,
Scope pScope,
Expr pResult)
{
// (3) - Place the result in a return statement and create the EXPRBOUNDLAMBDA.
- ExprBoundLambda boundLambda = GenerateBoundLambda(arguments, pScope, pResult);
+ ExprBoundLambda boundLambda = GenerateBoundLambda(pScope, pResult);
// (4) - Rewrite the EXPRBOUNDLAMBDA into an expression tree.
Expr exprTree = ExpressionTreeRewriter.Rewrite(boundLambda, _exprFactory, SymbolLoader);
@@ -472,7 +471,6 @@ namespace Microsoft.CSharp.RuntimeBinder
/////////////////////////////////////////////////////////////////////////////////
private ExprBoundLambda GenerateBoundLambda(
- ArgumentObject[] arguments,
Scope pScope,
Expr call)
{
@@ -481,18 +479,9 @@ namespace Microsoft.CSharp.RuntimeBinder
AggregateType delegateType = _symbolTable.GetCTypeFromType(typeof(Func<>)).AsAggregateType();
LocalVariableSymbol thisLocal = _semanticChecker.GetGlobalSymbolFactory().CreateLocalVar(_semanticChecker.GetNameManager().Add("this"), pScope, _symbolTable.GetCTypeFromType(typeof(object)));
thisLocal.isThis = true;
- ExprBoundLambda boundLambda = _exprFactory.CreateAnonymousMethod(delegateType);
- ExprUnboundLambda unboundLambda = _exprFactory.CreateLambda();
-
- List<Type> paramTypes = new List<Type>();
- foreach (ArgumentObject o in arguments)
- {
- paramTypes.Add(o.Type);
- }
- boundLambda.ArgumentScope = pScope;
-
- ExprReturn returnStatement = _exprFactory.CreateReturn(0, pScope, call);
- ExprBlock block = _exprFactory.CreateBlock(returnStatement, pScope);
+ ExprBoundLambda boundLambda = _exprFactory.CreateAnonymousMethod(delegateType, pScope);
+ ExprReturn returnStatement = _exprFactory.CreateReturn(call);
+ ExprBlock block = _exprFactory.CreateBlock(returnStatement);
boundLambda.OptionalBody = block;
return boundLambda;
}
@@ -513,7 +502,7 @@ namespace Microsoft.CSharp.RuntimeBinder
}
// If we can convert, do that. If not, cast it.
- ExprLocal exprLocal = _exprFactory.CreateLocal(EXPRFLAG.EXF_LVALUE, local);
+ ExprLocal exprLocal = _exprFactory.CreateLocal(local);
Expr result = _binder.tryConvert(exprLocal, ctype);
if (result == null)
{
@@ -843,8 +832,7 @@ namespace Microsoft.CSharp.RuntimeBinder
throw Error.InternalCompilerError();
}
- callingObject = _exprFactory.CreateClass(_symbolTable.GetCTypeFromType(t), t.ContainsGenericParameters ?
- _exprFactory.CreateTypeArguments(SymbolLoader.getBSymmgr().AllocParams(_symbolTable.GetCTypeArrayFromTypes(t.GetGenericArguments())), null) : null);
+ callingObject = _exprFactory.CreateClass(_symbolTable.GetCTypeFromType(t));
}
else
{
@@ -1035,7 +1023,7 @@ namespace Microsoft.CSharp.RuntimeBinder
// WindowsRuntimeMarshal.Add\RemoveEventHandler(...)
Type windowsRuntimeMarshalType = SymbolTable.WindowsRuntimeMarshalType;
_symbolTable.PopulateSymbolTableWithName(methodName, new List<Type> { evtType }, windowsRuntimeMarshalType);
- ExprClass marshalClass = _exprFactory.CreateClass(_symbolTable.GetCTypeFromType(windowsRuntimeMarshalType), null);
+ ExprClass marshalClass = _exprFactory.CreateClass(_symbolTable.GetCTypeFromType(windowsRuntimeMarshalType));
ExprMemberGroup addEventGrp = CreateMemberGroupEXPR(methodName, new List<Type> { evtType }, marshalClass, SYMKIND.SK_MethodSymbol);
Expr expr = _binder.BindMethodGroupToArguments(
BindingFlag.BIND_RVALUEREQUIRED | BindingFlag.BIND_STMTEXPRONLY,
@@ -1370,7 +1358,7 @@ namespace Microsoft.CSharp.RuntimeBinder
{
// If our argument is a static type, then we're calling a static property.
Expr callingObject = argument.Info.IsStaticType ?
- _exprFactory.CreateClass(_symbolTable.GetCTypeFromType(argument.Value as Type), null) :
+ _exprFactory.CreateClass(_symbolTable.GetCTypeFromType(argument.Value as Type)) :
CreateLocal(argument.Type, argument.Info.IsOut, local);
if (!argument.Info.UseCompileTimeType && argument.Value == null)
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs
index adf0232d42..2756538770 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs
@@ -332,7 +332,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// returns true if an implicit conversion exists from source type to dest type. flags is an optional parameter.
private bool canConvert(CType src, CType dest, CONVERTTYPE flags)
{
- ExprClass exprDest = ExprFactory.MakeClass(dest);
+ ExprClass exprDest = ExprFactory.CreateClass(dest);
return BindImplicitConversion(null, src, exprDest, dest, flags);
}
@@ -349,7 +349,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
private bool canConvert(Expr expr, CType dest, CONVERTTYPE flags)
{
- ExprClass exprDest = ExprFactory.MakeClass(dest);
+ ExprClass exprDest = ExprFactory.CreateClass(dest);
return BindImplicitConversion(expr, expr.Type, exprDest, dest, flags);
}
@@ -446,7 +446,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
private Expr tryConvert(Expr expr, CType dest, CONVERTTYPE flags)
{
Expr exprResult;
- ExprClass exprDest = ExprFactory.MakeClass(dest);
+ ExprClass exprDest = ExprFactory.CreateClass(dest);
if (BindImplicitConversion(expr, expr.Type, exprDest, dest, out exprResult, flags))
{
checkUnsafe(expr.Type); // added to the binder so we don't bind to pointer ops
@@ -463,7 +463,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
private Expr mustConvert(Expr expr, CType dest, CONVERTTYPE flags)
{
- ExprClass exprClass = ExprFactory.MakeClass(dest);
+ ExprClass exprClass = ExprFactory.CreateClass(dest);
return mustConvert(expr, exprClass, flags);
}
private Expr mustConvert(Expr expr, ExprClass dest, CONVERTTYPE flags)
@@ -577,7 +577,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
public Expr mustCast(Expr expr, CType dest, CONVERTTYPE flags)
{
- ExprClass exprDest = ExprFactory.MakeClass(dest);
+ ExprClass exprDest = ExprFactory.CreateClass(dest);
return mustCastCore(expr, exprDest, flags);
}
private Expr mustCastInUncheckedContext(Expr expr, CType dest, CONVERTTYPE flags)
@@ -589,7 +589,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// returns true if an explicit conversion exists from source type to dest type. flags is an optional parameter.
private bool canCast(CType src, CType dest, CONVERTTYPE flags)
{
- ExprClass destExpr = ExprFactory.MakeClass(dest);
+ ExprClass destExpr = ExprFactory.CreateClass(dest);
return BindExplicitConversion(null, src, destExpr, dest, flags);
}
@@ -1376,7 +1376,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
Debug.Assert(0 <= iuciBestSrc && iuciBestSrc < prguci.Count);
Debug.Assert(0 <= iuciBestDst && iuciBestDst < prguci.Count);
ErrorContext.Error(ErrorCode.ERR_AmbigUDConv, prguci[iuciBestSrc].mwt, prguci[iuciBestDst].mwt, typeSrc, typeDst);
- ExprClass exprClass = ExprFactory.MakeClass(typeDst);
+ ExprClass exprClass = ExprFactory.CreateClass(typeDst);
Expr pexprDst = ExprFactory.CreateCast(0, exprClass, exprSrc);
pexprDst.SetError();
return pexprDst;
@@ -1420,12 +1420,12 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
private Expr BindUDConversionCore(Expr pFrom, CType pTypeFrom, CType pTypeTo, CType pTypeDestination, MethWithInst mwiBest, out Expr ppTransformedArgument)
{
- ExprClass pClassFrom = ExprFactory.MakeClass(pTypeFrom);
+ ExprClass pClassFrom = ExprFactory.CreateClass(pTypeFrom);
Expr pTransformedArgument = mustCastCore(pFrom, pClassFrom, CONVERTTYPE.NOUDC);
Debug.Assert(pTransformedArgument != null);
ExprMemberGroup pMemGroup = ExprFactory.CreateMemGroup(null, mwiBest);
ExprCall pCall = ExprFactory.CreateCall(0, pTypeTo, pTransformedArgument, pMemGroup, mwiBest);
- ExprClass pDestination = ExprFactory.MakeClass(pTypeDestination);
+ ExprClass pDestination = ExprFactory.CreateClass(pTypeDestination);
Expr pCast = mustCastCore(pCall, pDestination, CONVERTTYPE.NOUDC);
Debug.Assert(pCast != null);
ppTransformedArgument = pTransformedArgument;
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExplicitConversion.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExplicitConversion.cs
index 60364e3690..b55cf07078 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExplicitConversion.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExplicitConversion.cs
@@ -297,7 +297,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
// Need to box first before unboxing.
Expr exprT;
- ExprClass exprObj = GetExprFactory().MakeClass(_binder.GetReqPDT(PredefinedType.PT_OBJECT));
+ ExprClass exprObj = GetExprFactory().CreateClass(_binder.GetReqPDT(PredefinedType.PT_OBJECT));
_binder.bindSimpleCast(_exprSrc, exprObj, out exprT, EXPRFLAG.EXF_FORCE_BOX);
_exprSrc = exprT;
}
@@ -543,7 +543,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
else
{
- ExprClass underlyingExpr = GetExprFactory().MakeClass(underlyingType);
+ ExprClass underlyingExpr = GetExprFactory().CreateClass(underlyingType);
_binder.bindSimpleCast(_exprSrc, underlyingExpr, out exprCast);
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExprFactory.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExprFactory.cs
index 99ee57626a..159f157f43 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExprFactory.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExprFactory.cs
@@ -17,375 +17,143 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
Debug.Assert(globalSymbolContext != null);
_globalSymbolContext = globalSymbolContext;
}
- private TypeManager GetTypes()
- {
- return _globalSymbolContext.GetTypes();
- }
- private BSYMMGR GetGlobalSymbols()
- {
- return _globalSymbolContext.GetGlobalSymbols();
- }
+ private TypeManager Types => _globalSymbolContext.GetTypes();
- public ExprCall CreateCall(EXPRFLAG nFlags, CType pType, Expr pOptionalArguments, ExprMemberGroup pMemberGroup, MethWithInst MWI)
- {
- Debug.Assert(0 == (nFlags &
- ~(
- EXPRFLAG.EXF_NEWOBJCALL | EXPRFLAG.EXF_CONSTRAINED | EXPRFLAG.EXF_BASECALL |
- EXPRFLAG.EXF_NEWSTRUCTASSG |
- EXPRFLAG.EXF_IMPLICITSTRUCTASSG | EXPRFLAG.EXF_MASK_ANY
- )
- ));
-
- ExprCall rval = new ExprCall(pType);
- rval.Flags = nFlags;
- rval.OptionalArguments = pOptionalArguments;
- rval.MemberGroup = pMemberGroup;
- rval.NullableCallLiftKind = NullableCallLiftKind.NotLifted;
-
- rval.MethWithInst = MWI;
- return rval;
- }
+ private BSYMMGR GlobalSymbols => _globalSymbolContext.GetGlobalSymbols();
- public ExprField CreateField(EXPRFLAG nFlags, CType pType, Expr pOptionalObject, FieldWithType FWT)
- {
- Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_MEMBERSET | EXPRFLAG.EXF_MASK_ANY)));
- ExprField rval = new ExprField(pType);
- rval.Flags = nFlags;
- rval.OptionalObject = pOptionalObject;
- rval.FieldWithType = FWT;
- return rval;
- }
+ public ExprCall CreateCall(EXPRFLAG flags, CType type, Expr arguments, ExprMemberGroup memberGroup, MethWithInst method) =>
+ new ExprCall(type, flags, arguments, memberGroup, method);
- public ExprFuncPtr CreateFunctionPointer(EXPRFLAG nFlags, CType pType, Expr pObject, MethWithInst MWI)
- {
- Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_BASECALL)));
- ExprFuncPtr rval = new ExprFuncPtr(pType);
- rval.Flags = nFlags;
- rval.OptionalObject = pObject;
- rval.MethWithInst = new MethWithInst(MWI);
- return rval;
- }
+ public ExprField CreateField(CType type, Expr optionalObject, FieldWithType field, bool isLValue) =>
+ new ExprField(type, optionalObject, field, isLValue);
- public ExprArrayInit CreateArrayInit(EXPRFLAG nFlags, CType pType, Expr pOptionalArguments, Expr pOptionalArgumentDimensions, int[] pDimSizes)
- {
- Debug.Assert(0 == (nFlags &
- ~(EXPRFLAG.EXF_MASK_ANY | EXPRFLAG.EXF_ARRAYCONST | EXPRFLAG.EXF_ARRAYALLCONST)));
- ExprArrayInit rval = new ExprArrayInit(pType);
- rval.OptionalArguments = pOptionalArguments;
- rval.OptionalArgumentDimensions = pOptionalArgumentDimensions;
- rval.DimensionSizes = pDimSizes;
- rval.DimensionSize = pDimSizes?.Length ?? 0;
- return rval;
- }
+ public ExprFuncPtr CreateFunctionPointer(EXPRFLAG flags, CType type, Expr obj, MethWithInst method) =>
+ new ExprFuncPtr(type, flags, obj, method);
- public ExprProperty CreateProperty(CType pType, Expr pOptionalObject)
- {
- MethPropWithInst mwi = new MethPropWithInst();
- ExprMemberGroup pMemGroup = CreateMemGroup(pOptionalObject, mwi);
- return CreateProperty(pType, null, null, pMemGroup, null, null, null);
- }
+ public ExprArrayInit CreateArrayInit(CType type, Expr arguments, Expr argumentDimensions, int[] dimSizes, int dimSize) =>
+ new ExprArrayInit(type, arguments, argumentDimensions, dimSizes, dimSize);
- public ExprProperty CreateProperty(CType pType, Expr pOptionalObjectThrough, Expr pOptionalArguments, ExprMemberGroup pMemberGroup, PropWithType pwtSlot, MethWithType mwtGet, MethWithType mwtSet)
- {
- ExprProperty rval = new ExprProperty(pType);
- rval.OptionalObjectThrough = pOptionalObjectThrough;
- rval.OptionalArguments = pOptionalArguments;
- rval.MemberGroup = pMemberGroup;
+ public ExprProperty CreateProperty(CType type, Expr optionalObject) =>
+ CreateProperty(type, null, null, CreateMemGroup(optionalObject, new MethPropWithInst()), null, null);
- if (pwtSlot != null)
- {
- rval.PropWithTypeSlot = pwtSlot;
- }
- if (mwtSet != null)
- {
- rval.MethWithTypeSet = mwtSet;
- }
- return rval;
- }
+ public ExprProperty CreateProperty(CType type, Expr optionalObjectThrough, Expr arguments, ExprMemberGroup memberGroup, PropWithType property, MethWithType setMethod) =>
+ new ExprProperty(type, optionalObjectThrough, arguments, memberGroup, property, setMethod);
- public ExprEvent CreateEvent(CType pType, Expr pOptionalObject, EventWithType EWT)
- {
- ExprEvent rval = new ExprEvent(pType);
- rval.OptionalObject = pOptionalObject;
- rval.EventWithType = EWT;
- return rval;
- }
+ public ExprEvent CreateEvent(CType type, Expr optionalObject, EventWithType eventWithType) =>
+ new ExprEvent(type, optionalObject, eventWithType);
- public ExprMemberGroup CreateMemGroup(EXPRFLAG nFlags, Name pName, TypeArray pTypeArgs, SYMKIND symKind, CType pTypePar, MethodOrPropertySymbol pMPS, Expr pObject, CMemberLookupResults memberLookupResults)
- {
- Debug.Assert(0 == (nFlags & ~(
- EXPRFLAG.EXF_CTOR | EXPRFLAG.EXF_INDEXER | EXPRFLAG.EXF_OPERATOR | EXPRFLAG.EXF_NEWOBJCALL |
- EXPRFLAG.EXF_BASECALL | EXPRFLAG.EXF_DELEGATE | EXPRFLAG.EXF_USERCALLABLE | EXPRFLAG.EXF_MASK_ANY
- )
- ));
- ExprMemberGroup rval = new ExprMemberGroup(GetTypes().GetMethGrpType());
- rval.Flags = nFlags;
- rval.Name = pName;
- rval.TypeArgs = pTypeArgs ?? BSYMMGR.EmptyTypeArray();
- rval.SymKind = symKind;
- rval.ParentType = pTypePar;
- rval.OptionalObject = pObject;
- rval.MemberLookupResults = memberLookupResults;
- return rval;
- }
+ public ExprMemberGroup CreateMemGroup(EXPRFLAG flags, Name name, TypeArray typeArgs, SYMKIND symKind, CType parentType, MethodOrPropertySymbol memberSymbol, Expr obj, CMemberLookupResults memberLookupResults) =>
+ new ExprMemberGroup(Types.GetMethGrpType(), flags, name, typeArgs, symKind, parentType, memberSymbol, obj, memberLookupResults);
- public ExprMemberGroup CreateMemGroup(
- Expr pObject,
- MethPropWithInst mwi)
+ public ExprMemberGroup CreateMemGroup(Expr obj, MethPropWithInst method)
{
- Name pName = mwi.Sym?.name;
- MethodOrPropertySymbol methProp = mwi.MethProp();
+ Name name = method.Sym?.name;
+ MethodOrPropertySymbol methProp = method.MethProp();
- CType pType = mwi.GetType() ?? (CType)GetTypes().GetErrorSym();
+ CType type = method.GetType() ?? (CType)Types.GetErrorSym();
- return CreateMemGroup(0, pName, mwi.TypeArgs, methProp?.getKind() ?? SYMKIND.SK_MethodSymbol, mwi.GetType(), methProp, pObject, new CMemberLookupResults(GetGlobalSymbols().AllocParams(1, new CType[] { pType }), pName));
+ return CreateMemGroup(
+ 0, name, method.TypeArgs, methProp?.getKind() ?? SYMKIND.SK_MethodSymbol, method.GetType(), methProp,
+ obj, new CMemberLookupResults(GlobalSymbols.AllocParams(1, new[] {type}), name));
}
- public ExprUserDefinedConversion CreateUserDefinedConversion(Expr arg, Expr call, MethWithInst mwi)
- {
- Debug.Assert(arg != null);
- Debug.Assert(call != null);
- ExprUserDefinedConversion rval = new ExprUserDefinedConversion();
- rval.Argument = arg;
- rval.UserDefinedCall = call;
- rval.UserDefinedCallMethod = mwi;
- if (call.HasError)
- {
- rval.SetError();
- }
- return rval;
- }
+ public ExprUserDefinedConversion CreateUserDefinedConversion(Expr arg, Expr call, MethWithInst method) =>
+ new ExprUserDefinedConversion(arg, call, method);
- public ExprCast CreateCast(EXPRFLAG nFlags, CType pType, Expr pArg)
- {
- return CreateCast(nFlags, CreateClass(pType, null), pArg);
- }
+ public ExprCast CreateCast(CType type, Expr argument) => CreateCast(0, CreateClass(type), argument);
- public ExprCast CreateCast(EXPRFLAG nFlags, ExprClass pType, Expr pArg)
- {
- Debug.Assert(pArg != null);
- Debug.Assert(pType != null);
- Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_CAST_ALL | EXPRFLAG.EXF_MASK_ANY)));
- ExprCast rval = new ExprCast();
- rval.Argument = pArg;
- rval.Flags = nFlags;
- rval.DestinationType = pType;
- return rval;
- }
+ public ExprCast CreateCast(EXPRFLAG flags, ExprClass type, Expr argument) => new ExprCast(flags, type, argument);
- public ExprReturn CreateReturn(EXPRFLAG nFlags, Scope pCurrentScope, Expr pOptionalObject)
- {
- Debug.Assert(0 == (nFlags &
- ~(EXPRFLAG.EXF_ASLEAVE | EXPRFLAG.EXF_FINALLYBLOCKED | EXPRFLAG.EXF_RETURNISYIELD |
- EXPRFLAG.EXF_ASFINALLYLEAVE | EXPRFLAG.EXF_GENERATEDSTMT | EXPRFLAG.EXF_MARKING |
- EXPRFLAG.EXF_MASK_ANY
- )
- ));
- ExprReturn rval = new ExprReturn();
- rval.Flags = nFlags;
- rval.OptionalObject = pOptionalObject;
- return rval;
- }
+ public ExprReturn CreateReturn(Expr optionalObject) => new ExprReturn(optionalObject);
- public ExprLocal CreateLocal(EXPRFLAG nFlags, LocalVariableSymbol pLocal)
- {
- Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_MASK_ANY)));
- ExprLocal rval = new ExprLocal();
- rval.Flags = nFlags;
- rval.Local = pLocal;
- return rval;
- }
+ public ExprLocal CreateLocal(LocalVariableSymbol local) => new ExprLocal(local);
- public ExprBoundLambda CreateAnonymousMethod(AggregateType delegateType)
- {
- Debug.Assert(delegateType == null || delegateType.isDelegateType());
- ExprBoundLambda rval = new ExprBoundLambda(delegateType);
- return rval;
- }
+ public ExprBoundLambda CreateAnonymousMethod(AggregateType delegateType, Scope argumentScope) =>
+ new ExprBoundLambda(delegateType, argumentScope);
- public ExprUnboundLambda CreateLambda()
- {
- ExprUnboundLambda rval = new ExprUnboundLambda(GetTypes().GetAnonMethType());
- return rval;
- }
-
- public ExprHoistedLocalExpr CreateHoistedLocalInExpression(ExprLocal localToHoist)
- {
- Debug.Assert(localToHoist != null);
- return new ExprHoistedLocalExpr(GetTypes().GetOptPredefAgg(PredefinedType.PT_EXPRESSION).getThisType());
- }
+ public ExprHoistedLocalExpr CreateHoistedLocalInExpression() =>
+ new ExprHoistedLocalExpr(Types.GetOptPredefAgg(PredefinedType.PT_EXPRESSION).getThisType());
- public ExprMethodInfo CreateMethodInfo(MethPropWithInst mwi)
- {
- return CreateMethodInfo(mwi.Meth(), mwi.GetType(), mwi.TypeArgs);
- }
+ public ExprMethodInfo CreateMethodInfo(MethPropWithInst mwi) =>
+ CreateMethodInfo(mwi.Meth(), mwi.GetType(), mwi.TypeArgs);
public ExprMethodInfo CreateMethodInfo(MethodSymbol method, AggregateType methodType, TypeArray methodParameters)
{
- Debug.Assert(method != null);
- Debug.Assert(methodType != null);
- ExprMethodInfo methodInfo = new ExprMethodInfo(
- GetTypes().GetOptPredefAgg(method.IsConstructor() ? PredefinedType.PT_CONSTRUCTORINFO : PredefinedType.PT_METHODINFO).getThisType());
- methodInfo.Method = new MethWithInst(method, methodType, methodParameters);
- return methodInfo;
+ return new ExprMethodInfo(
+ Types.GetOptPredefAgg(method.IsConstructor() ? PredefinedType.PT_CONSTRUCTORINFO : PredefinedType.PT_METHODINFO).getThisType(),
+ method, methodType, methodParameters);
}
- public ExprPropertyInfo CreatePropertyInfo(PropertySymbol prop, AggregateType propertyType)
- {
- Debug.Assert(prop != null);
- Debug.Assert(propertyType != null);
- ExprPropertyInfo propInfo = new ExprPropertyInfo(GetTypes().GetOptPredefAgg(PredefinedType.PT_PROPERTYINFO).getThisType());
- propInfo.Property = new PropWithType(prop, propertyType);
- return propInfo;
- }
+ public ExprPropertyInfo CreatePropertyInfo(PropertySymbol prop, AggregateType propertyType) =>
+ new ExprPropertyInfo(Types.GetOptPredefAgg(PredefinedType.PT_PROPERTYINFO).getThisType(), prop, propertyType);
- public ExprFieldInfo CreateFieldInfo(FieldSymbol field, AggregateType fieldType)
- {
- Debug.Assert(field != null);
- Debug.Assert(fieldType != null);
- return new ExprFieldInfo(field, fieldType, GetTypes().GetOptPredefAgg(PredefinedType.PT_FIELDINFO).getThisType());
- }
+ public ExprFieldInfo CreateFieldInfo(FieldSymbol field, AggregateType fieldType) =>
+ new ExprFieldInfo(field, fieldType, Types.GetOptPredefAgg(PredefinedType.PT_FIELDINFO).getThisType());
- private ExprTypeOf CreateTypeOf(ExprClass pSourceType)
- {
- ExprTypeOf rval = new ExprTypeOf(GetTypes().GetReqPredefAgg(PredefinedType.PT_TYPE).getThisType());
- rval.Flags = EXPRFLAG.EXF_CANTBENULL;
- rval.SourceType = pSourceType;
- return rval;
- }
- public ExprTypeOf CreateTypeOf(CType pSourceType)
- {
- return CreateTypeOf(MakeClass(pSourceType));
- }
+ private ExprTypeOf CreateTypeOf(ExprClass sourceType) =>
+ new ExprTypeOf(Types.GetReqPredefAgg(PredefinedType.PT_TYPE).getThisType(), sourceType);
- public ExprUserLogicalOp CreateUserLogOp(CType pType, Expr pCallTF, ExprCall pCallOp)
- {
- Debug.Assert(pCallTF != null);
- Debug.Assert((pCallOp?.OptionalArguments as ExprList)?.OptionalElement != null);
- ExprUserLogicalOp rval = new ExprUserLogicalOp(pType);
- Expr leftChild = ((ExprList)pCallOp.OptionalArguments).OptionalElement;
- Debug.Assert(leftChild != null);
- if (leftChild is ExprWrap wrap)
- {
- // In the EE case, we don't create WRAPEXPRs.
- leftChild = wrap.OptionalExpression;
- Debug.Assert(leftChild != null);
- }
- rval.Flags = EXPRFLAG.EXF_ASSGOP;
- rval.TrueFalseCall = pCallTF;
- rval.OperatorCall = pCallOp;
- rval.FirstOperandToExamine = leftChild;
- return rval;
- }
+ public ExprTypeOf CreateTypeOf(CType sourceType) => CreateTypeOf(CreateClass(sourceType));
- public ExprUserLogicalOp CreateUserLogOpError(CType pType, Expr pCallTF, ExprCall pCallOp)
+ public ExprUserLogicalOp CreateUserLogOp(CType type, Expr trueFalseCall, ExprCall operatorCall) =>
+ new ExprUserLogicalOp(type, trueFalseCall, operatorCall);
+
+ public ExprUserLogicalOp CreateUserLogOpError(CType type, Expr trueFalseCall, ExprCall operatorCall)
{
- ExprUserLogicalOp rval = CreateUserLogOp(pType, pCallTF, pCallOp);
+ ExprUserLogicalOp rval = CreateUserLogOp(type, trueFalseCall, operatorCall);
rval.SetError();
return rval;
}
- public ExprConcat CreateConcat(Expr op1, Expr op2)
- {
- Debug.Assert(op1?.Type != null);
- Debug.Assert(op2?.Type != null);
- Debug.Assert(op1.Type.isPredefType(PredefinedType.PT_STRING) || op2.Type.isPredefType(PredefinedType.PT_STRING));
+ public ExprConcat CreateConcat(Expr first, Expr second) => new ExprConcat(first, second);
- CType type = op1.Type;
- if (!type.isPredefType(PredefinedType.PT_STRING))
- {
- type = op2.Type;
- }
+ public ExprConstant CreateStringConstant(string str) =>
+ CreateConstant(Types.GetReqPredefAgg(PredefinedType.PT_STRING).getThisType(), ConstVal.Get(str));
- Debug.Assert(type.isPredefType(PredefinedType.PT_STRING));
+ public ExprMultiGet CreateMultiGet(EXPRFLAG flags, CType type, ExprMulti multi) =>
+ new ExprMultiGet(type, flags, multi);
- ExprConcat rval = new ExprConcat(type);
- rval.FirstArgument = op1;
- rval.SecondArgument = op2;
- return rval;
- }
-
- public ExprConstant CreateStringConstant(string str)
- {
- return CreateConstant(GetTypes().GetReqPredefAgg(PredefinedType.PT_STRING).getThisType(), ConstVal.Get(str));
- }
-
- public ExprMultiGet CreateMultiGet(EXPRFLAG nFlags, CType pType, ExprMulti pOptionalMulti)
- {
- Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_MASK_ANY)));
- ExprMultiGet rval = new ExprMultiGet(pType);
- rval.Flags = nFlags;
- rval.OptionalMulti = pOptionalMulti;
- return rval;
- }
-
- public ExprMulti CreateMulti(EXPRFLAG nFlags, CType pType, Expr pLeft, Expr pOp)
- {
- Debug.Assert(pLeft != null);
- Debug.Assert(pOp != null);
- ExprMulti rval = new ExprMulti(pType);
- rval.Flags = nFlags;
- rval.Left = pLeft;
- rval.Operator = pOp;
- return rval;
- }
+ public ExprMulti CreateMulti(EXPRFLAG flags, CType type, Expr left, Expr op) =>
+ new ExprMulti(type, flags, left, op);
////////////////////////////////////////////////////////////////////////////////
//
// Precondition:
//
- // pType - Non-null
+ // type - Non-null
//
// This returns a null for reference types and an EXPRZEROINIT for all others.
- public Expr CreateZeroInit(CType pType)
- {
- ExprClass exprClass = MakeClass(pType);
- return CreateZeroInit(exprClass);
- }
+ public Expr CreateZeroInit(CType type) => CreateZeroInit(CreateClass(type), null, false);
- private Expr CreateZeroInit(ExprClass pTypeExpr)
+ private Expr CreateZeroInit(ExprClass typeExpr, Expr originalConstructorCall, bool isConstructor)
{
- return CreateZeroInit(pTypeExpr, null, false);
- }
+ Debug.Assert(typeExpr != null);
+ CType type = typeExpr.Type;
+ bool isError = false;
- private Expr CreateZeroInit(ExprClass pTypeExpr, Expr pOptionalOriginalConstructorCall, bool isConstructor)
- {
- Debug.Assert(pTypeExpr != null);
- CType pType = pTypeExpr.Type;
- bool bIsError = false;
-
- if (pType.isEnumType())
+ if (type.isEnumType())
{
// For enum types, we create a constant that has the default value
// as an object pointer.
- ExprConstant expr = CreateConstant(pType, ConstVal.Get(Activator.CreateInstance(pType.AssociatedSystemType)));
- return expr;
+ return CreateConstant(type, ConstVal.Get(Activator.CreateInstance(type.AssociatedSystemType)));
}
- switch (pType.fundType())
+ switch (type.fundType())
{
- default:
- bIsError = true;
- break;
-
case FUNDTYPE.FT_PTR:
{
- CType nullType = GetTypes().GetNullType();
+ CType nullType = Types.GetNullType();
// It looks like this if is always false ...
- if (nullType.fundType() == pType.fundType())
+ if (nullType.fundType() == type.fundType())
{
// Create a constant here.
-
- ExprConstant expr = CreateConstant(pType, ConstVal.GetDefaultValue(ConstValKind.IntPtr));
- return (expr);
+ return CreateConstant(type, ConstVal.GetDefaultValue(ConstValKind.IntPtr));
}
// Just allocate a new node and fill it in.
-
- ExprCast cast = CreateCast(0, pTypeExpr, CreateNull());
- return (cast);
+ return CreateCast(0, typeExpr, CreateNull());
}
case FUNDTYPE.FT_REF:
@@ -399,215 +167,103 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
case FUNDTYPE.FT_U8:
case FUNDTYPE.FT_R4:
case FUNDTYPE.FT_R8:
- {
- ExprConstant expr = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind()));
- ExprConstant exprInOriginal = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind()));
- exprInOriginal.OptionalConstructorCall = pOptionalOriginalConstructorCall;
- return expr;
- }
+ return CreateConstant(type, ConstVal.GetDefaultValue(type.constValKind()));
case FUNDTYPE.FT_STRUCT:
- if (pType.isPredefType(PredefinedType.PT_DECIMAL))
+ if (type.isPredefType(PredefinedType.PT_DECIMAL))
{
- ExprConstant expr = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind()));
- ExprConstant exprOriginal = CreateConstant(pType, ConstVal.GetDefaultValue(pType.constValKind()));
- exprOriginal.OptionalConstructorCall = pOptionalOriginalConstructorCall;
- return expr;
+ goto case FUNDTYPE.FT_R8;
}
+
break;
case FUNDTYPE.FT_VAR:
break;
- }
-
- ExprZeroInit rval = new ExprZeroInit(pType);
- rval.OptionalConstructorCall = pOptionalOriginalConstructorCall;
- rval.IsConstructor = isConstructor;
- if (bIsError)
- {
- rval.SetError();
+ default:
+ isError = true;
+ break;
}
- return rval;
+ return new ExprZeroInit(type, originalConstructorCall, isConstructor, isError);
}
- public ExprConstant CreateConstant(CType pType, ConstVal constVal)
- {
- ExprConstant rval = CreateConstant(pType);
- rval.Val = constVal;
- return rval;
- }
+ public ExprConstant CreateConstant(CType type, ConstVal constVal) => new ExprConstant(type, constVal);
- private ExprConstant CreateConstant(CType pType)
- {
- return new ExprConstant(pType);
- }
+ public ExprConstant CreateIntegerConstant(int x) =>
+ CreateConstant(Types.GetReqPredefAgg(PredefinedType.PT_INT).getThisType(), ConstVal.Get(x));
- public ExprConstant CreateIntegerConstant(int x)
- {
- return CreateConstant(GetTypes().GetReqPredefAgg(PredefinedType.PT_INT).getThisType(), ConstVal.Get(x));
- }
- public ExprConstant CreateBoolConstant(bool b)
- {
- return CreateConstant(GetTypes().GetReqPredefAgg(PredefinedType.PT_BOOL).getThisType(), ConstVal.Get(b));
- }
+ public ExprConstant CreateBoolConstant(bool b) =>
+ CreateConstant(Types.GetReqPredefAgg(PredefinedType.PT_BOOL).getThisType(), ConstVal.Get(b));
- public ExprBlock CreateBlock(ExprStatement pOptionalStatements, Scope pOptionalScope)
- {
- ExprBlock rval = new ExprBlock();
- rval.OptionalStatements = pOptionalStatements;
- rval.OptionalScopeSymbol = pOptionalScope;
- return rval;
- }
+ public ExprBlock CreateBlock(ExprStatement pOptionalStatements) => new ExprBlock(pOptionalStatements);
- public ExprArrayIndex CreateArrayIndex(Expr pArray, Expr pIndex)
+ public ExprArrayIndex CreateArrayIndex(Expr array, Expr index)
{
- CType pType = pArray.Type;
-
- if (pType != null && pType.IsArrayType())
+ CType type = array.Type;
+ if (type is ArrayType arr)
{
- pType = pType.AsArrayType().GetElementType();
+ type = arr.GetElementType();
}
- else if (pType == null)
+ else if (type == null)
{
- pType = GetTypes().GetReqPredefAgg(PredefinedType.PT_INT).getThisType();
+ type = Types.GetReqPredefAgg(PredefinedType.PT_INT).getThisType();
}
- ExprArrayIndex pResult = new ExprArrayIndex(pType);
- pResult.Array = pArray;
- pResult.Index = pIndex;
- return pResult;
- }
- public ExprBinOp CreateBinop(ExpressionKind exprKind, CType pType, Expr p1, Expr p2)
- {
- //Debug.Assert(exprKind.isBinaryOperator());
- ExprBinOp rval = new ExprBinOp(exprKind, pType);
- rval.Flags = EXPRFLAG.EXF_BINOP;
- rval.OptionalLeftChild = p1;
- rval.OptionalRightChild = p2;
- return rval;
+ return new ExprArrayIndex(type, array, index);
}
- public ExprUnaryOp CreateUnaryOp(ExpressionKind exprKind, CType pType, Expr pOperand)
- {
- Debug.Assert(exprKind.IsUnaryOperator());
- Debug.Assert(pOperand != null);
- ExprUnaryOp rval = new ExprUnaryOp(exprKind, pType);
- rval.Child = pOperand;
- return rval;
- }
+ public ExprBinOp CreateBinop(ExpressionKind exprKind, CType type, Expr left, Expr right) =>
+ new ExprBinOp(exprKind, type, left, right);
+
+ public ExprUnaryOp CreateUnaryOp(ExpressionKind exprKind, CType type, Expr operand) =>
+ new ExprUnaryOp(exprKind, type, operand);
- public ExprOperator CreateOperator(ExpressionKind exprKind, CType pType, Expr pArg1, Expr pOptionalArg2)
+ public ExprOperator CreateOperator(ExpressionKind exprKind, CType type, Expr arg1, Expr arg2)
{
- Debug.Assert(pArg1 != null);
- Debug.Assert(exprKind.IsUnaryOperator() ? pOptionalArg2 == null : pOptionalArg2 != null);
+ Debug.Assert(arg1 != null);
+ Debug.Assert(exprKind.IsUnaryOperator() == (arg2 == null));
return exprKind.IsUnaryOperator()
- ? (ExprOperator)CreateUnaryOp(exprKind, pType, pArg1)
- : CreateBinop(exprKind, pType, pArg1, pOptionalArg2);
+ ? (ExprOperator)CreateUnaryOp(exprKind, type, arg1)
+ : CreateBinop(exprKind, type, arg1, arg2);
}
- public ExprBinOp CreateUserDefinedBinop(ExpressionKind exprKind, CType pType, Expr p1, Expr p2, Expr call, MethPropWithInst pmpwi)
- {
- Debug.Assert(p1 != null);
- Debug.Assert(p2 != null);
- Debug.Assert(call != null);
- ExprBinOp rval = new ExprBinOp(exprKind, pType);
- rval.Flags = EXPRFLAG.EXF_BINOP;
- rval.OptionalLeftChild = p1;
- rval.OptionalRightChild = p2;
- rval.OptionalUserDefinedCall = call;
- rval.UserDefinedCallMethod = pmpwi;
- if (call.HasError)
- {
- rval.SetError();
- }
- return rval;
- }
+ public ExprBinOp CreateUserDefinedBinop(ExpressionKind exprKind, CType type, Expr left, Expr right, Expr call, MethPropWithInst userMethod) =>
+ new ExprBinOp(exprKind, type, left, right, call, userMethod);
- public ExprUnaryOp CreateUserDefinedUnaryOperator(ExpressionKind exprKind, CType pType, Expr pOperand, ExprCall call, MethPropWithInst pmpwi)
- {
- Debug.Assert(pType != null);
- Debug.Assert(pOperand != null);
- Debug.Assert(call != null);
- Debug.Assert(pmpwi != null);
- ExprUnaryOp rval = new ExprUnaryOp(exprKind, pType);
- rval.Child = pOperand;
- // The call may be lifted, but we do not mark the outer binop as lifted.
- rval.OptionalUserDefinedCall = call;
- rval.UserDefinedCallMethod = pmpwi;
- if (call.HasError)
- {
- rval.SetError();
- }
- return rval;
- }
+ // The call may be lifted, but we do not mark the outer binop as lifted.
+ public ExprUnaryOp CreateUserDefinedUnaryOperator(ExpressionKind exprKind, CType type, Expr operand, ExprCall call, MethPropWithInst userMethod) =>
+ new ExprUnaryOp(exprKind, type, operand, call, userMethod);
- public ExprUnaryOp CreateNeg(EXPRFLAG nFlags, Expr pOperand)
+ public ExprUnaryOp CreateNeg(EXPRFLAG flags, Expr operand)
{
- Debug.Assert(pOperand != null);
- ExprUnaryOp pUnaryOp = CreateUnaryOp(ExpressionKind.Negate, pOperand.Type, pOperand);
- pUnaryOp.Flags |= nFlags;
- return pUnaryOp;
+ Debug.Assert(operand != null);
+ ExprUnaryOp unary = CreateUnaryOp(ExpressionKind.Negate, operand.Type, operand);
+ unary.Flags |= flags;
+ return unary;
}
////////////////////////////////////////////////////////////////////////////////
// Create a node that evaluates the first, evaluates the second, results in the second.
- public ExprBinOp CreateSequence(Expr p1, Expr p2)
- {
- Debug.Assert(p1 != null);
- Debug.Assert(p2 != null);
- return CreateBinop(ExpressionKind.Sequence, p2.Type, p1, p2);
- }
+ public ExprBinOp CreateSequence(Expr first, Expr second) =>
+ CreateBinop(ExpressionKind.Sequence, second.Type, first, second);
////////////////////////////////////////////////////////////////////////////////
// Create a node that evaluates the first, evaluates the second, results in the first.
- public ExprBinOp CreateReverseSequence(Expr p1, Expr p2)
- {
- Debug.Assert(p1 != null);
- Debug.Assert(p2 != null);
- return CreateBinop(ExpressionKind.SequenceReverse, p1.Type, p1, p2);
- }
+ public ExprBinOp CreateReverseSequence(Expr first, Expr second) =>
+ CreateBinop(ExpressionKind.SequenceReverse, first.Type, first, second);
- public ExprAssignment CreateAssignment(Expr pLHS, Expr pRHS)
- {
- ExprAssignment pAssignment = new ExprAssignment();
- pAssignment.Flags = EXPRFLAG.EXF_ASSGOP;
- pAssignment.LHS = pLHS;
- pAssignment.RHS = pRHS;
- return pAssignment;
- }
+ public ExprAssignment CreateAssignment(Expr left, Expr right) => new ExprAssignment(left, right);
////////////////////////////////////////////////////////////////////////////////
- public ExprNamedArgumentSpecification CreateNamedArgumentSpecification(Name pName, Expr pValue)
- {
- ExprNamedArgumentSpecification pResult = new ExprNamedArgumentSpecification();
- pResult.Value = pValue;
- pResult.Name = pName;
-
- return pResult;
- }
+ public ExprNamedArgumentSpecification CreateNamedArgumentSpecification(Name name, Expr value) =>
+ new ExprNamedArgumentSpecification(name, value);
+ public ExprWrap CreateWrap(Expr expression) => new ExprWrap(expression);
- public ExprWrap CreateWrap(
- Scope pCurrentScope,
- Expr pOptionalExpression
- )
- {
- ExprWrap rval = new ExprWrap();
- rval.OptionalExpression = pOptionalExpression;
- rval.Flags = EXPRFLAG.EXF_LVALUE;
-
- return rval;
- }
- public ExprWrap CreateWrapNoAutoFree(Scope pCurrentScope, Expr pOptionalWrap)
- {
- ExprWrap rval = CreateWrap(pCurrentScope, pOptionalWrap);
- return rval;
- }
public ExprBinOp CreateSave(ExprWrap wrap)
{
Debug.Assert(wrap != null);
@@ -616,10 +272,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
return expr;
}
- public ExprConstant CreateNull()
- {
- return CreateConstant(GetTypes().GetNullType(), default(ConstVal));
- }
+ public ExprConstant CreateNull() => CreateConstant(Types.GetNullType(), default(ConstVal));
public void AppendItemToList(
Expr newItem,
@@ -653,41 +306,14 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
last = list.OptionalNextListNode;
}
- public ExprList CreateList(Expr op1, Expr op2)
- {
- ExprList rval = new ExprList();
- rval.OptionalElement = op1;
- rval.OptionalNextListNode = op2;
- return rval;
- }
- public ExprList CreateList(Expr op1, Expr op2, Expr op3)
- {
- return CreateList(op1, CreateList(op2, op3));
- }
- public ExprList CreateList(Expr op1, Expr op2, Expr op3, Expr op4)
- {
- return CreateList(op1, CreateList(op2, CreateList(op3, op4)));
- }
- public ExprTypeArguments CreateTypeArguments(TypeArray pTypeArray, Expr pOptionalElements)
- {
- Debug.Assert(pTypeArray != null);
- ExprTypeArguments rval = new ExprTypeArguments();
- rval.OptionalElements = pOptionalElements;
- return rval;
- }
+ public ExprList CreateList(Expr op1, Expr op2) => new ExprList(op1, op2);
- public ExprClass CreateClass(CType pType, ExprTypeArguments pOptionalTypeArguments)
- {
- Debug.Assert(pType != null);
- ExprClass rval = new ExprClass(pType);
- return rval;
- }
+ public ExprList CreateList(Expr op1, Expr op2, Expr op3) => CreateList(op1, CreateList(op2, op3));
- public ExprClass MakeClass(CType pType)
- {
- Debug.Assert(pType != null);
- return CreateClass(pType, null/* type arguments */);
- }
+ public ExprList CreateList(Expr op1, Expr op2, Expr op3, Expr op4) =>
+ CreateList(op1, CreateList(op2, CreateList(op3, op4)));
+
+ public ExprClass CreateClass(CType type) => new ExprClass(type);
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs
index 30b08a7a4c..ee75e7b38e 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs
@@ -395,11 +395,11 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
if (allowExplicit)
{
- return mustCastCore(op2, GetExprFactory().MakeClass(op1.Type), 0);
+ return mustCastCore(op2, GetExprFactory().CreateClass(op1.Type), 0);
}
else
{
- return mustConvertCore(op2, GetExprFactory().MakeClass(op1.Type));
+ return mustConvertCore(op2, GetExprFactory().CreateClass(op1.Type));
}
}
@@ -472,7 +472,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
Expr pTemp = mustConvert(x, pDestType);
if (pDestType == pIntType)
return pTemp;
- ExprClass exprType = GetExprFactory().MakeClass(pDestType);
+ ExprClass exprType = GetExprFactory().CreateClass(pDestType);
return GetExprFactory().CreateCast(EXPRFLAG.EXF_INDEXEXPR, exprType, pTemp);
});
@@ -697,7 +697,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
CType pFieldType = GetTypes().SubstType(fwt.Field().GetType(), fwt.GetType());
if (pOptionalObject != null && !pOptionalObject.IsOK)
{
- ExprField pField = GetExprFactory().CreateField(0, pFieldType, pOptionalObject, fwt);
+ ExprField pField = GetExprFactory().CreateField(pFieldType, pOptionalObject, fwt, false);
pField.SetError();
return pField;
}
@@ -738,7 +738,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
ExprField pResult = GetExprFactory()
- .CreateField(isLValue ? EXPRFLAG.EXF_LVALUE : 0, pFieldType, pOptionalObject, fwt);
+ .CreateField(pFieldType, pOptionalObject, fwt, isLValue);
if (!bIsMatchingStatic)
{
pResult.SetMismatchedStaticBit();
@@ -848,7 +848,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
if (pObject != null && !pObject.IsOK)
{
- ExprProperty pResult = GetExprFactory().CreateProperty(pReturnType, pObjectThrough, args, pMemGroup, pwt, null, null);
+ ExprProperty pResult = GetExprFactory().CreateProperty(pReturnType, pObjectThrough, args, pMemGroup, pwt, null);
if (!bIsMatchingStatic)
{
pResult.SetMismatchedStaticBit();
@@ -866,7 +866,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
if (pOtherType != null)
{
- return GetExprFactory().MakeClass(pOtherType);
+ return GetExprFactory().CreateClass(pOtherType);
}
ErrorContext.ErrorRef(ErrorCode.ERR_PropertyLacksGet, pwt);
}
@@ -875,7 +875,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// if the get exists, but is abstract, forbid the call as well...
if (pOtherType != null)
{
- return GetExprFactory().MakeClass(pOtherType);
+ return GetExprFactory().CreateClass(pOtherType);
}
ErrorContext.Error(ErrorCode.ERR_AbstractBaseCall, pwt);
}
@@ -893,7 +893,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// if the get exists, but is not accessible, give an error.
if (pOtherType != null)
{
- return GetExprFactory().MakeClass(pOtherType);
+ return GetExprFactory().CreateClass(pOtherType);
}
if (error == ACCESSERROR.ACCESSERROR_NOACCESSTHRU)
@@ -908,7 +908,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
}
- ExprProperty result = GetExprFactory().CreateProperty(pReturnType, pObjectThrough, args, pMemGroup, pwt, mwtGet, mwtSet);
+ ExprProperty result = GetExprFactory().CreateProperty(pReturnType, pObjectThrough, args, pMemGroup, pwt, mwtSet);
if (!bIsMatchingStatic)
{
result.SetMismatchedStaticBit();
@@ -1394,7 +1394,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
break;
case ExpressionKind.BoundLambda:
- case ExpressionKind.UnboundLambda:
case ExpressionKind.Constant:
ErrorContext.Error(GetStandardLvalueError(kind));
return false;
@@ -1811,10 +1810,8 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
CType elemType = arrayType.AsArrayType().GetElementType();
// Use an EK_ARRINIT even in the empty case so empty param arrays in attributes work.
- ExprArrayInit arrayInit = GetExprFactory().CreateArrayInit(0, arrayType, null, null, null);
+ ExprArrayInit arrayInit = GetExprFactory().CreateArrayInit(arrayType, null, null, new[] { 0 }, 1);
arrayInit.GeneratedForParamArray = true;
- arrayInit.DimensionSizes = new[] {arrayInit.DimensionSize};
- arrayInit.DimensionSize = 1;
arrayInit.OptionalArguments = named.Value;
named.Value = arrayInit;
@@ -1891,9 +1888,8 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
CType elementType = substitutedArrayType.AsArrayType().GetElementType();
// Use an EK_ARRINIT even in the empty case so empty param arrays in attributes work.
- ExprArrayInit exprArrayInit = GetExprFactory().CreateArrayInit(0, substitutedArrayType, null, null, null);
+ ExprArrayInit exprArrayInit = GetExprFactory().CreateArrayInit(substitutedArrayType, null, null, new[] { 0 }, 1);
exprArrayInit.GeneratedForParamArray = true;
- exprArrayInit.DimensionSizes = new int[] { exprArrayInit.DimensionSize };
if (it.AtEnd())
{
@@ -2347,7 +2343,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
private ExprWrap WrapShortLivedExpression(Expr expr)
{
- return GetExprFactory().CreateWrap(null, expr);
+ return GetExprFactory().CreateWrap(expr);
}
private ExprAssignment GenerateOptimizedAssignment(Expr op1, Expr op2)
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionKind.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionKind.cs
index b0176522c3..bf426faa47 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionKind.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionKind.cs
@@ -53,7 +53,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
//EK_TYPEORSIMPLENAME,
// The following exprs are used to represent the results of typebinding.
// Look in exprnodes.h for a more detailed description.
- TypeArguments,
+ //TypeArguments,
//EK_TYPEORNAMESPACE,
//EK_TYPEORNAMESPACEERROR,
//EK_ARRAYTYPE,
@@ -86,7 +86,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
UserLogicalOp,
MemberGroup,
BoundLambda,
- UnboundLambda,
+ //UnboundLambda,
//EK_LAMBDAPARAMETER,
HoistedLocalExpression,
FieldInfo,
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GroupToArgsBinder.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GroupToArgsBinder.cs
index 124f1892c7..25a8d40341 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GroupToArgsBinder.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/GroupToArgsBinder.cs
@@ -647,11 +647,11 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
Name name = NameManager.GetPredefinedName(PredefinedName.PN_CAP_VALUE);
FieldSymbol field = symbolLoader.LookupAggMember(name, agg, symbmask_t.MASK_FieldSymbol).AsFieldSymbol();
FieldWithType fwt = new FieldWithType(field, agg.getThisType());
- ExprField exprField = exprFactory.CreateField(0, agg.getThisType(), null, fwt);
+ ExprField exprField = exprFactory.CreateField(agg.getThisType(), null, fwt, false);
if (agg.getThisType() != type)
{
- optionalArgument = exprFactory.CreateCast(0, type, exprField);
+ optionalArgument = exprFactory.CreateCast(type, exprField);
}
else
{
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ImplicitConversion.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ImplicitConversion.cs
index c4c1bf588d..c9eb5ae21d 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ImplicitConversion.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ImplicitConversion.cs
@@ -334,9 +334,8 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
bool dstWasNullable;
bool srcWasNullable;
CType typeDstBase = nubDst.StripNubs(out dstWasNullable);
- ExprClass exprTypeDstBase = GetExprFactory().MakeClass(typeDstBase);
+ ExprClass exprTypeDstBase = GetExprFactory().CreateClass(typeDstBase);
CType typeSrcBase = _typeSrc.StripNubs(out srcWasNullable);
-
ConversionFunc pfn = (_flags & CONVERTTYPE.ISEXPLICIT) != 0 ?
(ConversionFunc)_binder.BindExplicitConversion :
(ConversionFunc)_binder.BindImplicitConversion;
@@ -359,7 +358,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
else
{
- _exprDest = GetExprFactory().CreateCast(0x00, _typeDest, _exprSrc);
+ _exprDest = GetExprFactory().CreateCast(_typeDest, _exprSrc);
}
}
return true;
@@ -418,7 +417,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// Here we want to first check whether or not the conversions work on the base types.
Expr arg1 = _binder.mustCast(_exprSrc, typeSrcBase);
- ExprClass arg2 = GetExprFactory().MakeClass(typeDstBase);
+ ExprClass arg2 = GetExprFactory().CreateClass(typeDstBase);
bool convertible;
if (0 != (_flags & CONVERTTYPE.ISEXPLICIT))
@@ -468,7 +467,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
else
{
- _exprDest = GetExprFactory().CreateCast(0x00, _typeDest, _exprSrc);
+ _exprDest = GetExprFactory().CreateCast(_typeDest, _exprSrc);
}
}
return true;
@@ -850,7 +849,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
// For a type var destination we need to cast to object then to the other type var.
Expr exprT;
- ExprClass exprObj = GetExprFactory().MakeClass(_binder.GetReqPDT(PredefinedType.PT_OBJECT));
+ ExprClass exprObj = GetExprFactory().CreateClass(_binder.GetReqPDT(PredefinedType.PT_OBJECT));
_binder.bindSimpleCast(_exprSrc, exprObj, out exprT, EXPRFLAG.EXF_FORCE_BOX);
_binder.bindSimpleCast(exprT, _exprTypeDest, out _exprDest, EXPRFLAG.EXF_FORCE_UNBOX);
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Nullable.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Nullable.cs
index 19dbea7e2f..b23fc44509 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Nullable.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Nullable.cs
@@ -84,10 +84,9 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
PropWithType pwt = new PropWithType(prop, ats);
- MethWithType mwt = new MethWithType(prop?.methGet, ats);
MethPropWithInst mpwi = new MethPropWithInst(prop, ats);
ExprMemberGroup pMemGroup = GetExprFactory().CreateMemGroup(exprSrc, mpwi);
- ExprProperty exprRes = GetExprFactory().CreateProperty(typeBase, null, null, pMemGroup, pwt, mwt, null);
+ ExprProperty exprRes = GetExprFactory().CreateProperty(typeBase, null, null, pMemGroup, pwt, null);
if (prop == null)
{
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs
index 9baae2a213..298f7db8f5 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs
@@ -2413,7 +2413,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
if (ptOp == PredefinedType.PT_UINT && op.Type.fundType() == FUNDTYPE.FT_U4)
{
- ExprClass exprObj = GetExprFactory().MakeClass(GetReqPDT(PredefinedType.PT_LONG));
+ ExprClass exprObj = GetExprFactory().CreateClass(GetReqPDT(PredefinedType.PT_LONG));
op = mustConvertCore(op, exprObj, CONVERTTYPE.NOUDC);
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayIndex.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayIndex.cs
index 8db2d0d667..adb9efb030 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayIndex.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayIndex.cs
@@ -6,9 +6,11 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprArrayIndex : ExprWithType
{
- public ExprArrayIndex(CType type)
+ public ExprArrayIndex(CType type, Expr array, Expr index)
: base(ExpressionKind.ArrayIndex, type)
{
+ Array = array;
+ Index = index;
}
public Expr Array { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayInitialization.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayInitialization.cs
index c059c57f5e..c5abebfffd 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayInitialization.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayInitialization.cs
@@ -6,9 +6,13 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprArrayInit : ExprWithType
{
- public ExprArrayInit(CType type)
+ public ExprArrayInit(CType type, Expr arguments, Expr argumentDimensions, int[] dimensionSizes, int dimensionSize)
: base(ExpressionKind.ArrayInit, type)
{
+ OptionalArguments = arguments;
+ OptionalArgumentDimensions = argumentDimensions;
+ DimensionSizes = dimensionSizes;
+ DimensionSize = dimensionSize;
}
public Expr OptionalArguments { get; set; }
@@ -16,7 +20,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
public Expr OptionalArgumentDimensions { get; set; }
// The Exprs bound as the size of the array.
- public int[] DimensionSizes { get; set; }
+ public int[] DimensionSizes { get; }
public int DimensionSize { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Assignment.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Assignment.cs
index 6337aaaf19..5294ff0189 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Assignment.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Assignment.cs
@@ -6,9 +6,12 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprAssignment : Expr
{
- public ExprAssignment()
+ public ExprAssignment(Expr lhs, Expr rhs)
: base(ExpressionKind.Assignment)
{
+ LHS = lhs;
+ RHS = rhs;
+ Flags = EXPRFLAG.EXF_ASSGOP;
}
public Expr LHS { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BinaryOperator.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BinaryOperator.cs
index 0f67f9b54f..82afe7bf0e 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BinaryOperator.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BinaryOperator.cs
@@ -8,10 +8,27 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprBinOp : ExprOperator
{
- public ExprBinOp(ExpressionKind kind, CType type)
+ public ExprBinOp(ExpressionKind kind, CType type, Expr left, Expr right)
: base(kind, type)
{
Debug.Assert(kind > ExpressionKind.TypeLimit);
+ Debug.Assert(left != null);
+ Debug.Assert(right != null);
+ Flags = EXPRFLAG.EXF_BINOP;
+ OptionalLeftChild = left;
+ OptionalRightChild = right;
+ }
+
+ public ExprBinOp(ExpressionKind kind, CType type, Expr left, Expr right, Expr call, MethPropWithInst userMethod)
+ : base(kind, type, call, userMethod)
+ {
+ Debug.Assert(kind > ExpressionKind.TypeLimit);
+ Debug.Assert(left != null);
+ Debug.Assert(right != null);
+ Debug.Assert(call != null);
+ Flags = EXPRFLAG.EXF_BINOP;
+ OptionalLeftChild = left;
+ OptionalRightChild = right;
}
public Expr OptionalLeftChild { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Block.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Block.cs
index e365765a8c..25fdeab7df 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Block.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Block.cs
@@ -6,13 +6,12 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprBlock : ExprStatement
{
- public ExprBlock()
+ public ExprBlock(ExprStatement optionalStatements)
: base(ExpressionKind.Block)
{
+ OptionalStatements = optionalStatements;
}
public ExprStatement OptionalStatements { get; set; }
-
- public Scope OptionalScopeSymbol { get; set; }
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BoundAnonymousFunction.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BoundAnonymousFunction.cs
index 2f12c3362e..9b0c05972e 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BoundAnonymousFunction.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BoundAnonymousFunction.cs
@@ -8,12 +8,12 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprBoundLambda : ExprWithType
{
- private Scope _argumentScope;
-
- public ExprBoundLambda(CType type)
+ public ExprBoundLambda(CType type, Scope argumentScope)
: base(ExpressionKind.BoundLambda, type)
{
Debug.Assert(type == null || type.isDelegateType());
+ Debug.Assert(argumentScope != null);
+ ArgumentScope = argumentScope;
}
public ExprBlock OptionalBody { get; set; }
@@ -23,18 +23,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// The scope containing the names of the parameters
// The scope that will hold this anonymous function. This starts off as the outer scope and is then
// ratcheted down to the correct scope after the containing method is fully bound.
- public Scope ArgumentScope
- {
- get
- {
- Debug.Assert(_argumentScope != null);
- return _argumentScope;
- }
- set
- {
- Debug.Assert(value != null);
- _argumentScope = value;
- }
- }
+ public Scope ArgumentScope { get; }
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Call.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Call.cs
index e8cba5393c..fe02b8ff3d 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Call.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Call.cs
@@ -2,13 +2,23 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprCall : ExprWithType, IExprWithArgs
{
- public ExprCall(CType type)
+ public ExprCall(CType type, EXPRFLAG flags, Expr arguments, ExprMemberGroup member, MethWithInst method)
: base(ExpressionKind.Call, type)
{
+ Debug.Assert(
+ (flags & ~(EXPRFLAG.EXF_NEWOBJCALL | EXPRFLAG.EXF_CONSTRAINED | EXPRFLAG.EXF_BASECALL
+ | EXPRFLAG.EXF_NEWSTRUCTASSG | EXPRFLAG.EXF_IMPLICITSTRUCTASSG | EXPRFLAG.EXF_MASK_ANY)) == 0);
+ Flags = flags;
+ OptionalArguments = arguments;
+ MemberGroup = member;
+ NullableCallLiftKind = NullableCallLiftKind.NotLifted;
+ MethWithInst = method;
}
public Expr OptionalArguments { get; set; }
@@ -17,8 +27,8 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
public Expr OptionalObject
{
- get { return MemberGroup.OptionalObject; }
- set { MemberGroup.OptionalObject = value; }
+ get => MemberGroup.OptionalObject;
+ set => MemberGroup.OptionalObject = value;
}
public MethWithInst MethWithInst { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Cast.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Cast.cs
index 26f5793cd7..e76a520fbb 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Cast.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Cast.cs
@@ -2,13 +2,21 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprCast : Expr
{
- public ExprCast()
+ public ExprCast(EXPRFLAG flags, ExprClass destinationType, Expr argument)
: base(ExpressionKind.Cast)
- {
+ {
+ Debug.Assert(argument != null);
+ Debug.Assert(destinationType != null);
+ Debug.Assert((flags & ~(EXPRFLAG.EXF_CAST_ALL | EXPRFLAG.EXF_MASK_ANY)) == 0);
+ Argument = argument;
+ Flags = flags;
+ DestinationType = destinationType;
}
public Expr Argument { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Class.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Class.cs
index bd4dfbe463..4975d4c62a 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Class.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Class.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprClass : ExprWithType
@@ -9,6 +11,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
public ExprClass(CType type)
: base(ExpressionKind.Class, type)
{
+ Debug.Assert(type != null);
}
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/CompoundOperator.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/CompoundOperator.cs
index 6139ce67ee..af3ccd3cd0 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/CompoundOperator.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/CompoundOperator.cs
@@ -2,13 +2,18 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprMultiGet : ExprWithType
{
- public ExprMultiGet(CType type)
+ public ExprMultiGet(CType type, EXPRFLAG flags, ExprMulti multi)
: base(ExpressionKind.MultiGet, type)
{
+ Debug.Assert((flags & ~EXPRFLAG.EXF_MASK_ANY) == 0);
+ Flags = flags;
+ OptionalMulti = multi;
}
public ExprMulti OptionalMulti { get; set; }
@@ -16,9 +21,14 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
internal sealed class ExprMulti : ExprWithType
{
- public ExprMulti(CType type)
+ public ExprMulti(CType type, EXPRFLAG flags, Expr left, Expr op)
: base(ExpressionKind.Multi, type)
{
+ Debug.Assert(left != null);
+ Debug.Assert(op != null);
+ Flags = flags;
+ Left = left;
+ Operator = op;
}
public Expr Left { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Concatenate.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Concatenate.cs
index d7c6c47561..0d94074549 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Concatenate.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Concatenate.cs
@@ -2,13 +2,33 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+using Microsoft.CSharp.RuntimeBinder.Syntax;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprConcat : ExprWithType
{
- public ExprConcat(CType type)
- : base(ExpressionKind.Concat ,type)
+ public ExprConcat(Expr first, Expr second)
+ : base(ExpressionKind.Concat, TypeFromOperands(first, second))
{
+ Debug.Assert(first?.Type != null);
+ Debug.Assert(second?.Type != null);
+ Debug.Assert(first.Type.isPredefType(PredefinedType.PT_STRING) || second.Type.isPredefType(PredefinedType.PT_STRING));
+ FirstArgument = first;
+ SecondArgument = second;
+ }
+
+ private static CType TypeFromOperands(Expr first, Expr second)
+ {
+ CType type = first.Type;
+ if (type.isPredefType(PredefinedType.PT_STRING))
+ {
+ return type;
+ }
+
+ Debug.Assert(second.Type.isPredefType(PredefinedType.PT_STRING));
+ return second.Type;
}
public Expr FirstArgument { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Constant.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Constant.cs
index bb8a77cfd8..6a115a5f66 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Constant.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Constant.cs
@@ -8,16 +8,17 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprConstant : ExprWithType
{
- public ExprConstant(CType type)
+ public ExprConstant(CType type, ConstVal value)
: base(ExpressionKind.Constant, type)
{
+ Val = value;
}
public Expr OptionalConstructorCall { get; set; }
public bool IsZero => Val.IsZero(Type.constValKind());
- public ConstVal Val { get; set; }
+ public ConstVal Val { get; }
public ulong UInt64Value => Val.UInt64Val;
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Event.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Event.cs
index fcaef69fe3..912cf21011 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Event.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Event.cs
@@ -6,13 +6,15 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprEvent : ExprWithType, IExprWithObject
{
- public ExprEvent(CType type)
+ public ExprEvent(CType type, Expr obj, EventWithType ev)
: base(ExpressionKind.Event, type)
{
+ OptionalObject = obj;
+ EventWithType = ev;
}
public Expr OptionalObject { get; set; }
- public EventWithType EventWithType { get; set; }
+ public EventWithType EventWithType { get; }
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs
index 81ea8e9aef..d6d846247d 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs
@@ -14,7 +14,18 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
Debug.Assert(kind.IsUnaryOperator() || kind > ExpressionKind.TypeLimit);
}
- public Expr OptionalUserDefinedCall { get; set; }
+ protected ExprOperator(ExpressionKind kind, CType type, Expr call, MethPropWithInst userDefinedMethod)
+ : this (kind, type)
+ {
+ OptionalUserDefinedCall = call;
+ UserDefinedCallMethod = userDefinedMethod;
+ if (call.HasError)
+ {
+ SetError();
+ }
+ }
+
+ public Expr OptionalUserDefinedCall { get; }
public MethWithInst PredefinedMethodToCall { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Field.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Field.cs
index 6f26f2f9d1..b7d9df12a5 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Field.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Field.cs
@@ -6,13 +6,16 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprField : ExprWithType, IExprWithObject
{
- public ExprField(CType type)
+ public ExprField(CType type, Expr optionalObject, FieldWithType field, bool isLValue)
: base(ExpressionKind.Field, type)
{
+ Flags = isLValue ? EXPRFLAG.EXF_LVALUE : 0;
+ OptionalObject = optionalObject;
+ FieldWithType = field;
}
public Expr OptionalObject { get; set; }
- public FieldWithType FieldWithType { get; set; }
+ public FieldWithType FieldWithType { get; }
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/FieldInfo.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/FieldInfo.cs
index bc155b8992..ce272b32b6 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/FieldInfo.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/FieldInfo.cs
@@ -2,15 +2,19 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprFieldInfo : ExprWithType
{
- public ExprFieldInfo(FieldSymbol f, AggregateType ft, CType type)
+ public ExprFieldInfo(FieldSymbol field, AggregateType fieldType, CType type)
: base(ExpressionKind.FieldInfo, type)
{
- Field = f;
- FieldType = ft;
+ Debug.Assert(field != null);
+ Debug.Assert(fieldType != null);
+ Field = field;
+ FieldType = fieldType;
}
public FieldSymbol Field { get; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/List.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/List.cs
index 6d0c01d496..4be6e5625c 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/List.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/List.cs
@@ -6,9 +6,11 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprList : Expr
{
- public ExprList()
+ public ExprList(Expr optionalElement, Expr optionalNextListNode)
: base(ExpressionKind.List)
- {
+ {
+ OptionalElement = optionalElement;
+ OptionalNextListNode = optionalNextListNode;
}
public Expr OptionalElement { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/LocalVariable.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/LocalVariable.cs
index 9e1db41f21..f5c9970c7c 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/LocalVariable.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/LocalVariable.cs
@@ -8,12 +8,14 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprLocal : Expr
{
- public ExprLocal()
+ public ExprLocal(LocalVariableSymbol local)
: base(ExpressionKind.Local)
{
+ Flags = EXPRFLAG.EXF_LVALUE;
+ Local = local;
}
- public LocalVariableSymbol Local { get; set; }
+ public LocalVariableSymbol Local { get; }
public override CType Type => Local?.GetType();
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MemberGroup.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MemberGroup.cs
index eb5683f264..1d76966e16 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MemberGroup.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MemberGroup.cs
@@ -2,22 +2,34 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
using Microsoft.CSharp.RuntimeBinder.Syntax;
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprMemberGroup : ExprWithType, IExprWithObject
{
- public ExprMemberGroup(CType type)
+ public ExprMemberGroup(CType type, EXPRFLAG flags, Name name, TypeArray typeArgs, SYMKIND symKind, CType parentType, MethodOrPropertySymbol pMPS, Expr optionalObject, CMemberLookupResults memberLookupResults)
: base(ExpressionKind.MemberGroup, type)
{
+ Debug.Assert(
+ (flags & ~(EXPRFLAG.EXF_CTOR | EXPRFLAG.EXF_INDEXER | EXPRFLAG.EXF_OPERATOR | EXPRFLAG.EXF_NEWOBJCALL
+ | EXPRFLAG.EXF_BASECALL | EXPRFLAG.EXF_DELEGATE | EXPRFLAG.EXF_USERCALLABLE
+ | EXPRFLAG.EXF_MASK_ANY)) == 0);
+ Flags = flags;
+ Name = name;
+ TypeArgs = typeArgs ?? BSYMMGR.EmptyTypeArray();
+ SymKind = symKind;
+ ParentType = parentType;
+ OptionalObject = optionalObject;
+ MemberLookupResults = memberLookupResults;
}
- public Name Name { get; set; }
+ public Name Name { get; }
- public TypeArray TypeArgs { get; set; }
+ public TypeArray TypeArgs { get; }
- public SYMKIND SymKind { get; set; }
+ public SYMKIND SymKind { get; }
// The type containing the members. This may be a TypeParameterType or an AggregateType.
// This may be NULL (if types is not NULL).
@@ -35,9 +47,9 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// The owning call of this member group. NEVER visit this thing.
// The list of the methods that the memgroup is binding to. This list is formulated after binding
// the name of the method. When we've attempted to bind the arguments, we populate the MethPropWithInst list.
- public CMemberLookupResults MemberLookupResults { get; set; }
+ public CMemberLookupResults MemberLookupResults { get; }
- public CType ParentType { get; set; }
+ public CType ParentType { get; }
public bool IsDelegate => (Flags & EXPRFLAG.EXF_DELEGATE) != 0;
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodInfo.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodInfo.cs
index 87c4f0e703..4f166c4e6a 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodInfo.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodInfo.cs
@@ -2,15 +2,20 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprMethodInfo : ExprWithType
{
- public ExprMethodInfo(CType type)
+ public ExprMethodInfo(CType type, MethodSymbol method, AggregateType methodType, TypeArray methodParameters)
: base(ExpressionKind.MethodInfo, type)
{
+ Debug.Assert(method != null);
+ Debug.Assert(methodType != null);
+ Method = new MethWithInst(method, methodType, methodParameters);
}
- public MethWithInst Method { get; set; }
+ public MethWithInst Method { get; }
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodReference.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodReference.cs
index 809aab8525..a457df2491 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodReference.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/MethodReference.cs
@@ -2,16 +2,22 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprFuncPtr : ExprWithType, IExprWithObject
{
- public ExprFuncPtr(CType type)
+ public ExprFuncPtr(CType type, EXPRFLAG flags, Expr optionalObject, MethWithInst method)
: base(ExpressionKind.FunctionPointer, type)
{
+ Debug.Assert((flags & ~EXPRFLAG.EXF_BASECALL) == 0);
+ Flags = flags;
+ OptionalObject = optionalObject;
+ MethWithInst = new MethWithInst(method);
}
- public MethWithInst MethWithInst { get; set; }
+ public MethWithInst MethWithInst { get; }
public Expr OptionalObject { get; set; }
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/NamedArgumentSpecification.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/NamedArgumentSpecification.cs
index 72a381fbe8..98ff7c92bd 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/NamedArgumentSpecification.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/NamedArgumentSpecification.cs
@@ -8,12 +8,14 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprNamedArgumentSpecification : Expr
{
- public ExprNamedArgumentSpecification()
+ public ExprNamedArgumentSpecification(Name name, Expr value)
: base(ExpressionKind.NamedArgumentSpecification)
{
+ Name = name;
+ Value = value;
}
- public Name Name { get; set; }
+ public Name Name { get; }
public Expr Value { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Property.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Property.cs
index d68f4da578..5172c53597 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Property.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Property.cs
@@ -14,9 +14,22 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
// of the type we are actually calling through. (We need to know the
// "through" type to ensure that protected semantics are correctly enforced.)
- public ExprProperty(CType type)
+ public ExprProperty(CType type, Expr pOptionalObjectThrough, Expr pOptionalArguments, ExprMemberGroup pMemberGroup, PropWithType pwtSlot, MethWithType mwtSet)
: base(ExpressionKind.Property, type)
{
+ OptionalObjectThrough = pOptionalObjectThrough;
+ OptionalArguments = pOptionalArguments;
+ MemberGroup = pMemberGroup;
+
+ if (pwtSlot != null)
+ {
+ PropWithTypeSlot = pwtSlot;
+ }
+
+ if (mwtSet != null)
+ {
+ MethWithTypeSet = mwtSet;
+ }
}
public Expr OptionalArguments { get; set; }
@@ -25,15 +38,15 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
public Expr OptionalObject
{
- get { return MemberGroup.OptionalObject; }
- set { MemberGroup.OptionalObject = value; }
+ get => MemberGroup.OptionalObject;
+ set => MemberGroup.OptionalObject = value;
}
- public Expr OptionalObjectThrough { get; set; }
+ public Expr OptionalObjectThrough { get; }
- public PropWithType PropWithTypeSlot { get; set; }
+ public PropWithType PropWithTypeSlot { get; }
- public MethWithType MethWithTypeSet { get; set; }
+ public MethWithType MethWithTypeSet { get; }
public bool IsBaseCall => 0 != (Flags & EXPRFLAG.EXF_BASECALL);
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/PropertyInfo.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/PropertyInfo.cs
index c0bf56cec4..755228aa0d 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/PropertyInfo.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/PropertyInfo.cs
@@ -2,15 +2,20 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprPropertyInfo : ExprWithType
{
- public ExprPropertyInfo(CType type)
+ public ExprPropertyInfo(CType type, PropertySymbol propertySymbol, AggregateType propertyType)
: base(ExpressionKind.PropertyInfo, type)
{
+ Debug.Assert(propertySymbol != null);
+ Debug.Assert(propertyType != null);
+ Property = new PropWithType(propertySymbol, propertyType);
}
- public PropWithType Property { get; set; }
+ public PropWithType Property { get; }
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Return.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Return.cs
index 3fbcf25bb2..3610b60487 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Return.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Return.cs
@@ -6,9 +6,10 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprReturn : ExprStatement, IExprWithObject
{
- public ExprReturn()
+ public ExprReturn(Expr optionalObject)
: base(ExpressionKind.Return)
{
+ OptionalObject = optionalObject;
}
// Return object is optional because of void returns.
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Temporary.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Temporary.cs
index b6f411810e..7ea9df6b1e 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Temporary.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Temporary.cs
@@ -6,11 +6,14 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprWrap : Expr
{
- public ExprWrap()
+ public ExprWrap(Expr expression)
: base(ExpressionKind.Wrap)
- {
+ {
+ OptionalExpression = expression;
+ Flags = EXPRFLAG.EXF_LVALUE;
}
- public Expr OptionalExpression { get; set; }
+
+ public Expr OptionalExpression { get; }
public override CType Type => OptionalExpression?.Type;
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeArguments.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeArguments.cs
deleted file mode 100644
index 617aa2e798..0000000000
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeArguments.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace Microsoft.CSharp.RuntimeBinder.Semantics
-{
- /*************************************************************************************************
- This wraps the type arguments for a class. It contains the TypeArray which is
- associated with the AggregateType for the instantiation of the class.
- *************************************************************************************************/
-
- internal sealed class ExprTypeArguments : Expr
- {
- public Expr OptionalElements { get; set; }
-
- public ExprTypeArguments()
- : base(ExpressionKind.TypeArguments)
- {
- }
- }
-}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeOf.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeOf.cs
index c6a4f5172b..79128ae7b8 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeOf.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/TypeOf.cs
@@ -6,9 +6,11 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprTypeOf : ExprWithType
{
- public ExprTypeOf(CType type)
+ public ExprTypeOf(CType type, ExprClass pSourceType)
: base(ExpressionKind.TypeOf, type)
{
+ Flags = EXPRFLAG.EXF_CANTBENULL;
+ SourceType = pSourceType;
}
public ExprClass SourceType { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnaryOperator.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnaryOperator.cs
index 45d955f9fa..31fd21bf60 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnaryOperator.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnaryOperator.cs
@@ -8,10 +8,23 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprUnaryOp : ExprOperator
{
- public ExprUnaryOp(ExpressionKind kind, CType type)
+ public ExprUnaryOp(ExpressionKind kind, CType type, Expr operand)
: base(kind, type)
{
Debug.Assert(kind.IsUnaryOperator());
+ Debug.Assert(operand != null);
+ Child = operand;
+ }
+
+ public ExprUnaryOp(ExpressionKind kind, CType type, Expr operand, Expr call, MethPropWithInst userMethod)
+ : base(kind, type, call, userMethod)
+ {
+ Debug.Assert(kind.IsUnaryOperator());
+ Debug.Assert(operand != null);
+ Debug.Assert(type != null);
+ Debug.Assert(call != null);
+ Debug.Assert(userMethod != null);
+ Child = operand;
}
public Expr Child { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnboundAnonymousFunction.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnboundAnonymousFunction.cs
deleted file mode 100644
index 5011b6aec2..0000000000
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UnboundAnonymousFunction.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace Microsoft.CSharp.RuntimeBinder.Semantics
-{
- internal sealed class ExprUnboundLambda : ExprWithType
- {
- public ExprUnboundLambda(CType type)
- : base(ExpressionKind.UnboundLambda, type)
- {
- }
- }
-}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedConversion.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedConversion.cs
index 0e8a81a855..8439864c70 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedConversion.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedConversion.cs
@@ -2,21 +2,32 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprUserDefinedConversion : Expr
{
- public ExprUserDefinedConversion()
+ public ExprUserDefinedConversion(Expr argument, Expr call, MethWithInst method)
: base(ExpressionKind.UserDefinedConversion)
{
-
+ Debug.Assert(argument != null);
+ Debug.Assert(call != null);
+ Argument = argument;
+ UserDefinedCall = call;
+ UserDefinedCallMethod = method;
+ if (call.HasError)
+ {
+ SetError();
+ }
}
+
public Expr Argument { get; set; }
public Expr UserDefinedCall { get; set; }
public override CType Type => UserDefinedCall.Type;
- public MethWithInst UserDefinedCallMethod { get; set; }
+ public MethWithInst UserDefinedCallMethod { get; }
}
}
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedLogicalOperator.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedLogicalOperator.cs
index 546ef85c52..d29ec48663 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedLogicalOperator.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/UserDefinedLogicalOperator.cs
@@ -2,13 +2,24 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
+
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprUserLogicalOp : ExprWithType
{
- public ExprUserLogicalOp(CType type)
+ public ExprUserLogicalOp(CType type, Expr trueFalseCall, ExprCall operatorCall)
: base(ExpressionKind.UserLogicalOp, type)
{
+ Debug.Assert(trueFalseCall != null);
+ Debug.Assert((operatorCall?.OptionalArguments as ExprList)?.OptionalElement != null);
+ Flags = EXPRFLAG.EXF_ASSGOP;
+ TrueFalseCall = trueFalseCall;
+ OperatorCall = operatorCall;
+ Expr leftChild = ((ExprList)operatorCall.OptionalArguments).OptionalElement;
+ // In the EE case, we don't create WRAPEXPRs.
+ FirstOperandToExamine = leftChild is ExprWrap wrap ? wrap.OptionalExpression : leftChild;
+ Debug.Assert(FirstOperandToExamine != null);
}
public Expr TrueFalseCall { get; set; }
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExprVisitorBase.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExprVisitorBase.cs
index e2ce8e88f5..2abac4cecc 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExprVisitorBase.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExprVisitorBase.cs
@@ -122,8 +122,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
return VisitLOCAL(pExpr as ExprLocal);
case ExpressionKind.Constant:
return VisitCONSTANT(pExpr as ExprConstant);
- case ExpressionKind.TypeArguments:
- return VisitTYPEARGUMENTS(pExpr as ExprTypeArguments);
case ExpressionKind.Class:
return VisitCLASS(pExpr as ExprClass);
case ExpressionKind.FunctionPointer:
@@ -154,8 +152,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
return VisitMEMGRP(pExpr as ExprMemberGroup);
case ExpressionKind.BoundLambda:
return VisitBOUNDLAMBDA(pExpr as ExprBoundLambda);
- case ExpressionKind.UnboundLambda:
- return VisitUNBOUNDLAMBDA(pExpr as ExprUnboundLambda);
case ExpressionKind.HoistedLocalExpression:
return VisitHOISTEDLOCALEXPR(pExpr as ExprHoistedLocalExpr);
case ExpressionKind.FieldInfo:
@@ -429,7 +425,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
TYPEORNAMESPACEERROR - This is the error class for the type or namespace exprs when we don't know
what to bind it to.
- The following three exprs all have a TYPEORNAMESPACE child, which is their fundamental type:
+ The following two exprs all have a TYPEORNAMESPACE child, which is their fundamental type:
POINTERTYPE - This wraps the sym for the pointer type.
NULLABLETYPE - This wraps the sym for the nullable type.
@@ -442,11 +438,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
*************************************************************************************************/
- case ExpressionKind.TypeArguments:
- exprRet = Visit((pExpr as ExprTypeArguments).OptionalElements);
- (pExpr as ExprTypeArguments).OptionalElements = exprRet;
- break;
-
case ExpressionKind.Multi:
exprRet = Visit((pExpr as ExprMulti).Left);
Debug.Assert(exprRet != null);
@@ -483,7 +474,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
case ExpressionKind.MultiGet:
case ExpressionKind.Wrap:
case ExpressionKind.NoOp:
- case ExpressionKind.UnboundLambda:
case ExpressionKind.HoistedLocalExpression:
case ExpressionKind.FieldInfo:
case ExpressionKind.MethodInfo:
@@ -590,10 +580,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
return VisitEXPR(pExpr);
}
- protected virtual Expr VisitTYPEARGUMENTS(ExprTypeArguments pExpr)
- {
- return VisitEXPR(pExpr);
- }
protected virtual Expr VisitFUNCPTR(ExprFuncPtr pExpr)
{
return VisitEXPR(pExpr);
@@ -622,10 +608,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
return VisitEXPR(pExpr);
}
- protected virtual Expr VisitUNBOUNDLAMBDA(ExprUnboundLambda pExpr)
- {
- return VisitEXPR(pExpr);
- }
+
protected virtual Expr VisitHOISTEDLOCALEXPR(ExprHoistedLocalExpr pExpr)
{
return VisitEXPR(pExpr);
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs
index fccb47998f..96075b6d38 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs
@@ -146,7 +146,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
return local.Local.wrap;
}
Debug.Assert(local.Local.fUsedInAnonMeth);
- return GetExprFactory().CreateHoistedLocalInExpression(local);
+ return GetExprFactory().CreateHoistedLocalInExpression();
}
protected override Expr VisitFIELD(ExprField expr)
{
@@ -895,7 +895,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
Debug.Assert(anonmeth.OptionalBody != null);
Expr create = GenerateParameter(local.name.Text, local.GetType());
- local.wrap = GetExprFactory().CreateWrapNoAutoFree(anonmeth.OptionalBody.OptionalScopeSymbol, create);
+ local.wrap = GetExprFactory().CreateWrap(create);
Expr save = GetExprFactory().CreateSave(local.wrap);
if (sequence == null)
{
@@ -925,7 +925,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
}
Debug.Assert(local.wrap != null);
Debug.Assert(anonmeth.OptionalBody != null);
- Expr freeWrap = GetExprFactory().CreateWrap(anonmeth.OptionalBody.OptionalScopeSymbol, local.wrap);
+ Expr freeWrap = GetExprFactory().CreateWrap(local.wrap);
sequence = GetExprFactory().CreateReverseSequence(sequence, freeWrap);
}
return sequence;
@@ -1016,7 +1016,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
Expr newIndex = it.Current();
if (newIndex.Type != intType)
{
- ExprClass exprType = expressionFactory.CreateClass(intType, null);
+ ExprClass exprType = expressionFactory.CreateClass(intType);
newIndex = expressionFactory.CreateCast(EXPRFLAG.EXF_INDEXEXPR, exprType, newIndex);
newIndex.Flags |= EXPRFLAG.EXF_CHECKOVERFLOW;
}
@@ -1044,7 +1044,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
flags = EXPRFLAG.EXF_BOX;
}
- ExprClass objectType = GetExprFactory().MakeClass(pObject);
+ ExprClass objectType = GetExprFactory().CreateClass(pObject);
ExprCast cast = GetExprFactory().CreateCast(flags, objectType, expr);
ExprTypeOf pTypeOf2 = CreateTypeOf(expr.Type);
@@ -1114,10 +1114,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
AggregateType paramsArrayElementType = GetSymbolLoader().GetOptPredefTypeErr(pt);
ArrayType paramsArrayType = GetSymbolLoader().GetTypeManager().GetArray(paramsArrayElementType, 1, true);
ExprConstant paramsArrayArg = GetExprFactory().CreateIntegerConstant(parameterCount);
- ExprArrayInit arrayInit = GetExprFactory().CreateArrayInit(EXPRFLAG.EXF_CANTBENULL, paramsArrayType, args, paramsArrayArg, null);
- arrayInit.DimensionSize = parameterCount;
- arrayInit.DimensionSizes = new int[] { arrayInit.DimensionSize }; // CLEANUP: Why isn't this done by the factory?
- return arrayInit;
+ return GetExprFactory().CreateArrayInit(paramsArrayType, args, paramsArrayArg, new int[] { parameterCount }, parameterCount);
}
private void FixLiftedUserDefinedBinaryOperators(ExprBinOp expr, ref Expr pp1, ref Expr pp2)
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ZeroInitialize.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ZeroInitialize.cs
index 1de32f2c70..8593c111a2 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ZeroInitialize.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ZeroInitialize.cs
@@ -6,15 +6,21 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprZeroInit : ExprWithType
{
- public ExprZeroInit(CType type)
+ public ExprZeroInit(CType type, Expr originalConstructorCall, bool isConstructor, bool isError)
: base(ExpressionKind.ZeroInit, type)
{
+ OptionalConstructorCall = originalConstructorCall;
+ IsConstructor = isConstructor;
+ if (isError)
+ {
+ SetError();
+ }
}
public Expr OptionalArgument { get; set; }
public Expr OptionalConstructorCall { get; set; }
- public bool IsConstructor { get; set; }
+ public bool IsConstructor { get; }
}
}