public override void VisitMemberHandleExpression(MemberHandleExpression node) { WriteKeyword("__ldtoken__"); WriteToken("("); if (node.MemberReference is MethodReference) { MethodReference methodRef = node.MemberReference as MethodReference; WriteReference(GetTypeName(methodRef.DeclaringType), methodRef.DeclaringType); WriteToken("."); WriteReference(GetMethodName(methodRef), methodRef); } else if (node.MemberReference is FieldReference) { FieldReference fieldRef = node.MemberReference as FieldReference; WriteReference(GetTypeName(fieldRef.DeclaringType), fieldRef.DeclaringType); WriteToken("."); WriteReference(GetFieldName(fieldRef), fieldRef); } else if (node.MemberReference is TypeReference) { TypeReference typeRef = node.MemberReference as TypeReference; WriteReference(GetTypeName(typeRef), typeRef); } else { Write(string.Format("Invalid member reference: {0} {1}.", node.MemberReference.GetType(), node.MemberReference.FullName)); } WriteToken(")"); }
public static bool IsTypeOfExpression(this MethodInvocationExpression self, out TypeReference typeReference) { typeReference = null; MethodReferenceExpression method_ref = self.MethodExpression; if (method_ref == null) { return(false); } var method = method_ref.Method; if ((method.CallingConvention == Mono.Cecil.MethodCallingConvention.StdCall) || (method.DeclaringType.FullName != "System.Type") || (method.Name != "GetTypeFromHandle")) { return(false); } if (self.Arguments.Count != 1) { return(false); } MemberHandleExpression memberHandle = self.Arguments[0] as MemberHandleExpression; if (memberHandle == null) { return(false); } typeReference = memberHandle.MemberReference as TypeReference; return(typeReference != null); }
private bool TryFillInitializer(ArrayCreationExpression expression, MemberHandleExpression values) { if (values.get_MemberReference() as FieldDefinition == null) { return(false); } V_0 = this.ConvertInitialValues((values.get_MemberReference() as FieldDefinition).get_InitialValue(), expression.get_ElementType().get_Name()); if (V_0 == null || !this.CheckElementsCount(V_0, expression.get_Dimensions())) { return(false); } this.RebuildDimensions(ref V_0, expression.get_Dimensions()); expression.get_Initializer().set_Expressions(V_0); return(true); }
private bool TryFillInitializer(ArrayCreationExpression expression, MemberHandleExpression values) { if (!(values.MemberReference is FieldDefinition)) { return(false); } ExpressionCollection convertedExpressions = ConvertInitialValues((values.MemberReference as FieldDefinition).InitialValue, expression.ElementType.Name); if (convertedExpressions == null || CheckElementsCount(convertedExpressions, expression.Dimensions) == false) { return(false); } RebuildDimensions(ref convertedExpressions, expression.Dimensions); expression.Initializer.Expressions = convertedExpressions; return(true); }
public override ICodeNode VisitMemberHandleExpression(MemberHandleExpression node) { V_0 = node.get_MemberReference() as MethodReference; if (V_0 != null) { return this.GetMethodHandleExpression(V_0, node.get_MappedInstructions()); } V_1 = node.get_MemberReference() as TypeReference; if (V_1 != null) { return this.GetTypeHandleExpression(V_1, node.get_MappedInstructions()); } V_2 = node.get_MemberReference() as FieldReference; if (V_2 == null) { throw new NotSupportedException(); } return this.GetFieldHandleExpression(V_2, node.get_MappedInstructions()); }
public ICodeNode VisitArrayCreationExpression(ArrayCreationExpression node) { if (node.Initializer == null || node.Initializer.Expressions == null || node.Initializer.Expressions.Count != 1) { return(null); } MemberHandleExpression runtimeHandle = node.Initializer.Expressions[0] as MemberHandleExpression; if (runtimeHandle == null) { return(null); } if (!TryFillInitializer(node, runtimeHandle)) { return(null); } return(node); }
public virtual void VisitMemberHandleExpression(MemberHandleExpression node) { }
public virtual ICodeNode VisitMemberHandleExpression(MemberHandleExpression node) { return(node); }
public override void VisitMemberHandleExpression(MemberHandleExpression node) { throw new NotSupportedException(); }