本文整理汇总了C#中Mono.Cecil.TypeSystem类的典型用法代码示例。如果您正苦于以下问题:C# TypeSystem类的具体用法?C# TypeSystem怎么用?C# TypeSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeSystem类属于Mono.Cecil命名空间,在下文中一共展示了TypeSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NegateBinaryExpression
private static Expression NegateBinaryExpression(Expression expression, TypeSystem typeSystem)
{
BinaryExpression binary = (BinaryExpression)expression;
if (IsLogicalOperator(binary.Operator))
{
BinaryOperator @operator = binary.Operator == BinaryOperator.LogicalAnd ?
BinaryOperator.LogicalOr
: BinaryOperator.LogicalAnd;
binary.Left = Negate(binary.Left, typeSystem);
binary.Operator = @operator;
binary.Right = Negate(binary.Right, typeSystem);
return binary;
}
BinaryOperator op;
if (TryGetInverseOperator(binary.Operator, out op))
{
binary.Operator = op;
}
return binary;
}
示例2: NegateConditionExpression
private static Expression NegateConditionExpression(Expression expression, TypeSystem typeSystem)
{
ConditionExpression condition = (ConditionExpression)expression;
condition.Then = Negate(condition.Then, typeSystem);
condition.Else = Negate(condition.Else, typeSystem);
return condition;
}
示例3: Process
public BlockStatement Process(DecompilationContext context, BlockStatement body)
{
this.context = context;
this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
InsertTopLevelParameterAssignments(body);
return body;
}
示例4: FilterInvocationResult
public static JSExpression FilterInvocationResult(
MethodReference methodReference, MethodInfo method,
JSExpression result,
ITypeInfoSource typeInfo, TypeSystem typeSystem
)
{
if (method == null)
return result;
var resultType = result.GetActualType(typeSystem);
var resultIsPackedArray = PackedArrayUtil.IsPackedArrayType(resultType);
var returnValueAttribute = method.Metadata.GetAttribute("JSIL.Meta.JSPackedArrayReturnValueAttribute");
if (returnValueAttribute != null) {
if (TypeUtil.IsOpenType(resultType)) {
// FIXME: We need to restrict substitution to when the result type is a generic parameter owned by the invocation...
resultType = JSExpression.SubstituteTypeArgs(typeInfo, resultType, methodReference);
}
if (!resultIsPackedArray)
return JSChangeTypeExpression.New(result, PackedArrayUtil.MakePackedArrayType(resultType, returnValueAttribute.Entries.First().Type), typeSystem);
}
return result;
}
示例5: CheckInvocationSafety
public static void CheckInvocationSafety(MethodInfo method, JSExpression[] argumentValues, TypeSystem typeSystem)
{
if (method.Metadata.HasAttribute("JSIL.Meta.JSAllowPackedArrayArgumentsAttribute"))
return;
TypeReference temp;
string[] argumentNames = GetPackedArrayArgumentNames(method, out temp);
for (var i = 0; i < method.Parameters.Length; i++) {
if (i >= argumentValues.Length)
continue;
var valueType = argumentValues[i].GetActualType(typeSystem);
if (!IsPackedArrayType(valueType)) {
if ((argumentNames != null) && argumentNames.Contains(method.Parameters[i].Name))
throw new ArgumentException(
"Invalid attempt to pass a normal array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
"This parameter must be a packed array."
);
} else {
if ((argumentNames == null) || !argumentNames.Contains(method.Parameters[i].Name))
throw new ArgumentException(
"Invalid attempt to pass a packed array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
"If this is intentional, annotate the method with the JSPackedArrayArguments attribute."
);
}
}
}
示例6: Process
public BlockStatement Process(DecompilationContext context, BlockStatement body)
{
this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
this.decompiledMethodReturnType = context.MethodContext.Method.ReturnType;
Visit(body);
return body;
}
示例7: GetTypeCode
public static TypeCode GetTypeCode(TypeSystem typeSystem, TypeReference type)
{
if (type == typeSystem.Boolean)
return TypeCode.Boolean;
else if (type == typeSystem.Byte)
return TypeCode.Byte;
else if (type == typeSystem.Char)
return TypeCode.Char;
else if (type == typeSystem.Double)
return TypeCode.Double;
else if (type == typeSystem.Int16)
return TypeCode.Int16;
else if (type == typeSystem.Int32)
return TypeCode.Int32;
else if (type == typeSystem.Int64)
return TypeCode.Int64;
else if (type == typeSystem.Single)
return TypeCode.Single;
else if (type == typeSystem.Double)
return TypeCode.Double;
else if (type == typeSystem.SByte)
return TypeCode.SByte;
else if (type == typeSystem.UInt16)
return TypeCode.UInt16;
else if (type == typeSystem.UInt32)
return TypeCode.UInt32;
else if (type == typeSystem.UInt64)
return TypeCode.UInt64;
else if (type == typeSystem.String)
return TypeCode.String;
else
return TypeCode.Object;
}
示例8: PropertyWeaver
public PropertyWeaver(ModuleWeaver moduleWeaver, PropertyData propertyData, TypeNode typeNode, TypeSystem typeSystem )
{
this.moduleWeaver = moduleWeaver;
this.propertyData = propertyData;
this.typeNode = typeNode;
this.typeSystem = typeSystem;
}
示例9: ExtractOffsetFromPointerExpression
public static bool ExtractOffsetFromPointerExpression(JSExpression pointer, TypeSystem typeSystem, out JSExpression newPointer, out JSExpression offset)
{
offset = null;
newPointer = pointer;
var boe = pointer as JSBinaryOperatorExpression;
if (boe == null)
return false;
var leftType = boe.Left.GetActualType(typeSystem);
var rightType = boe.Right.GetActualType(typeSystem);
var resultType = boe.GetActualType(typeSystem);
if (!resultType.IsPointer)
return false;
if (!TypeUtil.IsIntegral(rightType))
return false;
if (boe.Operator != JSOperator.Add)
return false;
newPointer = boe.Left;
offset = boe.Right;
return true;
}
示例10: DeconstructMutationAssignment
public static JSExpression DeconstructMutationAssignment (
JSNode parentNode, JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType
) {
var assignmentOperator = boe.Operator as JSAssignmentOperator;
if (assignmentOperator == null)
return null;
JSBinaryOperator replacementOperator;
if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator))
return null;
var leftType = boe.Left.GetActualType(typeSystem);
var newBoe = new JSBinaryOperatorExpression(
JSOperator.Assignment, MakeLhsForAssignment(boe.Left),
new JSBinaryOperatorExpression(
replacementOperator, boe.Left, boe.Right, intermediateType
),
leftType
);
var result = ConvertReadExpressionToWriteExpression(newBoe, typeSystem);
if (parentNode is JSExpressionStatement) {
return result;
} else {
var comma = new JSCommaExpression(
newBoe, boe.Left
);
return comma;
}
}
示例11: ExpandCastExpressions
public ExpandCastExpressions (TypeSystem typeSystem, JSSpecialIdentifiers js, JSILIdentifier jsil, ITypeInfoSource typeInfo, MethodTypeFactory methodTypeFactory) {
TypeSystem = typeSystem;
JS = js;
JSIL = jsil;
TypeInfo = typeInfo;
MethodTypeFactory = methodTypeFactory;
}
示例12: Process
public BlockStatement Process(DecompilationContext context, BlockStatement block)
{
this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
this.context = context;
BlockStatement newBlock = (BlockStatement)VisitBlockStatement(block);
return newBlock;
}
示例13: Negate
/// <summary>
/// Swaps the then and else and negates the condition
/// </summary>
public void Negate(TypeSystem typeSystem)
{
this.Condition.Negate(typeSystem);
BlockLogicalConstruct temp = this.Then;
this.Then = this.Else;
this.Else = temp;
}
示例14: EmulateStructAssignment
public EmulateStructAssignment(TypeSystem typeSystem, IFunctionSource functionSource, CLRSpecialIdentifiers clr, bool optimizeCopies)
{
TypeSystem = typeSystem;
FunctionSource = functionSource;
CLR = clr;
OptimizeCopies = optimizeCopies;
}
示例15: Process
public void Process()
{
typeSystem = TypeProcessor.ModuleWeaver.ModuleDefinition.TypeSystem;
CreateDisposeBoolMethod();
InjectIntoDispose();
TypeProcessor.AddFinalizer(DisposeBoolMethod);
}