IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ArrayType.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2015 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System;
25using System.Collections.Generic;
26
27namespace IKVM.Reflection
28{
29
31 {
32
33 internal static Type Make(Type type, CustomModifiers mods)
34 {
35 return type.Universe.CanonicalizeType(new ArrayType(type, mods));
36 }
37
43 ArrayType(Type type, CustomModifiers mods) :
44 base(type, mods, Signature.ELEMENT_TYPE_SZARRAY)
45 {
46
47 }
48
49 public override Type BaseType
50 {
51 get { return elementType.Module.Universe.System_Array; }
52 }
53
54 public override Type[] __GetDeclaredInterfaces()
55 {
56 return new Type[] {
57 Module.Universe.Import(typeof(IList<>)).MakeGenericType(elementType),
58 Module.Universe.Import(typeof(ICollection<>)).MakeGenericType(elementType),
59 Module.Universe.Import(typeof(IEnumerable<>)).MakeGenericType(elementType)
60 };
61 }
62
63 public override MethodBase[] __GetDeclaredMethods()
64 {
65 var int32 = new Type[] { Module.Universe.System_Int32 };
66 var list = new List<MethodBase>();
67 list.Add(new BuiltinArrayMethod(Module, this, "Set", CallingConventions.Standard | CallingConventions.HasThis, Module.Universe.System_Void, new Type[] { Module.Universe.System_Int32, elementType }));
68 list.Add(new BuiltinArrayMethod(Module, this, "Address", CallingConventions.Standard | CallingConventions.HasThis, elementType.MakeByRefType(), int32));
69 list.Add(new BuiltinArrayMethod(Module, this, "Get", CallingConventions.Standard | CallingConventions.HasThis, elementType, int32));
70 list.Add(new ConstructorInfoImpl(new BuiltinArrayMethod(Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, Module.Universe.System_Void, int32)));
71
72 for (var type = elementType; type.IsSZArray; type = type.GetElementType())
73 {
74 Array.Resize(ref int32, int32.Length + 1);
75 int32[int32.Length - 1] = int32[0];
76 list.Add(new ConstructorInfoImpl(new BuiltinArrayMethod(Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, Module.Universe.System_Void, int32)));
77 }
78
79 return list.ToArray();
80 }
81
82 public override TypeAttributes Attributes
83 {
84 get { return TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Serializable; }
85 }
86
87 public override int GetArrayRank()
88 {
89 return 1;
90 }
91
92 public override bool Equals(object o)
93 {
94 return EqualsHelper(o as ArrayType);
95 }
96
97 public override int GetHashCode()
98 {
99 return elementType.GetHashCode() * 5;
100 }
101
102 internal override string GetSuffix()
103 {
104 return "[]";
105 }
106
107 protected override Type Wrap(Type type, CustomModifiers mods)
108 {
109 return Make(type, mods);
110 }
111
112 }
113
114}
override TypeAttributes Attributes
Definition ArrayType.cs:83
override Type[] __GetDeclaredInterfaces()
Definition ArrayType.cs:54
override Type BaseType
Definition ArrayType.cs:50
override MethodBase[] __GetDeclaredMethods()
Definition ArrayType.cs:63
override int GetArrayRank()
Definition ArrayType.cs:87
override bool Equals(object o)
Definition ArrayType.cs:92
override Type Wrap(Type type, CustomModifiers mods)
Definition ArrayType.cs:107
override int GetHashCode()
Definition ArrayType.cs:97
bool EqualsHelper(ElementHolderType other)