summaryrefslogtreecommitdiff
path: root/src/msil/ch/epfl/lamp/compiler/msil/MethodInfo.java
blob: a415e7551f7f58f734e19fbfa130d25299266930 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * System.Reflection-like API for access to .NET assemblies (DLL & EXE)
 */


package ch.epfl.lamp.compiler.msil;

import java.util.Iterator;

/**
 * Discovers the attributes of a method and provides access to method metadata.
 *
 * @author Nikolay Mihaylov
 * @version 1.0
 */
public class MethodInfo extends MethodBase {

    public boolean HasPtrParamOrRetType() {
        if(ReturnType.IsByRef() && !(ReturnType.GetElementType().IsValueType())) {
            /* A method returning ByRef won't pass peverify, so I guess this is dead code. */
            return true;
        }
        if(ReturnType.IsPointer()) {
            return true;
        }
        return super.HasPtrParamOrRetType();
    }

    //##########################################################################
    // public members

    public final int MemberType() { return MemberTypes.Method; }

    public final boolean IsConstructor() { return false; }

    /** The return type of this method.
     */
    public final Type ReturnType;

    //##########################################################################
    // protected members

    protected static final MethodInfo[] EMPTY_ARRAY = new MethodInfo[0];

    /**
     * Constructor Initializes a new instance of the MethodInfo class.
     */
    protected MethodInfo(String name, Type declType,
			 int attrs, Type returnType, Type[] paramTypes )
    {
	super(name, declType, attrs, paramTypes);
	ReturnType = returnType;
    }

    protected MethodInfo(String name, Type declType,
			 int attrs, Type returnType, ParameterInfo[] params )
    {
	super(name, declType, attrs, params);
	ReturnType = returnType;
    }

    public String toString() {
 	return MethodAttributes.toString(Attributes) + " " + ReturnType +
	    " " + DeclaringType + "::" + Name + params2String();
    }

    //##########################################################################

}  // class MethodInfo