No significant changes. Adding a few more tests to the primitives test case and...
[boo.git] / src / Boo.Lang.Compiler / TypeSystem / Error.cs
blob96c2b34f6c91e1aec855c8f43e7428052c04c235
1 #region license
2 // Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 // * Neither the name of Rodrigo B. de Oliveira nor the names of its
14 // contributors may be used to endorse or promote products derived from this
15 // software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #endregion
29 namespace Boo.Lang.Compiler.TypeSystem
31 public abstract class AbstractType : IType, INamespace
33 public abstract string Name
35 get;
38 public abstract EntityType EntityType
40 get;
43 public virtual string FullName
45 get
47 return Name;
51 public virtual IType Type
53 get
55 return this;
59 public virtual bool IsByRef
61 get
63 return false;
67 public virtual bool IsClass
69 get
71 return false;
75 public virtual bool IsAbstract
77 get
79 return false;
83 public virtual bool IsInterface
85 get
87 return false;
91 public virtual bool IsFinal
93 get
95 return true;
99 public virtual bool IsEnum
103 return false;
107 public virtual bool IsValueType
111 return false;
115 public virtual bool IsArray
119 return false;
123 public virtual IType BaseType
127 return null;
131 public virtual IType GetElementType()
133 return null;
136 public virtual IEntity GetDefaultMember()
138 return null;
141 public virtual int GetTypeDepth()
143 return 0;
146 public virtual bool IsSubclassOf(IType other)
148 return false;
151 public virtual bool IsAssignableFrom(IType other)
153 return false;
156 public virtual IConstructor[] GetConstructors()
158 return new IConstructor[0];
161 public virtual IType[] GetInterfaces()
163 return new IType[0];
166 public virtual IEntity[] GetMembers()
168 return new IEntity[0];
171 public virtual INamespace ParentNamespace
175 return null;
179 public virtual bool Resolve(Boo.Lang.List targetList, string name, EntityType flags)
181 return false;
184 override public string ToString()
186 return Name;
189 IGenericTypeInfo IType.GenericInfo
191 get { return null; }
194 IConstructedTypeInfo IType.ConstructedInfo
196 get { return null; }
200 public class Null : AbstractType
202 public static Null Default = new Null();
204 private Null()
208 override public string Name
212 return "null";
216 override public EntityType EntityType
220 return EntityType.Null;
225 public class Unknown : AbstractType
227 public static Unknown Default = new Unknown();
229 private Unknown()
233 override public string Name
237 return "unknown";
241 override public EntityType EntityType
245 return EntityType.Unknown;
250 public class Error : AbstractType
252 public static Error Default = new Error();
254 private Error()
258 override public string Name
262 return "error";
266 override public EntityType EntityType
270 return EntityType.Error;