Skip to content

Commit

Permalink
Remove formatting changes added by accident
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Mar 28, 2024
1 parent f1e5fb6 commit c4abc6e
Showing 1 changed file with 50 additions and 106 deletions.
156 changes: 50 additions & 106 deletions src/System.Management.Automation/engine/runtime/Binding/Binders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,7 @@ private static IEnumerator PSObjectNotEnumerableRule(CallSite site, object obj)
private static IEnumerator ArrayRule(CallSite site, object obj)
{
var array = obj as Array;
if (array != null)
return array.GetEnumerator();
if (array != null) return array.GetEnumerator();
return ((CallSite<Func<CallSite, object, IEnumerator>>)site).Update(site, obj);
}

Expand All @@ -774,8 +773,7 @@ private static IEnumerator StringRule(CallSite site, object obj)
private static IEnumerator PSObjectStringRule(CallSite site, object obj)
{
var psobj = obj as PSObject;
if (psobj != null && PSObject.Base(psobj) is string)
return null;
if (psobj != null && PSObject.Base(psobj) is string) return null;
return ((CallSite<Func<CallSite, object, IEnumerator>>)site).Update(site, obj);
}
}
Expand Down Expand Up @@ -904,32 +902,25 @@ public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObje

private static void BoolRule(CallSite site, object obj, Pipe pipe, ExecutionContext context)
{
if (obj is bool)
{ pipe.Add(obj); }
else
{ ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
if (obj is bool) { pipe.Add(obj); }
else { ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
}

private static void IntRule(CallSite site, object obj, Pipe pipe, ExecutionContext context)
{
if (obj is int)
{ pipe.Add(obj); }
else
{ ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
if (obj is int) { pipe.Add(obj); }
else { ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
}

private static void StringRule(CallSite site, object obj, Pipe pipe, ExecutionContext context)
{
if (obj is string)
{ pipe.Add(obj); }
else
{ ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
if (obj is string) { pipe.Add(obj); }
else { ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
}

private static void AutomationNullRule(CallSite site, object obj, Pipe pipe, ExecutionContext context)
{
if (obj != AutomationNull.Value)
{ ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
if (obj != AutomationNull.Value) { ((CallSite<Action<CallSite, object, Pipe, ExecutionContext>>)site).Update(site, obj, pipe, context); }
}
}

Expand Down Expand Up @@ -2005,41 +1996,36 @@ public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObje

private static object EnumRule(CallSite site, object obj)
{
if (obj is Enum)
{ return obj; }
if (obj is Enum) { return obj; }

return ((CallSite<Func<CallSite, object, object>>)site).Update(site, obj);
}

private static object BoolRule(CallSite site, object obj)
{
if (obj is bool)
{ return obj; }
if (obj is bool) { return obj; }

return ((CallSite<Func<CallSite, object, object>>)site).Update(site, obj);
}

private static object IntRule(CallSite site, object obj)
{
if (obj is int)
{ return obj; }
if (obj is int) { return obj; }

return ((CallSite<Func<CallSite, object, object>>)site).Update(site, obj);
}

private static object ObjectRule(CallSite site, object obj)
{
if (obj is not ValueType && obj is not PSObject)
{ return obj; }
if (obj is not ValueType && obj is not PSObject) { return obj; }

return ((CallSite<Func<CallSite, object, object>>)site).Update(site, obj);
}

private static object PSObjectStringRule(CallSite site, object obj)
{
var psobj = obj as PSObject;
if (psobj != null && psobj.BaseObject is string)
return obj;
if (psobj != null && psobj.BaseObject is string) return obj;
return ((CallSite<Func<CallSite, object, object>>)site).Update(site, obj);
}

Expand Down Expand Up @@ -2278,38 +2264,22 @@ private string GetOperatorText()
{
switch (Operation)
{
case ExpressionType.Add:
return TokenKind.Plus.Text();
case ExpressionType.Subtract:
return TokenKind.Minus.Text();
case ExpressionType.Multiply:
return TokenKind.Multiply.Text();
case ExpressionType.Divide:
return TokenKind.Divide.Text();
case ExpressionType.Modulo:
return TokenKind.Rem.Text();
case ExpressionType.And:
return TokenKind.Band.Text();
case ExpressionType.Or:
return TokenKind.Bor.Text();
case ExpressionType.ExclusiveOr:
return TokenKind.Bxor.Text();
case ExpressionType.Equal:
return _ignoreCase ? TokenKind.Ieq.Text() : TokenKind.Ceq.Text();
case ExpressionType.NotEqual:
return _ignoreCase ? TokenKind.Ine.Text() : TokenKind.Cne.Text();
case ExpressionType.GreaterThan:
return _ignoreCase ? TokenKind.Igt.Text() : TokenKind.Cgt.Text();
case ExpressionType.GreaterThanOrEqual:
return _ignoreCase ? TokenKind.Ige.Text() : TokenKind.Cge.Text();
case ExpressionType.LessThan:
return _ignoreCase ? TokenKind.Ilt.Text() : TokenKind.Clt.Text();
case ExpressionType.LessThanOrEqual:
return _ignoreCase ? TokenKind.Ile.Text() : TokenKind.Cle.Text();
case ExpressionType.LeftShift:
return TokenKind.Shl.Text();
case ExpressionType.RightShift:
return TokenKind.Shr.Text();
case ExpressionType.Add: return TokenKind.Plus.Text();
case ExpressionType.Subtract: return TokenKind.Minus.Text();
case ExpressionType.Multiply: return TokenKind.Multiply.Text();
case ExpressionType.Divide: return TokenKind.Divide.Text();
case ExpressionType.Modulo: return TokenKind.Rem.Text();
case ExpressionType.And: return TokenKind.Band.Text();
case ExpressionType.Or: return TokenKind.Bor.Text();
case ExpressionType.ExclusiveOr: return TokenKind.Bxor.Text();
case ExpressionType.Equal: return _ignoreCase ? TokenKind.Ieq.Text() : TokenKind.Ceq.Text();
case ExpressionType.NotEqual: return _ignoreCase ? TokenKind.Ine.Text() : TokenKind.Cne.Text();
case ExpressionType.GreaterThan: return _ignoreCase ? TokenKind.Igt.Text() : TokenKind.Cgt.Text();
case ExpressionType.GreaterThanOrEqual: return _ignoreCase ? TokenKind.Ige.Text() : TokenKind.Cge.Text();
case ExpressionType.LessThan: return _ignoreCase ? TokenKind.Ilt.Text() : TokenKind.Clt.Text();
case ExpressionType.LessThanOrEqual: return _ignoreCase ? TokenKind.Ile.Text() : TokenKind.Cle.Text();
case ExpressionType.LeftShift: return TokenKind.Shl.Text();
case ExpressionType.RightShift: return TokenKind.Shr.Text();
}

Diagnostics.Assert(false, "Unexpected operator");
Expand Down Expand Up @@ -2343,14 +2313,10 @@ private static bool IsValueNegative(object value, TypeCode typeCode)
{
switch (typeCode)
{
case TypeCode.SByte:
return (sbyte)value < 0;
case TypeCode.Int16:
return (short)value < 0;
case TypeCode.Int32:
return (int)value < 0;
case TypeCode.Int64:
return (long)value < 0;
case TypeCode.SByte: return (sbyte)value < 0;
case TypeCode.Int16: return (short)value < 0;
case TypeCode.Int32: return (int)value < 0;
case TypeCode.Int64: return (long)value < 0;
}

Diagnostics.Assert(false, "Invalid type code for testing negative value");
Expand All @@ -2361,14 +2327,10 @@ private static Expression TypedZero(TypeCode typeCode)
{
switch (typeCode)
{
case TypeCode.SByte:
return Expression.Constant((sbyte)0);
case TypeCode.Int16:
return Expression.Constant((short)0);
case TypeCode.Int32:
return ExpressionCache.Constant(0);
case TypeCode.Int64:
return Expression.Constant((long)0);
case TypeCode.SByte: return Expression.Constant((sbyte)0);
case TypeCode.Int16: return Expression.Constant((short)0);
case TypeCode.Int32: return ExpressionCache.Constant(0);
case TypeCode.Int64: return Expression.Constant((long)0);
}

Diagnostics.Assert(false, "Invalid type code for testing negative value");
Expand Down Expand Up @@ -2681,15 +2643,11 @@ private static DynamicMetaObject GetArgAsNumericOrPrimitive(DynamicMetaObject ar
private static Type GetBitwiseOpType(TypeCode opTypeCode)
{
Type opType;
if ((int)opTypeCode <= (int)TypeCode.Int32)
{ opType = typeof(int); }
else if ((int)opTypeCode <= (int)TypeCode.UInt32)
{ opType = typeof(uint); }
else if ((int)opTypeCode <= (int)TypeCode.Int64)
{ opType = typeof(long); }
if ((int)opTypeCode <= (int)TypeCode.Int32) { opType = typeof(int); }
else if ((int)opTypeCode <= (int)TypeCode.UInt32) { opType = typeof(uint); }
else if ((int)opTypeCode <= (int)TypeCode.Int64) { opType = typeof(long); }
// Because we use unsigned for -bnot, to be consistent, we promote to unsigned here too (-band,-bor,-xor)
else
{ opType = typeof(ulong); }
else { opType = typeof(ulong); }

return opType;
}
Expand Down Expand Up @@ -3431,24 +3389,12 @@ private DynamicMetaObject BinaryComparisonCommon(DynamicMetaObject targetAsEnume
string numericMethod = null;
switch (Operation)
{
case ExpressionType.Equal:
numericMethod = "CompareEq";
break;
case ExpressionType.NotEqual:
numericMethod = "CompareNe";
break;
case ExpressionType.GreaterThan:
numericMethod = "CompareGt";
break;
case ExpressionType.GreaterThanOrEqual:
numericMethod = "CompareGe";
break;
case ExpressionType.LessThan:
numericMethod = "CompareLt";
break;
case ExpressionType.LessThanOrEqual:
numericMethod = "CompareLe";
break;
case ExpressionType.Equal: numericMethod = "CompareEq"; break;
case ExpressionType.NotEqual: numericMethod = "CompareNe"; break;
case ExpressionType.GreaterThan: numericMethod = "CompareGt"; break;
case ExpressionType.GreaterThanOrEqual: numericMethod = "CompareGe"; break;
case ExpressionType.LessThan: numericMethod = "CompareLt"; break;
case ExpressionType.LessThanOrEqual: numericMethod = "CompareLe"; break;
}

return BinaryNumericOp(numericMethod, target, numericArg);
Expand Down Expand Up @@ -7779,8 +7725,7 @@ public override DynamicMetaObject FallbackCreateInstance(DynamicMetaObject targe
internal static bool IsTargetTypeByRefLike(object target)
{
var targetValue = PSObject.Base(target);
if (targetValue == null)
{ return false; }
if (targetValue == null) { return false; }

var instanceType = targetValue as Type ?? targetValue.GetType();
return instanceType.IsByRefLike;
Expand All @@ -7792,8 +7737,7 @@ internal static bool IsTargetTypeByRefLike(object target)
internal static bool IsTargetTypeNonPublic(object target)
{
var targetValue = PSObject.Base(target);
if (targetValue == null)
{ return false; }
if (targetValue == null) { return false; }

var instanceType = targetValue as Type ?? targetValue.GetType();
return !TypeResolver.IsPublic(instanceType);
Expand Down

0 comments on commit c4abc6e

Please sign in to comment.