+2004-11-18 Martin Baulig <martin@ximian.com>
+
+ * rootcontext.cs
+ (RootContext.LookupType): Return a `Type', not a `TypeExpr'.
+
2004-11-18 Martin Baulig <martin@ximian.com>
* ecore.cs (TypeExpr.DoResolveAsTypeStep): Make this protected.
/// </summary>
protected virtual Type CheckAttributeType (EmitContext ec, bool complain)
{
- TypeExpr t1 = RootContext.LookupType (ec.DeclSpace, Name, true, Location);
+ Type t1 = RootContext.LookupType (ec.DeclSpace, Name, true, Location);
// FIXME: Shouldn't do this for quoted attributes: [@A]
- TypeExpr t2 = RootContext.LookupType (ec.DeclSpace, Name + "Attribute", true, Location);
+ Type t2 = RootContext.LookupType (ec.DeclSpace, Name + "Attribute", true, Location);
String err0616 = null;
- if (t1 != null && ! t1.IsAttribute) {
+ if (t1 != null && ! t1.IsSubclassOf (TypeManager.attribute_type)) {
t1 = null;
err0616 = "'" + Name + "': is not an attribute class";
}
- if (t2 != null && ! t2.IsAttribute) {
+ if (t2 != null && ! t2.IsSubclassOf (TypeManager.attribute_type)) {
t2 = null;
err0616 = (err0616 != null)
? "Neither '" + Name + "' nor '" + Name + "Attribute' is an attribute class"
return null;
}
if (t1 != null)
- return t1.Type;
+ return t1;
if (t2 != null)
- return t2.Type;
+ return t2;
if (err0616 != null) {
Report.Error (616, Location, err0616);
return null;
{
DeclSpace ds = ec.DeclSpace;
NamespaceEntry ns = ds.NamespaceEntry;
- TypeExpr t;
+ Type t;
IAlias alias_value;
//
if (alias_value.IsType)
return alias_value.ResolveAsType (ec);
if ((t = RootContext.LookupType (ds, alias_value.Name, true, loc)) != null)
- return t;
+ return new TypeExpression (t, loc);
}
}
if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
- return t;
+ return new TypeExpression (t, loc);
if (alias_value != null) {
if (alias_value.IsType)
return alias_value.ResolveAsType (ec);
if ((t = RootContext.LookupType (ds, alias_value.Name, true, loc)) != null)
- return t;
+ return new TypeExpression (t, loc);
// we have alias value, but it isn't Type, so try if it's namespace
return new SimpleName (alias_value.Name, loc);
protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
{
if (type == null) {
- TypeExpr texpr = RootContext.LookupType (
+ type = RootContext.LookupType (
ec.DeclSpace, name, false, Location.Null);
- if (texpr == null)
+ if (type == null)
return null;
-
- texpr = texpr.ResolveAsTypeTerminal (ec);
- if (texpr == null)
- return null;
-
- type = texpr.Type;
}
return this;
//
// For now, fall back to the full lookup in that case.
//
- TypeExpr texpr = RootContext.LookupType (
- ec.DeclSpace, cname, false, loc);
-
- if (texpr == null)
- return null;
-
- texpr = texpr.ResolveAsTypeTerminal (ec);
- if (texpr == null)
+ type = RootContext.LookupType (ec.DeclSpace, cname, false, loc);
+ if (type == null)
return null;
-
- type = texpr.Type;
}
if (!ec.InUnsafe && type.IsPointer){
return ns.Substring (0, i);
}
- static TypeExpr NamespaceLookup (DeclSpace ds, string name,
- int num_type_args, Location loc)
+ static Type NamespaceLookup (DeclSpace ds, string name, int num_type_args, Location loc)
{
//
// Try in the current namespace and all its implicit parents
if (!result.IsType)
return null;
- return result.ResolveAsType (ds.EmitContext);
+ TypeExpr texpr = result.ResolveAsType (ds.EmitContext);
+ if (texpr == null)
+ return null;
+
+ return texpr.Type;
}
return null;
}
- static public TypeExpr LookupType (DeclSpace ds, string name, bool silent,
- Location loc)
+ static public Type LookupType (DeclSpace ds, string name, bool silent, Location loc)
{
return LookupType (ds, name, silent, 0, loc);
}
//
// Come to think of it, this should be a DeclSpace
//
- static public TypeExpr LookupType (DeclSpace ds, string name, bool silent,
- int num_type_params, Location loc)
+ static public Type LookupType (DeclSpace ds, string name, bool silent,
+ int num_type_params, Location loc)
{
- TypeExpr t;
+ Type t;
if (ds.Cache.Contains (name)){
- t = (TypeExpr) ds.Cache [name];
+ t = (Type) ds.Cache [name];
if (t != null)
return t;
} else {
//
Type type = TypeManager.LookupType (current_type.FullName + "." + name);
if (type != null){
- type = ds.ResolveNestedType (type, loc);
- t = new TypeExpression (type, loc);
+ t = ds.ResolveNestedType (type, loc);
ds.Cache [name] = t;
return t;
}
// This is the silent version of LookupType, you can use this
// to `probe' for a type
// </summary>
- static public TypeExpr LookupType (TypeContainer tc, string name, Location loc)
+ static public Type LookupType (TypeContainer tc, string name, Location loc)
{
return LookupType (tc, name, true, loc);
}