/
class.cs
8091 lines (6630 loc) · 208 KB
/
class.cs
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// class.cs: Class and Struct handlers
//
// Authors: Miguel de Icaza (miguel@gnu.org)
// Martin Baulig (martin@ximian.com)
// Marek Safar (marek.safar@seznam.cz)
//
// Licensed under the terms of the GNU GPL
//
// (C) 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
// (C) 2004 Novell, Inc
//
//
// 2002-10-11 Miguel de Icaza <miguel@ximian.com>
//
// * class.cs: Following the comment from 2002-09-26 to AddMethod, I
// have fixed a remaining problem: not every AddXXXX was adding a
// fully qualified name.
//
// Now everyone registers a fully qualified name in the DeclSpace as
// being defined instead of the partial name.
//
// Downsides: we are slower than we need to be due to the excess
// copies and the names being registered this way.
//
// The reason for this is that we currently depend (on the corlib
// bootstrap for instance) that types are fully qualified, because
// we dump all the types in the namespace, and we should really have
// types inserted into the proper namespace, so we can only store the
// basenames in the defined_names array.
//
//
#define CACHE
using System;
using System.Text;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Xml;
using Mono.CompilerServices.SymbolWriter;
namespace Mono.CSharp {
public enum Kind {
Root,
Struct,
Class,
Interface
}
/// <summary>
/// This is the base class for structs and classes.
/// </summary>
public abstract class TypeContainer : DeclSpace, IMemberContainer {
public class MemberCoreArrayList: ArrayList
{
/// <summary>
/// Defines the MemberCore objects that are in this array
/// </summary>
public virtual void DefineContainerMembers ()
{
foreach (MemberCore mc in this) {
mc.Define ();
}
}
public virtual void Emit ()
{
foreach (MemberCore mc in this)
mc.Emit ();
}
}
public class MethodArrayList: MemberCoreArrayList
{
[Flags]
enum CachedMethods {
Equals = 1,
GetHashCode = 1 << 1
}
CachedMethods cached_method;
TypeContainer container;
public MethodArrayList (TypeContainer container)
{
this.container = container;
}
/// <summary>
/// Method container contains Equals method
/// </summary>
public bool HasEquals {
set {
cached_method |= CachedMethods.Equals;
}
get {
return (cached_method & CachedMethods.Equals) != 0;
}
}
/// <summary>
/// Method container contains GetHashCode method
/// </summary>
public bool HasGetHashCode {
set {
cached_method |= CachedMethods.GetHashCode;
}
get {
return (cached_method & CachedMethods.GetHashCode) != 0;
}
}
public override void DefineContainerMembers ()
{
base.DefineContainerMembers ();
if ((RootContext.WarningLevel >= 3) && HasEquals && !HasGetHashCode) {
Report.Warning (659, container.Location, "'{0}' overrides Object.Equals(object) but does not override Object.GetHashCode()", container.GetSignatureForError ());
}
}
}
public sealed class IndexerArrayList: MemberCoreArrayList
{
/// <summary>
/// The indexer name for this container
/// </summary>
public string IndexerName = DefaultIndexerName;
bool seen_normal_indexers = false;
TypeContainer container;
public IndexerArrayList (TypeContainer container)
{
this.container = container;
}
/// <summary>
/// Defines the indexers, and also verifies that the IndexerNameAttribute in the
/// class is consistent. Either it is `Item' or it is the name defined by all the
/// indexers with the `IndexerName' attribute.
///
/// Turns out that the IndexerNameAttribute is applied to each indexer,
/// but it is never emitted, instead a DefaultMember attribute is attached
/// to the class.
/// </summary>
public override void DefineContainerMembers()
{
base.DefineContainerMembers ();
string class_indexer_name = null;
//
// If there's both an explicit and an implicit interface implementation, the
// explicit one actually implements the interface while the other one is just
// a normal indexer. See bug #37714.
//
// Invariant maintained by AddIndexer(): All explicit interface indexers precede normal indexers
foreach (Indexer i in this) {
if (i.InterfaceType != null) {
if (seen_normal_indexers)
throw new Exception ("Internal Error: 'Indexers' array not sorted properly.");
continue;
}
seen_normal_indexers = true;
if (class_indexer_name == null) {
class_indexer_name = i.ShortName;
continue;
}
if (i.ShortName != class_indexer_name)
Report.Error (668, i.Location, "Two indexers have different names; the IndexerName attribute must be used with the same name on every indexer within a type");
}
if (class_indexer_name != null)
IndexerName = class_indexer_name;
}
public override void Emit ()
{
base.Emit ();
if (!seen_normal_indexers)
return;
CustomAttributeBuilder cb = new CustomAttributeBuilder (TypeManager.default_member_ctor, new string [] { IndexerName });
container.TypeBuilder.SetCustomAttribute (cb);
}
}
public class OperatorArrayList: MemberCoreArrayList
{
TypeContainer container;
public OperatorArrayList (TypeContainer container)
{
this.container = container;
}
//
// Operator pair checking
//
class OperatorEntry
{
public int flags;
public Type ret_type;
public Type type1, type2;
public Operator op;
public Operator.OpType ot;
public OperatorEntry (int f, Operator o)
{
flags = f;
ret_type = o.OperatorMethod.ReturnType;
Type [] pt = o.OperatorMethod.ParameterTypes;
type1 = pt [0];
type2 = pt [1];
op = o;
ot = o.OperatorType;
}
public override int GetHashCode ()
{
return ret_type.GetHashCode ();
}
public override bool Equals (object o)
{
OperatorEntry other = (OperatorEntry) o;
if (other.ret_type != ret_type)
return false;
if (other.type1 != type1)
return false;
if (other.type2 != type2)
return false;
return true;
}
}
//
// Checks that some operators come in pairs:
// == and !=
// > and <
// >= and <=
// true and false
//
// They are matched based on the return type and the argument types
//
void CheckPairedOperators ()
{
Hashtable pairs = new Hashtable (null, null);
Operator true_op = null;
Operator false_op = null;
bool has_equality_or_inequality = false;
// Register all the operators we care about.
foreach (Operator op in this){
int reg = 0;
switch (op.OperatorType){
case Operator.OpType.Equality:
reg = 1;
has_equality_or_inequality = true;
break;
case Operator.OpType.Inequality:
reg = 2;
has_equality_or_inequality = true;
break;
case Operator.OpType.True:
true_op = op;
break;
case Operator.OpType.False:
false_op = op;
break;
case Operator.OpType.GreaterThan:
reg = 1; break;
case Operator.OpType.LessThan:
reg = 2; break;
case Operator.OpType.GreaterThanOrEqual:
reg = 1; break;
case Operator.OpType.LessThanOrEqual:
reg = 2; break;
}
if (reg == 0)
continue;
OperatorEntry oe = new OperatorEntry (reg, op);
object o = pairs [oe];
if (o == null)
pairs [oe] = oe;
else {
oe = (OperatorEntry) o;
oe.flags |= reg;
}
}
if (true_op != null){
if (false_op == null)
Report.Error (216, true_op.Location, "operator true requires a matching operator false");
} else if (false_op != null)
Report.Error (216, false_op.Location, "operator false requires a matching operator true");
//
// Look for the mistakes.
//
foreach (DictionaryEntry de in pairs){
OperatorEntry oe = (OperatorEntry) de.Key;
if (oe.flags == 3)
continue;
string s = "";
switch (oe.ot){
case Operator.OpType.Equality:
s = "!=";
break;
case Operator.OpType.Inequality:
s = "==";
break;
case Operator.OpType.GreaterThan:
s = "<";
break;
case Operator.OpType.LessThan:
s = ">";
break;
case Operator.OpType.GreaterThanOrEqual:
s = "<=";
break;
case Operator.OpType.LessThanOrEqual:
s = ">=";
break;
}
Report.Error (216, oe.op.Location,
"The operator `" + oe.op + "' requires a matching operator `" + s + "' to also be defined");
}
if (has_equality_or_inequality && (RootContext.WarningLevel > 2)) {
if (container.Methods == null || !container.Methods.HasEquals)
Report.Warning (660, container.Location, "'{0}' defines operator == or operator != but does not override Object.Equals(object o)", container.GetSignatureForError ());
if (container.Methods == null || !container.Methods.HasGetHashCode)
Report.Warning (661, container.Location, "'{0}' defines operator == or operator != but does not override Object.GetHashCode()", container.GetSignatureForError ());
}
}
public override void DefineContainerMembers ()
{
base.DefineContainerMembers ();
CheckPairedOperators ();
}
}
// Whether this is a struct, class or interface
public readonly Kind Kind;
// Holds a list of classes and structures
ArrayList types;
// Holds the list of properties
MemberCoreArrayList properties;
// Holds the list of enumerations
MemberCoreArrayList enums;
// Holds the list of delegates
MemberCoreArrayList delegates;
// Holds the list of constructors
protected MemberCoreArrayList instance_constructors;
// Holds the list of fields
MemberCoreArrayList fields;
// Holds a list of fields that have initializers
protected ArrayList initialized_fields;
// Holds a list of static fields that have initializers
protected ArrayList initialized_static_fields;
// Holds the list of constants
MemberCoreArrayList constants;
// Holds the list of
MemberCoreArrayList interfaces;
// Holds the methods.
MethodArrayList methods;
// Holds the events
protected MemberCoreArrayList events;
// Holds the indexers
IndexerArrayList indexers;
// Holds the operators
MemberCoreArrayList operators;
// Holds the iterators
ArrayList iterators;
// Holds the parts of a partial class;
ArrayList parts;
//
// Pointers to the default constructor and the default static constructor
//
protected Constructor default_constructor;
protected Constructor default_static_constructor;
//
// Whether we have at least one non-static field
//
bool have_nonstatic_fields = false;
//
// This one is computed after we can distinguish interfaces
// from classes from the arraylist `type_bases'
//
string base_class_name;
TypeExpr base_type;
ArrayList type_bases;
bool members_defined;
bool members_defined_ok;
// The interfaces we implement.
protected Type[] ifaces;
protected Type ptype;
// The base member cache and our member cache
MemberCache base_cache;
MemberCache member_cache;
public const string DefaultIndexerName = "Item";
Type GenericType;
public TypeContainer (NamespaceEntry ns, TypeContainer parent, MemberName name,
Attributes attrs, Kind kind, Location l)
: base (ns, parent, name, attrs, l)
{
this.Kind = kind;
types = new ArrayList ();
base_class_name = null;
}
public bool AddToMemberContainer (MemberCore symbol)
{
return AddToContainer (symbol, String.Concat (Name, '.', symbol.Name), symbol.Name);
}
bool AddToTypeContainer (DeclSpace ds)
{
return AddToContainer (ds, ds.Name, ds.Basename);
}
public void AddConstant (Const constant)
{
if (!AddToMemberContainer (constant))
return;
if (constants == null)
constants = new MemberCoreArrayList ();
constants.Add (constant);
}
public void AddEnum (Mono.CSharp.Enum e)
{
if (!AddToTypeContainer (e))
return;
if (enums == null)
enums = new MemberCoreArrayList ();
enums.Add (e);
}
public void AddClassOrStruct (TypeContainer c)
{
if (!AddToTypeContainer (c))
return;
types.Add (c);
}
public void AddDelegate (Delegate d)
{
if (!AddToTypeContainer (d))
return;
if (delegates == null)
delegates = new MemberCoreArrayList ();
delegates.Add (d);
}
public void AddMethod (Method method)
{
if (!AddToMemberContainer (method))
return;
if (methods == null)
methods = new MethodArrayList (this);
if (method.Name.IndexOf ('.') != -1)
methods.Insert (0, method);
else
methods.Add (method);
}
public void AddConstructor (Constructor c)
{
if (c.Name != Basename) {
Report.Error (1520, c.Location, "Class, struct, or interface method must have a return type");
}
bool is_static = (c.ModFlags & Modifiers.STATIC) != 0;
if (is_static){
if (default_static_constructor != null) {
Report.SymbolRelatedToPreviousError (default_static_constructor);
Report.Error (111, c.Location, "Type '{0}' already defines a member " +
"called '{1}' with the same parameter types", Name, c.Name);
return;
}
default_static_constructor = c;
} else {
if (c.IsDefault ()){
if (default_constructor != null) {
Report.SymbolRelatedToPreviousError (default_constructor);
Report.Error (111, c.Location, "Type '{0}' already defines a member " +
"called '{1}' with the same parameter types", Name, c.Name);
return;
}
default_constructor = c;
}
if (instance_constructors == null)
instance_constructors = new MemberCoreArrayList ();
instance_constructors.Add (c);
}
}
public void AddInterface (TypeContainer iface)
{
if (!AddToTypeContainer (iface))
return;
if (interfaces == null) {
interfaces = new MemberCoreArrayList ();
}
interfaces.Add (iface);
}
public void AddField (Field field)
{
if (!AddToMemberContainer (field))
return;
if (fields == null)
fields = new MemberCoreArrayList ();
fields.Add (field);
if (field.HasInitializer){
if ((field.ModFlags & Modifiers.STATIC) != 0){
if (initialized_static_fields == null)
initialized_static_fields = new ArrayList ();
initialized_static_fields.Add (field);
} else {
if (initialized_fields == null)
initialized_fields = new ArrayList ();
initialized_fields.Add (field);
}
}
if ((field.ModFlags & Modifiers.STATIC) == 0)
have_nonstatic_fields = true;
}
public void AddProperty (Property prop)
{
if (!AddToMemberContainer (prop) ||
!AddToMemberContainer (prop.Get) || !AddToMemberContainer (prop.Set))
return;
if (properties == null)
properties = new MemberCoreArrayList ();
if (prop.Name.IndexOf ('.') != -1)
properties.Insert (0, prop);
else
properties.Add (prop);
}
public void AddEvent (Event e)
{
if (!AddToMemberContainer (e))
return;
if (e is EventProperty) {
if (!AddToMemberContainer (e.Add))
return;
if (!AddToMemberContainer (e.Remove))
return;
}
if (events == null)
events = new MemberCoreArrayList ();
events.Add (e);
}
/// <summary>
/// Indexer has special handling in constrast to other AddXXX because the name can be driven by IndexerNameAttribute
/// </summary>
public void AddIndexer (Indexer i)
{
if (indexers == null)
indexers = new IndexerArrayList (this);
if (i.IsExplicitImpl)
indexers.Insert (0, i);
else
indexers.Add (i);
}
public void AddOperator (Operator op)
{
if (!AddToMemberContainer (op))
return;
if (operators == null)
operators = new OperatorArrayList (this);
operators.Add (op);
}
public void AddIterator (Iterator i)
{
if (iterators == null)
iterators = new ArrayList ();
iterators.Add (i);
}
public void AddType (TypeContainer tc)
{
types.Add (tc);
}
public void AddPart (ClassPart part)
{
if (parts == null)
parts = new ArrayList ();
parts.Add (part);
}
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type == TypeManager.default_member_type) {
if (Indexers != null) {
Report.Error (646, a.Location,
"Cannot specify the DefaultMember attribute on" +
" a type containing an indexer");
return;
}
}
base.ApplyAttributeBuilder (a, cb);
}
public override AttributeTargets AttributeTargets {
get {
switch (Kind) {
case Kind.Class:
return AttributeTargets.Class;
case Kind.Struct:
return AttributeTargets.Struct;
case Kind.Interface:
return AttributeTargets.Interface;
default:
throw new NotSupportedException ();
}
}
}
public ArrayList Types {
get {
return types;
}
}
public MethodArrayList Methods {
get {
return methods;
}
}
public ArrayList Constants {
get {
return constants;
}
}
public ArrayList Interfaces {
get {
return interfaces;
}
}
public ArrayList Iterators {
get {
return iterators;
}
}
public string Base {
get {
return base_class_name;
}
}
public ArrayList Bases {
get {
return type_bases;
}
set {
type_bases = value;
}
}
public ArrayList Fields {
get {
return fields;
}
}
public ArrayList InstanceConstructors {
get {
return instance_constructors;
}
}
public ArrayList Properties {
get {
return properties;
}
}
public ArrayList Events {
get {
return events;
}
}
public ArrayList Enums {
get {
return enums;
}
}
public ArrayList Indexers {
get {
return indexers;
}
}
public ArrayList Operators {
get {
return operators;
}
}
public ArrayList Delegates {
get {
return delegates;
}
}
public ArrayList Parts {
get {
return parts;
}
}
public virtual TypeAttributes TypeAttr {
get {
return Modifiers.TypeAttr (ModFlags, this);
}
}
public string IndexerName {
get {
return indexers == null ? DefaultIndexerName : indexers.IndexerName;
}
}
//
// Emits the instance field initializers
//
public bool EmitFieldInitializers (EmitContext ec)
{
ArrayList fields;
Expression instance_expr;
if (ec.IsStatic){
fields = initialized_static_fields;
instance_expr = null;
} else {
fields = initialized_fields;
instance_expr = new This (Location.Null).Resolve (ec);
}
if (fields == null)
return true;
foreach (Field f in fields){
Expression e = f.GetInitializerExpression (ec);
if (e == null)
return false;
Location l = f.Location;
FieldExpr fe = new FieldExpr (f.FieldBuilder, l);
fe.InstanceExpression = instance_expr;
fe.IsFieldInitializer = true;
ExpressionStatement a = new Assign (fe, e, l);
a = a.ResolveStatement (ec);
if (a == null)
return false;
a.EmitStatement (ec);
}
return true;
}
//
// Defines the default constructors
//
protected void DefineDefaultConstructor (bool is_static)
{
Constructor c;
// The default constructor is public
// If the class is abstract, the default constructor is protected
// The default static constructor is private
int mods = Modifiers.PUBLIC;
if (is_static)
mods = Modifiers.STATIC | Modifiers.PRIVATE;
else if ((ModFlags & Modifiers.ABSTRACT) != 0)
mods = Modifiers.PROTECTED;
c = new Constructor (this, Basename, mods, Parameters.EmptyReadOnlyParameters,
new ConstructorBaseInitializer (
null, Parameters.EmptyReadOnlyParameters,
Location),
Location);
AddConstructor (c);
c.Block = new ToplevelBlock (null, Location);
}
/// <remarks>
/// The pending methods that need to be implemented
// (interfaces or abstract methods)
/// </remarks>
public PendingImplementation Pending;
public abstract void Register ();
public abstract PendingImplementation GetPendingImplementations ();
TypeExpr[] GetPartialBases (out TypeExpr base_class, out bool error)
{
ArrayList ifaces = new ArrayList ();
base_class = null;
Location base_loc = Location.Null;
foreach (ClassPart part in parts) {
TypeExpr new_base_class;
TypeExpr[] new_ifaces;
new_ifaces = part.GetClassBases (out new_base_class, out error);
if (error)
return null;
if ((base_class != null) && (new_base_class != null) &&
!base_class.Equals (new_base_class)) {
Report.Error (263, part.Location,
"Partial declarations of `{0}' must " +
"not specify different base classes",
Name);
if (!Location.IsNull (base_loc))
Report.LocationOfPreviousError (base_loc);
error = true;
return null;
}
if ((base_class == null) && (new_base_class != null)) {
base_class = new_base_class;
base_loc = part.Location;
}
if (new_ifaces == null)
continue;
foreach (TypeExpr iface in new_ifaces) {
bool found = false;
foreach (TypeExpr old_iface in ifaces) {
if (old_iface.Equals (iface)) {
found = true;
break;
}
}
if (!found)
ifaces.Add (iface);
}
}
error = false;
TypeExpr[] retval = new TypeExpr [ifaces.Count];
ifaces.CopyTo (retval, 0);
return retval;
}
TypeExpr[] GetNormalBases (out TypeExpr base_class, out bool error)
{
base_class = null;
int count = Bases.Count;
int start = 0, i, j;
if (Kind == Kind.Class){
TypeExpr name = ResolveBaseTypeExpr (
(Expression) Bases [0], false, Location);
if (name == null){
error = true;
return null;
}
if (!name.IsInterface) {
// base_class could be a class, struct, enum, delegate.
// This is validated in GetClassBases.
base_class = name;
start = 1;
}
}
TypeExpr [] ifaces = new TypeExpr [count-start];
for (i = start, j = 0; i < count; i++, j++){
TypeExpr resolved = ResolveBaseTypeExpr ((Expression) Bases [i], false, Location);
if (resolved == null) {