本文整理汇总了C#中Mono.CSharp.Method.GetReturnType方法的典型用法代码示例。如果您正苦于以下问题:C# Method.GetReturnType方法的具体用法?C# Method.GetReturnType怎么用?C# Method.GetReturnType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.Method
的用法示例。
在下文中一共展示了Method.GetReturnType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Define
public override bool Define (TypeContainer parent)
{
int length = 1;
MethodName = "op_" + OperatorType;
if (SecondArgType != null)
length = 2;
Parameter [] param_list = new Parameter [length];
if ((ModFlags & RequiredModifiers) != RequiredModifiers){
Report.Error (
558, Location,
"User defined operators `" +
Prototype (parent) +
"' must be declared static and public");
return false;
}
param_list[0] = new Parameter (FirstArgType, FirstArgName,
Parameter.Modifier.NONE, null);
if (SecondArgType != null)
param_list[1] = new Parameter (SecondArgType, SecondArgName,
Parameter.Modifier.NONE, null);
OperatorMethod = new Method (ReturnType, ModFlags, MethodName,
new Parameters (param_list, null, Location),
OptAttributes, Mono.CSharp.Location.Null);
OperatorMethod.IsOperator = true;
OperatorMethod.Define (parent);
if (OperatorMethod.MethodBuilder == null)
return false;
OperatorMethodBuilder = OperatorMethod.MethodBuilder;
Type [] param_types = OperatorMethod.ParameterTypes;
Type declaring_type = OperatorMethodBuilder.DeclaringType;
Type return_type = OperatorMethod.GetReturnType ();
Type first_arg_type = param_types [0];
// Rules for conversion operators
if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) {
if (first_arg_type == return_type && first_arg_type == declaring_type){
Report.Error (
555, Location,
"User-defined conversion cannot take an object of the " +
"enclosing type and convert to an object of the enclosing" +
" type");
return false;
}
if (first_arg_type != declaring_type && return_type != declaring_type){
Report.Error (
556, Location,
"User-defined conversion must convert to or from the " +
"enclosing type");
return false;
}
if (first_arg_type == TypeManager.object_type ||
return_type == TypeManager.object_type){
Report.Error (
-8, Location,
"User-defined conversion cannot convert to or from " +
"object type");
return false;
}
if (first_arg_type.IsInterface || return_type.IsInterface){
Report.Error (
552, Location,
"User-defined conversion cannot convert to or from an " +
"interface type");
return false;
}
if (first_arg_type.IsSubclassOf (return_type) ||
return_type.IsSubclassOf (first_arg_type)){
Report.Error (
-10, Location,
"User-defined conversion cannot convert between types " +
"that derive from each other");
return false;
}
} else if (SecondArgType == null) {
// Checks for Unary operators
if (first_arg_type != declaring_type){
Report.Error (
562, Location,
"The parameter of a unary operator must be the " +
"containing type");
return false;
}
if (OperatorType == OpType.Increment || OperatorType == OpType.Decrement) {
if (return_type != declaring_type){
//.........这里部分代码省略.........