summaryrefslogtreecommitdiff
path: root/src/msil/ch/epfl/lamp/compiler/msil/ConstructorInfo.java
blob: 69f5d6d32a587826ac95acbb4459d7344c73ba52 (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
/*
 * System.Reflection-like API for access to .NET assemblies (DLL & EXE)
 */


package ch.epfl.lamp.compiler.msil;

/**
 * Discovers the attributes of a class constructor and provides
 * access to constructor metadata.
 * ConstructorInfo is used to discover the attributes of a constructor
 * as well as to invoke a constructor. Objects are created by invoking
 * either the GetConstructors or GetConstructor method of a Type object.
 *
 * @author Nikolay Mihaylov
 * @version 1.0
 */
public class ConstructorInfo extends MethodBase {
    //##########################################################################

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

    public final boolean IsConstructor() { return true; }

    protected static final String CTOR = ".ctor";
    protected static final String CCTOR = ".cctor";
    protected static final ConstructorInfo[] EMPTY_ARRAY = new ConstructorInfo[0];

    protected static String getName(int attrs) {
	  return (attrs & MethodAttributes.Static) == 0 ? CTOR : CCTOR;
    }

    /** Public constructors */

    public ConstructorInfo(Type declType, int attrs, Type[] paramTypes) {
	  super(getName(attrs), declType, attrs, paramTypes);
	  assert declType != null : "Owner can't be 'null' for a constructor!";
    }

    public ConstructorInfo(Type declType, int attrs, ParameterInfo[] params)
    {
	  super(getName(attrs), declType, attrs, params);
	  assert declType != null : "Owner can't be 'null' for a constructor!";
    }


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

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

} // class ConstructorInfo