* ecore.cs (TypeExpr.ResolveType): Removed.
(Expression.ResolveAsTypeTerminal): We always return a fully
resolved `TypeExpr', so we can just access its `Type'.
* class.cs (TypeContainer.DefineType): Resolve `CurrentType' here.
svn path=/trunk/mcs/; revision=36242
+2004-11-18 Martin Baulig <martin@ximian.com>
+
+ * ecore.cs (TypeExpr.ResolveType): Removed.
+ (Expression.ResolveAsTypeTerminal): We always return a fully
+ resolved `TypeExpr', so we can just access its `Type'.
+
+ * class.cs (TypeContainer.DefineType): Resolve `CurrentType' here.
+
2004-11-17 Martin Baulig <martin@ximian.com>
* ecore.cs (IAlias.Type): Replaced with ResolveAsType() to make
return null;
}
if (t1 != null)
- return t1.ResolveType (ec);
+ return t1.Type;
if (t2 != null)
- return t2.ResolveType (ec);
+ return t2.Type;
if (err0616 != null) {
Report.Error (616, Location, err0616);
return null;
TypeManager.AddUserType (Name, TypeBuilder, this);
+ TypeExpr current_type = null;
+
if (IsGeneric) {
string[] param_names = new string [TypeParameters.Length];
for (int i = 0; i < TypeParameters.Length; i++)
for (int i = offset; i < gen_params.Length; i++)
CurrentTypeParameters [i - offset].DefineConstraints ();
- CurrentType = new ConstructedType (Name, TypeParameters, Location);
+ current_type = new ConstructedType (Name, TypeParameters, Location);
}
if (IsGeneric) {
}
}
- ConstructedType constructed = parent_type as ConstructedType;
- if ((constructed == null) && (parent_type != null))
- ptype = parent_type.ResolveType (ec);
- else
- ptype = null;
-
- if (constructed != null) {
- ptype = constructed.ResolveType (ec);
- if (ptype == null) {
+ if (parent_type != null) {
+ parent_type = parent_type.ResolveAsTypeTerminal (ec);
+ if (parent_type == null) {
error = true;
return null;
}
+
+ ptype = parent_type.Type;
}
if (!CheckRecursiveDefinition ()) {
}
}
+ if (current_type != null) {
+ CurrentType = current_type.ResolveAsTypeTerminal (ec);
+ if (CurrentType == null) {
+ error = true;
+ return null;
+ }
+ }
+
//
// Finish the setup for the EmitContext
//
DefineContainerMembers (delegates);
if (CurrentType != null) {
- GenericType = CurrentType.ResolveType (ec);
+ GenericType = CurrentType.Type;
ec.ContainerType = GenericType;
}
return false;
if (container.CurrentType != null)
- declaring_type = container.CurrentType.ResolveType (ec);
+ declaring_type = container.CurrentType.Type;
else
declaring_type = container.TypeBuilder;
if (texpr == null)
return false;
- MemberType = texpr.ResolveType (ec);
- if (MemberType == null)
- return false;
+ MemberType = texpr.Type;
if ((Parent.ModFlags & Modifiers.SEALED) != 0){
if ((ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0){
if (iface_texpr == null)
return false;
- InterfaceType = iface_texpr.ResolveType (ec);
- if (InterfaceType == null)
- return false;
+ InterfaceType = iface_texpr.Type;
if (InterfaceType.IsClass) {
Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", ExplicitInterfaceName);
bool old_unsafe = ec.InUnsafe;
ec.InUnsafe = InUnsafe;
TypeExpr texpr = Type.ResolveAsTypeTerminal (ec);
+ ec.InUnsafe = old_unsafe;
if (texpr == null)
return false;
- MemberType = texpr.ResolveType (ec);
- ec.InUnsafe = old_unsafe;
- if (MemberType == null)
- return false;
+ MemberType = texpr.Type;
if (!CheckBase ())
return false;
else
args = TypeParameters;
- ConstructedType ctype = new ConstructedType (t, args, loc);
- t = ctype.ResolveType (ec);
+ TypeExpr ctype = new ConstructedType (t, args, loc);
+ ctype = ctype.ResolveAsTypeTerminal (ec);
+ if (ctype == null)
+ return null;
+
+ t = ctype.Type;
}
return t;
public abstract TypeExpr DoResolveAsTypeStep (EmitContext ec);
- public Type ResolveType (EmitContext ec)
- {
- TypeExpr t = ResolveAsTypeTerminal (ec);
- if (t == null)
- return null;
-
- return t.Type;
- }
-
public abstract string Name {
get;
}
if (texpr == null)
return null;
- type = texpr.ResolveType (ec);
- if (type == null)
+ texpr = texpr.ResolveAsTypeTerminal (ec);
+ if (texpr == null)
return null;
+
+ type = texpr.Type;
}
return this;
if (texpr == null)
return null;
- Type type = texpr.ResolveType (ec);
- if (type == null)
- return null;
-
+ Type type = texpr.Type;
int num_args = TypeManager.GetNumberOfTypeArguments (type);
if (args != null) {
Type ctype;
if (!is_field_initializer &&
(ec.TypeContainer.CurrentType != null))
- ctype = ec.TypeContainer.CurrentType.ResolveType (ec);
+ ctype = ec.TypeContainer.CurrentType.Type;
else
ctype = ec.ContainerType;
TypeExpr texpr = ProbeType.ResolveAsTypeTerminal (ec);
if (texpr == null)
return null;
- probe_type = texpr.ResolveType (ec);
+ probe_type = texpr.Type;
CheckObsoleteAttribute (probe_type);
if (target == null)
return null;
- type = target.ResolveType (ec);
+ type = target.Type;
CheckObsoleteAttribute (type);
if (texpr == null)
return null;
- type = texpr.ResolveType (ec);
+ type = texpr.Type;
if (type == null)
return null;
if (array_type_expr == null)
return false;
- type = array_type_expr.ResolveType (ec);
+ type = array_type_expr.Type;
if (!type.IsArray) {
Error (622, "Can only use array initializer expressions to assign to array types. Try using a new expression instead.");
eclass = ExprClass.Variable;
if (ec.TypeContainer.CurrentType != null)
- type = ec.TypeContainer.CurrentType.ResolveType (ec);
+ type = ec.TypeContainer.CurrentType.Type;
else
type = ec.ContainerType;
if (texpr == null)
return null;
- typearg = texpr.ResolveType (ec);
+ typearg = texpr.Type;
if (typearg == TypeManager.void_type) {
Error (673, "System.Void cannot be used from C# - " +
return null;
}
- type_queried = texpr.ResolveType (ec);
+ type_queried = texpr.Type;
CheckObsoleteAttribute (type_queried);
Type expr_type;
if (expr is TypeExpr){
- expr_type = ((TypeExpr) expr).ResolveType (ec);
+ expr_type = expr.Type;
if (!ec.DeclSpace.CheckAccessLevel (expr_type)){
Report.Error (122, loc, "'{0}' is inaccessible due to its protection level", expr_type);
return new_expr.ResolveAsTypeStep (ec);
}
- Type expr_type = ((TypeExpr) new_expr).ResolveType (ec);
- if (expr_type == null)
+ TypeExpr tnew_expr = new_expr.ResolveAsTypeTerminal (ec);
+ if (tnew_expr == null)
return null;
+ Type expr_type = tnew_expr.Type;
+
if (expr_type.IsPointer){
Error (23, "The `.' operator can not be applied to pointer operands (" +
TypeManager.CSharpName (expr_type) + ")");
if (texpr == null)
return null;
- Type t = texpr.ResolveType (ec);
- if (t == null)
+ texpr = texpr.ResolveAsTypeTerminal (ec);
+ if (texpr == null)
return null;
TypeArguments the_args = args;
}
if (the_args != null) {
- ConstructedType ctype = new ConstructedType (t, the_args, loc);
+ ConstructedType ctype = new ConstructedType (texpr.Type, the_args, loc);
return ctype.ResolveAsTypeStep (ec);
}
if (lexpr == null)
return null;
- Type ltype = lexpr.ResolveType (ec);
+ Type ltype = lexpr.Type;
if ((ltype == TypeManager.void_type) && (dim != "*")) {
Report.Error (1547, Location,
if (texpr == null)
return null;
- type = texpr.ResolveType (ec);
- if (type == null)
+ texpr = texpr.ResolveAsTypeTerminal (ec);
+ if (texpr == null)
return null;
+
+ type = texpr.Type;
}
if (!ec.InUnsafe && type.IsPointer){
if (texpr == null)
return null;
- otype = texpr.ResolveType (ec);
- if (otype == null)
- return null;
+ otype = texpr.Type;
if (!TypeManager.VerifyUnManaged (otype, loc))
return null;
ArrayList list = new ArrayList ();
foreach (TypeExpr iface_constraint in iface_constraints) {
- Type resolved = iface_constraint.ResolveType (ec);
- if (resolved == null)
- return false;
-
foreach (Type type in list) {
- if (!type.Equals (resolved))
+ if (!type.Equals (iface_constraint.Type))
continue;
Report.Error (405, loc,
"Duplicate constraint `{0}' for type " +
- "parameter `{1}'.", resolved, name);
+ "parameter `{1}'.", iface_constraint.Type,
+ name);
return false;
}
- list.Add (resolved);
+ list.Add (iface_constraint.Type);
}
foreach (TypeParameterExpr expr in type_param_constraints) {
- Type resolved = expr.ResolveType (ec);
- if (resolved == null)
- return false;
-
foreach (Type type in list) {
- if (!type.Equals (resolved))
+ if (!type.Equals (expr.Type))
continue;
Report.Error (405, loc,
"Duplicate constraint `{0}' for type " +
- "parameter `{1}'.", resolved, name);
+ "parameter `{1}'.", expr.Type, name);
return false;
}
- list.Add (resolved);
+ list.Add (expr.Type);
}
iface_constraint_types = new Type [list.Count];
list.CopyTo (iface_constraint_types, 0);
if (class_constraint != null) {
- class_constraint_type = class_constraint.ResolveType (ec);
+ class_constraint_type = class_constraint.Type;
if (class_constraint_type == null)
return false;
}
if (te is TypeParameterExpr)
has_type_args = true;
- atypes [i] = te.ResolveType (ec);
- if (atypes [i] == null) {
- Report.Error (246, Location, "Cannot find type `{0}'",
- te.Name);
- ok = false;
- }
+ atypes [i] = te.Type;
}
return ok;
}
new_args.Add (new TypeExpression (t, loc));
}
- ctype = new ConstructedType (ctype, new_args, loc).ResolveType (ec);
- if (ctype == null)
+ TypeExpr ct = new ConstructedType (ctype, new_args, loc);
+ if (ct.ResolveAsTypeTerminal (ec) == null)
return false;
+ ctype = ct.Type;
}
return Convert.ImplicitStandardConversionExists (ec, expr, ctype);
if (texpr == null)
return null;
- type = texpr.ResolveType (ec);
- if (type == null)
- return null;
-
+ type = texpr.Type;
if (type.IsGenericParameter || TypeManager.IsValueType (type))
temp_storage = new LocalTemporary (ec, type);
}
if (container.CurrentType != null)
- this_type = container.CurrentType.ResolveType (ec);
+ this_type = container.CurrentType.Type;
else
this_type = container.TypeBuilder;
if (tparam != null)
constraints = tparam.TypeParameter.Constraints;
- parameter_type = texpr.ResolveType (ec);
+ parameter_type = texpr.Type;
if (parameter_type.IsAbstract && parameter_type.IsSealed) {
Report.Error (721, l, "'{0}': static types cannot be used as parameters", GetSignatureForError ());
if (texpr == null)
return false;
- VariableType = texpr.ResolveType (ec);
- if (VariableType == null)
- return false;
+ VariableType = texpr.Type;
}
if (VariableType == TypeManager.void_type) {
if (texpr == null)
return false;
- expr_type = texpr.ResolveType (ec);
+ expr_type = texpr.Type;
CheckObsolete (expr_type);
if (te == null)
return false;
- type = te.ResolveType (ec);
+ type = te.Type;
CheckObsolete (type);
if (texpr == null)
return false;
- expr_type = texpr.ResolveType (ec);
+ expr_type = texpr.Type;
//
// The type must be an IDisposable or an implicit conversion
if (texpr == null)
return false;
- var_type = texpr.ResolveType (ec);
+ var_type = texpr.Type;
//
// We need an instance variable. Not sure this is the best
ArrayList new_ifaces = new ArrayList ();
foreach (TypeExpr iface in base_interfaces){
- Type itype = iface.ResolveType (ec);
- if (itype == null)
+ TypeExpr texpr = iface.ResolveAsTypeTerminal (ec);
+ if (texpr == null)
return null;
- if (!new_ifaces.Contains (itype))
- new_ifaces.Add (itype);
+ if (!new_ifaces.Contains (texpr.Type))
+ new_ifaces.Add (texpr.Type);
- Type [] implementing = itype.GetInterfaces ();
+ Type [] implementing = texpr.Type.GetInterfaces ();
foreach (Type imp in implementing){
if (!new_ifaces.Contains (imp))