Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* ***************************************************************************/

using System.Diagnostics;
using System.Reflection;

namespace System.Management.Automation.Interpreter
{
Expand Down Expand Up @@ -127,7 +126,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.Int16: return s_int16 ?? (s_int16 = new AddInt16());
Expand Down Expand Up @@ -259,7 +258,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.Int16: return s_int16 ?? (s_int16 = new AddOvfInt16());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ private static CallInstruction FastCreate(MethodInfo target, ParameterInfo[] pi)
return new ActionCallInstruction(target);
}

var typeInfo = t.GetTypeInfo();
if (typeInfo.IsEnum) return SlowCreate(target, pi);
if (t.IsEnum) return SlowCreate(target, pi);
switch (t.GetTypeCode()) {
case TypeCode.Object: {
if (t != typeof(object) && (IndexIsNotReturnType(0, target, pi) || typeInfo.IsValueType)) {
if (t != typeof(object) && (IndexIsNotReturnType(0, target, pi) || t.IsValueType)) {
// if we're on the return type relaxed delegates makes it ok to use object
goto default;
}
Expand Down Expand Up @@ -136,11 +135,10 @@ private static CallInstruction FastCreate<T0>(MethodInfo target, ParameterInfo[]
return new FuncCallInstruction<T0>(target);
}

var typeInfo = t.GetTypeInfo();
if (typeInfo.IsEnum) return SlowCreate(target, pi);
if (t.IsEnum) return SlowCreate(target, pi);
switch (t.GetTypeCode()) {
case TypeCode.Object: {
if (t != typeof(object) && (IndexIsNotReturnType(1, target, pi) || typeInfo.IsValueType)) {
if (t != typeof(object) && (IndexIsNotReturnType(1, target, pi) || t.IsValueType)) {
// if we're on the return type relaxed delegates makes it ok to use object
goto default;
}
Expand Down Expand Up @@ -174,12 +172,11 @@ private static CallInstruction FastCreate<T0, T1>(MethodInfo target, ParameterIn
return new FuncCallInstruction<T0, T1>(target);
}

var typeInfo = t.GetTypeInfo();
if (typeInfo.IsEnum) return SlowCreate(target, pi);
if (t.IsEnum) return SlowCreate(target, pi);
switch (t.GetTypeCode()) {
case TypeCode.Object: {
Debug.Assert(pi.Length == 2);
if (typeInfo.IsValueType) goto default;
if (t.IsValueType) goto default;

return new FuncCallInstruction<T0, T1, Object>(target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static CallInstruction Create(MethodInfo info, ParameterInfo[] parameters
return GetArrayAccessor(info, argumentCount);
}

if (info is DynamicMethod || !info.IsStatic && info.DeclaringType.GetTypeInfo().IsValueType)
if (info is DynamicMethod || !info.IsStatic && info.DeclaringType.IsValueType)
{
return new MethodInfoCallInstruction(info, argumentCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* ***************************************************************************/

using System.Diagnostics;
using System.Reflection;

namespace System.Management.Automation.Interpreter
{
Expand Down Expand Up @@ -127,7 +126,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.Int16: return s_int16 ?? (s_int16 = new DivInt16());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ public override int Run(InterpretedFrame frame)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
public static Instruction Create(Type type)
{
var typeInfo = type.GetTypeInfo();
// Boxed enums can be unboxed as their underlying types:
var typeToUse = typeInfo.IsEnum ? Enum.GetUnderlyingType(type) : type;
var typeToUse = type.IsEnum ? Enum.GetUnderlyingType(type) : type;
switch (typeToUse.GetTypeCode())
{
case TypeCode.Boolean: return s_boolean ?? (s_boolean = new EqualBoolean());
Expand All @@ -170,7 +169,7 @@ public static Instruction Create(Type type)
case TypeCode.Double: return s_double ?? (s_double = new EqualDouble());

case TypeCode.Object:
if (!typeInfo.IsValueType)
if (!type.IsValueType)
{
return s_reference ?? (s_reference = new EqualReference());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* ***************************************************************************/

using System.Diagnostics;
using System.Reflection;

namespace System.Management.Automation.Interpreter
{
Expand Down Expand Up @@ -141,7 +140,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.SByte: return s_SByte ?? (s_SByte = new GreaterThanSByte());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public void EmitLoad(object value, Type type)
return;
}

if (type == null || type.GetTypeInfo().IsValueType)
if (type == null || type.IsValueType)
{
if (value is bool)
{
Expand Down Expand Up @@ -625,7 +625,7 @@ public void EmitInitializeLocal(int index, Type type)
{
Emit(new InitializeLocalInstruction.ImmutableValue(index, value));
}
else if (type.GetTypeInfo().IsValueType)
else if (type.IsValueType)
{
Emit(new InitializeLocalInstruction.MutableValue(index, type));
}
Expand Down Expand Up @@ -712,8 +712,7 @@ public void EmitNewRuntimeVariables(int count)
public void EmitGetArrayItem(Type arrayType)
{
var elementType = arrayType.GetElementType();
var elementTypeInfo = elementType.GetTypeInfo();
if (elementTypeInfo.IsClass || elementTypeInfo.IsInterface)
if (elementType.IsClass || elementType.IsInterface)
{
Emit(InstructionFactory<object>.Factory.GetArrayItem());
}
Expand All @@ -726,8 +725,7 @@ public void EmitGetArrayItem(Type arrayType)
public void EmitSetArrayItem(Type arrayType)
{
var elementType = arrayType.GetElementType();
var elementTypeInfo = elementType.GetTypeInfo();
if (elementTypeInfo.IsClass || elementTypeInfo.IsInterface)
if (elementType.IsClass || elementType.IsInterface)
{
Emit(InstructionFactory<object>.Factory.SetArrayItem());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* ***************************************************************************/

using System.Diagnostics;
using System.Reflection;

namespace System.Management.Automation.Interpreter
{
Expand Down Expand Up @@ -141,7 +140,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.SByte: return s_SByte ?? (s_SByte = new LessThanSByte());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private void CompileDefaultExpression(Type type)
{
if (type != typeof(void))
{
if (type.GetTypeInfo().IsValueType)
if (type.IsValueType)
{
object value = ScriptingRuntimeHelpers.GetPrimitiveDefaultValue(type);
if (value != null)
Expand Down Expand Up @@ -790,7 +790,7 @@ private void CompileBinaryExpression(Expression expr)
private void CompileEqual(Expression left, Expression right)
{
Debug.Assert(left.Type == right.Type ||
!left.Type.GetTypeInfo().IsValueType && !right.Type.GetTypeInfo().IsValueType);
!left.Type.IsValueType && !right.Type.IsValueType);
Compile(left);
Compile(right);
_instructions.EmitEqual(left.Type);
Expand All @@ -799,7 +799,7 @@ private void CompileEqual(Expression left, Expression right)
private void CompileNotEqual(Expression left, Expression right)
{
Debug.Assert(left.Type == right.Type ||
!left.Type.GetTypeInfo().IsValueType && !right.Type.GetTypeInfo().IsValueType);
!left.Type.IsValueType && !right.Type.IsValueType);
Compile(left);
Compile(right);
_instructions.EmitNotEqual(left.Type);
Expand Down Expand Up @@ -1550,9 +1550,9 @@ private void CompileMethodCallExpression(Expression expr)
// force compilation for now for ref types
// also could be a mutable value type, Delegate.CreateDelegate and MethodInfo.Invoke both can't handle this, we
// need to generate code.
var declaringTypeInfo = node.Method.DeclaringType.GetTypeInfo();
var declaringType = node.Method.DeclaringType;
if (!parameters.TrueForAll(p => !p.ParameterType.IsByRef) ||
(!node.Method.IsStatic && declaringTypeInfo.IsValueType && !declaringTypeInfo.IsPrimitive))
(!node.Method.IsStatic && declaringType.IsValueType && !declaringType.IsPrimitive))
{
_forceCompile = true;
}
Expand Down Expand Up @@ -1595,7 +1595,7 @@ private void CompileNewExpression(Expression expr)
}
else
{
Debug.Assert(expr.Type.GetTypeInfo().IsValueType);
Debug.Assert(expr.Type.IsValueType);
_instructions.EmitDefaultValue(node.Type);
}
}
Expand Down Expand Up @@ -1844,7 +1844,7 @@ private void CompileTypeIsExpression(Expression expr)
Compile(node.Expression);

// use TypeEqual for sealed types:
if (node.TypeOperand.GetTypeInfo().IsSealed)
if (node.TypeOperand.IsSealed)
{
_instructions.EmitLoad(node.TypeOperand);
_instructions.EmitTypeEquals();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* ***************************************************************************/

using System.Diagnostics;
using System.Reflection;

namespace System.Management.Automation.Interpreter
{
Expand Down Expand Up @@ -127,7 +126,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.Int16: return s_int16 ?? (s_int16 = new MulInt16());
Expand Down Expand Up @@ -259,7 +258,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.Int16: return s_int16 ?? (s_int16 = new MulOvfInt16());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ public override int Run(InterpretedFrame frame)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
public static Instruction Create(Type type)
{
var typeInfo = type.GetTypeInfo();
// Boxed enums can be unboxed as their underlying types:
var typeToUse = typeInfo.IsEnum ? Enum.GetUnderlyingType(type) : type;
var typeToUse = type.IsEnum ? Enum.GetUnderlyingType(type) : type;
switch (typeToUse.GetTypeCode())
{
case TypeCode.Boolean: return s_boolean ?? (s_boolean = new NotEqualBoolean());
Expand All @@ -170,7 +169,7 @@ public static Instruction Create(Type type)
case TypeCode.Double: return s_double ?? (s_double = new NotEqualDouble());

case TypeCode.Object:
if (!typeInfo.IsValueType)
if (!type.IsValueType)
{
return s_reference ?? (s_reference = new NotEqualReference());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* ***************************************************************************/

using System.Diagnostics;
using System.Reflection;

namespace System.Management.Automation.Interpreter
{
Expand Down Expand Up @@ -127,7 +126,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.Int16: return s_int16 ?? (s_int16 = new SubInt16());
Expand Down Expand Up @@ -259,7 +258,7 @@ public override int Run(InterpretedFrame frame)

public static Instruction Create(Type type)
{
Debug.Assert(!type.GetTypeInfo().IsEnum);
Debug.Assert(!type.IsEnum);
switch (type.GetTypeCode())
{
case TypeCode.Int16: return s_int16 ?? (s_int16 = new SubOvfInt16());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal static Type GetNonNullableType(this Type type)
internal static Type GetNullableType(Type type)
{
Debug.Assert(type != null, "type cannot be null");
if (type.GetTypeInfo().IsValueType && !IsNullableType(type))
if (type.IsValueType && !IsNullableType(type))
{
return typeof(Nullable<>).MakeGenericType(type);
}
Expand All @@ -35,8 +35,7 @@ internal static Type GetNullableType(Type type)

internal static bool IsNullableType(Type type)
{
var typeInfo = type.GetTypeInfo();
return typeInfo.IsGenericType && typeInfo.GetGenericTypeDefinition() == typeof(Nullable<>);
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}

internal static bool IsBool(Type type)
Expand All @@ -47,7 +46,7 @@ internal static bool IsBool(Type type)
internal static bool IsNumeric(Type type)
{
type = GetNonNullableType(type);
if (!type.GetTypeInfo().IsEnum)
if (!type.IsEnum)
{
switch (type.GetTypeCode())
{
Expand Down Expand Up @@ -91,7 +90,7 @@ internal static bool IsNumeric(TypeCode typeCode)
internal static bool IsArithmetic(Type type)
{
type = GetNonNullableType(type);
if (!type.GetTypeInfo().IsEnum)
if (!type.IsEnum)
{
switch (type.GetTypeCode())
{
Expand Down