gcs0305-2.cs
gcs0305.cs
gcs0308.cs
-cs1547-3.cs
cs0553-2.cs
cs1669-2.cs NO ERROR
cs1677.cs
+2006-03-03 Marek Safar <marek.safar@seznam.cz>
+
+ * attribute.cs (ResolveAsTypeTerminal): Removed.
+
+ * ecore.cs (Expression.ResolveAsTypeTerminal): Make virtual to allow
+ specialization for predefined types; 30% speed up.
+ Finally placed obsolete check to right place.
+ (Expression.ResolveType): Removed.
+
+ * enum.cs, expression.cs, parameter.cs, statement.cs, typemanager.cs:
+ Updated after ResolveType was removed.
+
+ * expression.cs (Cast.ctor): Check void cast.
+ (Binary.ResolveAsTypeTerminal): Is never type.
+ (Conditional.ResolveAsTypeTerminal): Is never type.
+
+ * rootcontext.cs (ResolveCore): Set base type to simplify some code later.
+
2006-03-26 Marek Safar <marek.safar@seznam.cz>
* rootcontext.cs (ResolveCore): Removed System.INullableValue.
Error_AttributeEmitError ("it is attached to invalid parent");
}
- protected virtual FullNamedExpression ResolveAsTypeTerminal (Expression expr, EmitContext ec, bool silent)
+ protected virtual TypeExpr ResolveAsTypeTerminal (Expression expr, IResolveContext ec, bool silent)
{
return expr.ResolveAsTypeTerminal (ec, silent);
}
- protected virtual FullNamedExpression ResolveAsTypeStep (Expression expr, EmitContext ec, bool silent)
- {
- return expr.ResolveAsTypeStep (ec, silent);
- }
-
Type ResolvePossibleAttributeType (string name, bool silent, ref bool is_attr)
{
- // It will disapear when IResolveContext will take a place
- DeclSpace container = owner.ResolveContext.DeclContainer;
- if (owner is TypeParameter)
- container = ((TypeParameter)owner).DeclSpace;
- EmitContext ec = new EmitContext (owner.ResolveContext, container, container,
- Location, null, null, container.ModFlags, false);
- //
+ IResolveContext rc = owner.ResolveContext;
- FullNamedExpression fn;
+ TypeExpr te;
if (LeftExpr == null) {
- fn = ResolveAsTypeTerminal (new SimpleName (name, Location), ec, silent);
+ te = ResolveAsTypeTerminal (new SimpleName (name, Location), rc, silent);
} else {
- fn = ResolveAsTypeStep (LeftExpr, ec, silent);
- if (fn == null)
- return null;
- fn = new MemberAccess (fn, name, Location).ResolveAsTypeTerminal (ec, silent);
+ te = ResolveAsTypeTerminal (new MemberAccess (LeftExpr, name, Location), rc, silent);
}
- TypeExpr te = fn as TypeExpr;
if (te == null)
return null;
RootContext.Tree.Types.NamespaceEntry = null;
}
- protected override FullNamedExpression ResolveAsTypeStep (Expression expr, EmitContext ec, bool silent)
- {
- try {
- Enter ();
- return base.ResolveAsTypeStep (expr, ec, silent);
- }
- finally {
- Leave ();
- }
- }
-
-
- protected override FullNamedExpression ResolveAsTypeTerminal (Expression expr, EmitContext ec, bool silent)
+ protected override TypeExpr ResolveAsTypeTerminal (Expression expr, IResolveContext ec, bool silent)
{
try {
Enter ();
int start = 0, i, j;
if (Kind == Kind.Class){
- TypeExpr name = ResolveBaseTypeExpr ((Expression) Bases [0]);
+ TypeExpr name = ((Expression) Bases [0]).ResolveAsBaseTerminal (this, false);
if (name == null){
return null;
TypeExpr [] ifaces = new TypeExpr [count-start];
for (i = start, j = 0; i < count; i++, j++){
- TypeExpr resolved = ResolveBaseTypeExpr ((Expression) Bases [i]);
+ TypeExpr resolved = ((Expression) Bases [i]).ResolveAsTypeTerminal (this, false);
if (resolved == null) {
return null;
}
RootContext.RegisterOrder (this);
if (base_type != null) {
- base_type = base_type.ResolveAsTypeTerminal (this, false);
- if (base_type == null)
- return false;
-
if (IsGeneric && TypeManager.IsAttributeType (base_type.Type)) {
Report.Error (698, base_type.Location,
"A generic type cannot derive from `{0}' " +
}
TypeBuilder.SetParent (base_type.Type);
- CheckObsoleteType (base_type);
+
+ ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (base_type.Type);
+ if (obsolete_attr != null && !IsInObsoleteScope) {
+ AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), Location);
+ }
}
if (!CheckRecursiveDefinition (this)) {
// add interfaces that were not added at type creation
if (iface_exprs != null) {
- ifaces = TypeManager.ExpandInterfaces (this, iface_exprs);
+ ifaces = TypeManager.ExpandInterfaces (iface_exprs);
if (ifaces == null) {
return false;
}
public bool ResolveType ()
{
if ((base_type != null) &&
- (base_type.ResolveType (this) == null)) {
+ (base_type.ResolveAsTypeTerminal (this, false) == null)) {
error = true;
return false;
}
return false;
}
- CurrentType = current_type.ResolveType (this);
+ CurrentType = current_type.Type;
}
return true;
if (iface_texpr == null)
return false;
- InterfaceType = iface_texpr.ResolveType (this);
+ InterfaceType = iface_texpr.Type;
if (!InterfaceType.IsInterface) {
Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
if (MemberType == null)
return false;
- CheckObsoleteType (Type);
-
if ((Parent.ModFlags & Modifiers.SEALED) != 0 &&
(ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0) {
Report.Error (549, Location, "New virtual member `{0}' is declared in a sealed class `{1}'",
if (texpr == null)
return false;
- InterfaceType = texpr.ResolveType (this);
+ InterfaceType = texpr.Type;
if (!InterfaceType.IsInterface) {
Report.Error (538, Location, "`{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
if (MemberType == null || Type == null)
return false;
- CheckObsoleteType (Type);
-
if (MemberType == TypeManager.void_type) {
Report.Error (1547, Location, "Keyword 'void' cannot be used in this context");
return false;
AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc);
}
- protected void CheckObsoleteType (Expression type)
- {
- ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type.Type);
- if (obsolete_attr == null)
- return;
-
- if (IsInObsoleteScope)
- return;
-
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (type.Type), type.Location);
- }
-
/// <summary>
/// Analyze whether CLS-Compliant verification must be execute for this MemberCore.
/// </summary>
// Parent.GetSignatureForError
return Name;
}
-
- // <summary>
- // Resolves the expression `e' for a type, and will recursively define
- // types. This should only be used for resolving base types.
- // </summary>
- protected TypeExpr ResolveBaseTypeExpr (Expression e)
- {
- return e.ResolveAsTypeTerminal (this, false);
- }
public bool CheckAccessLevel (Type check_type)
{
if (TypeManager.multicast_delegate_type == null && !RootContext.StdLib) {
Namespace system = RootNamespace.Global.GetNamespace ("System", true);
TypeExpr expr = system.Lookup (this, "MulticastDelegate", Location) as TypeExpr;
- TypeManager.multicast_delegate_type = expr.ResolveType (this);
+ TypeManager.multicast_delegate_type = expr.Type;
}
if (TypeManager.multicast_delegate_type == null)
if (ret_type == null)
return false;
- CheckObsoleteType (ReturnType);
-
if (!Parent.AsAccessible (ret_type, ModFlags)) {
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
// reference
//
public virtual TypeExpr ResolveAsTypeTerminal (IResolveContext ec, bool silent)
+ {
+ TypeExpr te = ResolveAsBaseTerminal (ec, silent);
+ if (te == null)
+ return null;
+
+ ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (te.Type);
+ if (obsolete_attr != null && !ec.IsInObsoleteScope) {
+ AttributeTester.Report_ObsoleteMessage (obsolete_attr, GetSignatureForError (), Location);
+ }
+ return te;
+ }
+
+ public TypeExpr ResolveAsBaseTerminal (IResolveContext ec, bool silent)
{
int errors = Report.Errors;
protected abstract TypeExpr DoResolveAsTypeStep (IResolveContext ec);
- public Type ResolveType (IResolveContext ec)
- {
- TypeExpr t = ResolveAsTypeTerminal (ec, false);
- if (t == null)
- return null;
-
- ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (t.Type);
- if (obsolete_attr != null && !ec.IsInObsoleteScope) {
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, Name, Location);
- }
-
- return t.Type;
- }
-
public abstract string Name {
get;
}
return this;
}
+ public override TypeExpr ResolveAsTypeTerminal (IResolveContext ec, bool silent)
+ {
+ return this;
+ }
+
public override string Name {
get { return Type.ToString (); }
}
/// by the parser to setup the core types. A TypeLookupExpression is always
/// classified as a type.
/// </summary>
- public class TypeLookupExpression : TypeExpr {
- string name;
+ public sealed class TypeLookupExpression : TypeExpr {
+ readonly string name;
public TypeLookupExpression (string name)
{
this.name = name;
+ eclass = ExprClass.Type;
+ }
+
+ public override TypeExpr ResolveAsTypeTerminal (IResolveContext ec, bool silent)
+ {
+ // It's null for corlib compilation only
+ if (type == null)
+ return DoResolveAsTypeStep (ec);
+
+ return this;
}
static readonly char [] dot_array = { '.' };
protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
{
- if (type != null)
- return this;
-
// If name is of the form `N.I', first lookup `N', then search a member `I' in it.
string rest = null;
string lookup_name = name;
return null;
}
- type = ((TypeExpr) resolved).ResolveType (ec);
+ type = resolved.Type;
return this;
}
if (texpr == null)
return null;
- Type type = texpr.ResolveType (ec);
+ Type type = texpr.Type;
int num_args = TypeManager.GetNumberOfTypeArguments (type);
if (args != null) {
return null;
}
- return new TypeExpression (type, loc);
+ return texpr;
}
public override bool CheckAccessLevel (DeclSpace ds)
return null;
}
- TypeExpr ute = ResolveBaseTypeExpr (BaseType);
+ TypeExpr ute = BaseType.ResolveAsTypeTerminal (this, false);
UnderlyingType = ute.Type;
if (UnderlyingType != TypeManager.int32_type &&
probe_type_expr = ProbeType.ResolveAsTypeTerminal (ec, false);
if (probe_type_expr == null)
return null;
- if (probe_type_expr.ResolveType (ec) == null)
- return null;
expr = expr.Resolve (ec);
if (expr == null)
this.target_type = cast_type;
this.expr = expr;
this.loc = loc;
+
+ if (target_type == TypeManager.system_void_expr) {
+ Report.Error (1547, loc, "Keyword `void' cannot be used in this context");
+ }
}
public Expression TargetType {
if (target == null)
return null;
- type = target.ResolveType (ec);
+ type = target.Type;
if (type.IsAbstract && type.IsSealed) {
Report.Error (716, loc, "Cannot convert to static type `{0}'", TypeManager.CSharpName (type));
return ResolveOperator (ec);
}
+ public override TypeExpr ResolveAsTypeTerminal (IResolveContext ec, bool silent)
+ {
+ return null;
+ }
+
private void CheckUselessComparison (Constant c, Type type)
{
if (c == null || !IsTypeIntegral (type)
return this;
}
+ public override TypeExpr ResolveAsTypeTerminal (IResolveContext ec, bool silent)
+ {
+ return null;
+ }
+
public override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
if (texpr == null)
return null;
- type = texpr.ResolveType (ec);
+ type = texpr.Type;
if (Arguments == null) {
Expression c = Constantify (type);
if (array_type_expr == null)
return false;
- type = array_type_expr.ResolveType (ec);
+ type = array_type_expr.Type;
underlying_type = TypeManager.GetElementType (type);
dimensions = type.GetArrayRank ();
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#. Use typeof (void) to get the void type object");
return null;
}
- type_queried = texpr.ResolveType (ec);
+ type_queried = texpr.Type;
int size_of = GetTypeSize (type_queried);
if (size_of > 0) {
if (tnew_expr == null)
return null;
- Type expr_type = tnew_expr.ResolveType (rc);
+ Type expr_type = tnew_expr.Type;
if (expr_type.IsPointer){
Error (23, "The `.' operator can not be applied to pointer operands (" +
if (lexpr == null)
return null;
- Type ltype = lexpr.ResolveType (ec);
+ Type ltype = lexpr.Type;
if ((ltype == TypeManager.void_type) && (dim != "*")) {
Report.Error (1547, Location,
"Keyword 'void' cannot be used in this context");
if (texpr == null)
return null;
- otype = texpr.ResolveType (ec);
+ otype = texpr.Type;
if (!TypeManager.VerifyUnManaged (otype, loc))
return null;
return false;
}
- foreach (TypeExpr iface_constraint in iface_constraints) {
- if (iface_constraint.ResolveType (ec) == null)
+ for (int i = 0; i < iface_constraints.Count; ++i) {
+ TypeExpr iface_constraint = (TypeExpr) iface_constraints [i];
+ iface_constraint = iface_constraint.ResolveAsTypeTerminal (ec, false);
+ if (iface_constraint == null)
return false;
+ iface_constraints [i] = iface_constraint;
}
if (class_constraint != null) {
- if (class_constraint.ResolveType (ec) == null)
+ class_constraint = class_constraint.ResolveAsTypeTerminal (ec, false);
+ if (class_constraint == null)
return false;
}
}
}
+ // FIXME: This should be removed once we fix the handling of RootContext.Tree.Types
+ public override DeclSpace DeclContainer {
+ get { return DeclSpace; }
+ }
+
/// <summary>
/// This is the first method which is called during the resolving
/// process; we're called immediately after creating the type parameters
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, Location, "`{0}': static types cannot be used as parameters", GetSignatureForError ());
TypeContainer root = Tree.Types;
TypeManager.object_type = BootstrapCorlib_ResolveClass (root, "System.Object");
+ TypeManager.system_object_expr.Type = TypeManager.object_type;
TypeManager.value_type = BootstrapCorlib_ResolveClass (root, "System.ValueType");
+ TypeManager.system_valuetype_expr.Type = TypeManager.value_type;
TypeManager.attribute_type = BootstrapCorlib_ResolveClass (root, "System.Attribute");
TypeManager.indexer_name_type = BootstrapCorlib_ResolveClass (root, "System.Runtime.CompilerServices.IndexerNameAttribute");
if (texpr == null)
return false;
- VariableType = texpr.ResolveType (ec);
+ VariableType = texpr.Type;
}
if (VariableType == TypeManager.void_type) {
if (texpr == null)
return false;
- expr_type = texpr.ResolveType (ec);
+ expr_type = texpr.Type;
data = new Emitter [declarators.Count];
if (te == null)
return false;
- type = te.ResolveType (ec);
+ type = te.Type;
if (type != TypeManager.exception_type && !type.IsSubclassOf (TypeManager.exception_type)){
Error (155, "The type caught or thrown must be derived from System.Exception");
if (texpr == null)
return false;
- expr_type = texpr.ResolveType (ec);
+ expr_type = texpr.Type;
//
// The type must be an IDisposable or an implicit conversion
/// This expands in context like: IA; IB : IA; IC : IA, IB; the interface "IC" to
/// be IA, IB, IC.
/// </remarks>
- public static Type[] ExpandInterfaces (IResolveContext ec, TypeExpr [] base_interfaces)
+ public static Type[] ExpandInterfaces (TypeExpr [] base_interfaces)
{
ArrayList new_ifaces = new ArrayList ();
foreach (TypeExpr iface in base_interfaces){
- TypeExpr texpr = iface.ResolveAsTypeTerminal (ec, false);
- if (texpr == null)
- return null;
-
- Type itype = texpr.ResolveType (ec);
+ Type itype = iface.Type;
if (new_ifaces.Contains (itype))
continue;