diff options
Diffstat (limited to 'mcs/gmcs')
-rw-r--r-- | mcs/gmcs/ChangeLog | 68 | ||||
-rw-r--r-- | mcs/gmcs/cs-parser.jay | 4 | ||||
-rw-r--r-- | mcs/gmcs/ecore.cs | 25 | ||||
-rw-r--r-- | mcs/gmcs/expression.cs | 38 | ||||
-rw-r--r-- | mcs/gmcs/generic.cs | 87 | ||||
-rw-r--r-- | mcs/gmcs/typemanager.cs | 4 |
6 files changed, 116 insertions, 110 deletions
diff --git a/mcs/gmcs/ChangeLog b/mcs/gmcs/ChangeLog index 625bf8a1ecd..dbdb2d2c141 100644 --- a/mcs/gmcs/ChangeLog +++ b/mcs/gmcs/ChangeLog @@ -1,3 +1,12 @@ +2006-03-09 Martin Baulig <martin@ximian.com> + + * ecore.cs (FieldExpr.AddressOf): Don't emit the instance if the + `prepared' flag is set. + + * generic.cs (LiftedBinaryOperator): Don't allow `||' or `&&' anymore. + (LiftedBinaryOperator, LiftedUnaryMutator): Fix a few nullable + issues; see gtest-254.cs. + 2006-03-07 Martin Baulig <martin@ximian.com> * generic.cs (TypeManager.InferType): Allow infering @@ -15,21 +24,6 @@ (Invocation.IsAncestralType): Use TypeManager.IsSubclassOf(); fixes gtest-249.cs. -2006-03-01 Raja R Harinath <rharinath@novell.com> - - Fix #77679. - * expression.cs (ParameterReference.DoResolveBase): Change return - type to bool. - (ParameterReference.DoResolve, ParameterReference.DoResolveLValue): - Update. - - Fix #77628. - * ecore.cs (PropertyExpr.InstanceResolve): Fix CS1540 check. - - Fix #77642. - * typemanager.cs (GetFullNameSignature): Don't nullref on - protected accessors. - 2006-02-16 Martin Baulig <martin@ximian.com> * generic.cs @@ -61,37 +55,6 @@ (TypeManager.ExpandInterfaces): Use TypeManager.GetInterfaces() rather than calling it directly; fixes #77488. -2006-02-08 Martin Baulig <martin@ximian.com> - - * generic.cs (ConstraintChecker.CheckConstraints): Move the error - reporting into CheckConstraint() so we can use the correctly - instantiated type. - -2006-02-08 Martin Baulig <martin@ximian.com> - - * expression.cs (BaseAccess): Add support for generic methods. - - * ecore.cs (MethodGroupExpr.ResolveGeneric): Propagate `IsBase' to - the new MethodGroupExpr. - -2006-02-07 Martin Baulig <martin@ximian.com> - - * generic.cs (ConstraintChecker.CheckConstraints): Interfaces are - also reference types; fixes #77483. - -2006-02-07 Martin Baulig <martin@ximian.com> - - * generic.cs - (TypeManager.IsGenericMethod): We now return whether something is - an instantiated generic method (and not a generic method def). - (TypeManager.IsGenericMethodDefinition): New public method. - - * typemanager.cs - (TypeManager.CSharpSignature): Only include type arguments for - "real" generic methods, not for any instantiated method. - (TypeManager.GetMethodName): Likewise, but also allow generic - method definitions here. - 2006-02-06 Miguel de Icaza <miguel@novell.com> * codegen.cs (EmitScopeInitFromBlock): check here the @@ -116,6 +79,19 @@ * ecore.cs (PropertyExpr.FindAccessors): Just made flags const. +2006-02-07 Martin Baulig <martin@ximian.com> + + * generic.cs + (TypeManager.IsGenericMethod): We now return whether something is + an instantiated generic method (and not a generic method def). + (TypeManager.IsGenericMethodDefinition): New public method. + + * typemanager.cs + (TypeManager.CSharpSignature): Only include type arguments for + "real" generic methods, not for any instantiated method. + (TypeManager.GetMethodName): Likewise, but also allow generic + method definitions here. + 2006-02-06 Martin Baulig <martin@ximian.com> * class.cs (TypeContainer.DefineType): If we're a struct, pass diff --git a/mcs/gmcs/cs-parser.jay b/mcs/gmcs/cs-parser.jay index 1e5297fda46..05c5aa97654 100644 --- a/mcs/gmcs/cs-parser.jay +++ b/mcs/gmcs/cs-parser.jay @@ -3164,10 +3164,10 @@ this_access ; base_access - : BASE DOT IDENTIFIER opt_type_argument_list + : BASE DOT IDENTIFIER { LocatedToken lt = (LocatedToken) $3; - $$ = new BaseAccess (lt.Value, (TypeArguments) $4, lt.Location); + $$ = new BaseAccess (lt.Value, lt.Location); } | BASE OPEN_BRACKET expression_list CLOSE_BRACKET { diff --git a/mcs/gmcs/ecore.cs b/mcs/gmcs/ecore.cs index 57b7b66a2aa..7ac0acb4cec 100644 --- a/mcs/gmcs/ecore.cs +++ b/mcs/gmcs/ecore.cs @@ -2913,7 +2913,6 @@ namespace Mono.CSharp { MethodGroupExpr new_mg = new MethodGroupExpr (list, Location); new_mg.InstanceExpression = InstanceExpression; new_mg.HasTypeArguments = true; - new_mg.IsBase = IsBase; return new_mg; } @@ -3382,7 +3381,8 @@ namespace Mono.CSharp { if (FieldInfo.IsStatic){ ig.Emit (OpCodes.Ldsflda, FieldInfo); } else { - EmitInstance (ec, false); + if (!prepared) + EmitInstance (ec, false); ig.Emit (OpCodes.Ldflda, FieldInfo); } } @@ -3552,11 +3552,11 @@ namespace Mono.CSharp { InstanceExpression.CheckMarshallByRefAccess (ec.ContainerType); if (must_do_cs1540_check && InstanceExpression != EmptyExpression.Null && - InstanceExpression.Type != ec.ContainerType && - ec.ContainerType.IsSubclassOf (PropertyInfo.DeclaringType) && - !InstanceExpression.Type.IsSubclassOf (ec.ContainerType)) { - Error_CannotAccessProtected (loc, PropertyInfo, InstanceExpression.Type, ec.ContainerType); - return false; + InstanceExpression.Type != ec.ContainerType && + ec.ContainerType.IsSubclassOf (PropertyInfo.DeclaringType) && + InstanceExpression.Type.IsSubclassOf (PropertyInfo.DeclaringType)) { + Error_CannotAccessProtected (loc, PropertyInfo, InstanceExpression.Type, ec.ContainerType); + return false; } return true; @@ -3883,11 +3883,12 @@ namespace Mono.CSharp { // This is using the same mechanism as the CS1540 check in PropertyExpr. // However, in the Event case, we reported a CS0122 instead. // - if (must_do_cs1540_check && InstanceExpression != EmptyExpression.Null && - InstanceExpression.Type != ec.ContainerType && - ec.ContainerType.IsSubclassOf (InstanceExpression.Type)) { - ErrorIsInaccesible (loc, TypeManager.CSharpSignature (EventInfo)); - return false; + if (must_do_cs1540_check && InstanceExpression != EmptyExpression.Null) { + if ((InstanceExpression.Type != ec.ContainerType) && + ec.ContainerType.IsSubclassOf (InstanceExpression.Type)) { + ErrorIsInaccesible (loc, TypeManager.CSharpSignature (EventInfo)); + return false; + } } return true; diff --git a/mcs/gmcs/expression.cs b/mcs/gmcs/expression.cs index 0999bd00ca9..bb25e9cf564 100644 --- a/mcs/gmcs/expression.cs +++ b/mcs/gmcs/expression.cs @@ -3748,7 +3748,7 @@ namespace Mono.CSharp { ec.CurrentBranching.SetFieldAssigned (vi, field_name); } - protected bool DoResolveBase (EmitContext ec) + protected void DoResolveBase (EmitContext ec) { if (!par.Resolve (ec)) { //TODO: @@ -3767,7 +3767,7 @@ namespace Mono.CSharp { if (is_ref && !block.Toplevel.IsLocalParameter (name)){ Report.Error (1628, Location, "Cannot use ref or out parameter `{0}' inside an anonymous method block", par.Name); - return false; + return; } // @@ -3779,8 +3779,6 @@ namespace Mono.CSharp { ec.CaptureParameter (name, type, idx); } } - - return true; } public override int GetHashCode() @@ -3811,8 +3809,7 @@ namespace Mono.CSharp { // public override Expression DoResolve (EmitContext ec) { - if (!DoResolveBase (ec)) - return null; + DoResolveBase (ec); if (is_out && ec.DoFlowAnalysis && (!ec.OmitStructFlowAnalysis || !vi.TypeInfo.IsStruct) && !IsAssigned (ec, loc)) return null; @@ -3822,8 +3819,7 @@ namespace Mono.CSharp { override public Expression DoResolveLValue (EmitContext ec, Expression right_side) { - if (!DoResolveBase (ec)) - return null; + DoResolveBase (ec); SetAssigned (ec); @@ -8501,13 +8497,11 @@ namespace Mono.CSharp { /// The base operator for method names /// </summary> public class BaseAccess : Expression { - public readonly string Identifier; - TypeArguments args; + string member; - public BaseAccess (string member, TypeArguments args, Location l) + public BaseAccess (string member, Location l) { - this.Identifier = member; - this.args = args; + this.member = member; loc = l; } @@ -8559,10 +8553,10 @@ namespace Mono.CSharp { } member_lookup = MemberLookup (ec, ec.ContainerType, null, base_type, - Identifier, AllMemberTypes, AllBindingFlags, + member, AllMemberTypes, AllBindingFlags, loc); if (member_lookup == null) { - MemberLookupFailed (ec, base_type, base_type, Identifier, null, true, loc); + MemberLookupFailed (ec, base_type, base_type, member, null, true, loc); return null; } @@ -8583,18 +8577,8 @@ namespace Mono.CSharp { pe.IsBase = true; } - MethodGroupExpr mg = e as MethodGroupExpr; - if (mg != null) - mg.IsBase = true; - - if (args != null) { - if (mg != null) - return mg.ResolveGeneric (ec, args); - - Report.Error (307, loc, "`{0}' cannot be used with type arguments", - Identifier); - return null; - } + if (e is MethodGroupExpr) + ((MethodGroupExpr) e).IsBase = true; return e; } diff --git a/mcs/gmcs/generic.cs b/mcs/gmcs/generic.cs index d52299761d6..8d0c4b03d8b 100644 --- a/mcs/gmcs/generic.cs +++ b/mcs/gmcs/generic.cs @@ -1495,7 +1495,7 @@ namespace Mono.CSharp { is_class = is_struct = false; } } else { - is_class = atype.IsClass || atype.IsInterface; + is_class = atype.IsClass; is_struct = atype.IsValueType && !TypeManager.IsNullableType (atype); } @@ -1526,16 +1526,26 @@ namespace Mono.CSharp { // The class constraint comes next. // if (gc.HasClassConstraint) { - if (!CheckConstraint (ec, ptype, aexpr, gc.ClassConstraint)) + if (!CheckConstraint (ec, ptype, aexpr, gc.ClassConstraint)) { + Error_TypeMustBeConvertible (atype, gc.ClassConstraint, ptype); return false; + } } // // Now, check the interface constraints. // foreach (Type it in gc.InterfaceConstraints) { - if (!CheckConstraint (ec, ptype, aexpr, it)) + Type itype; + if (it.IsGenericParameter) + itype = atypes [it.GenericParameterPosition]; + else + itype = it; + + if (!CheckConstraint (ec, ptype, aexpr, itype)) { + Error_TypeMustBeConvertible (atype, itype, ptype); return false; + } } // @@ -1590,11 +1600,7 @@ namespace Mono.CSharp { ctype = atypes [pos]; } - if (Convert.ImplicitStandardConversionExists (ec, expr, ctype)) - return true; - - Error_TypeMustBeConvertible (expr.Type, ctype, ptype); - return false; + return Convert.ImplicitStandardConversionExists (ec, expr, ctype); } bool HasDefaultConstructor (EmitContext ec, Type atype) @@ -2685,8 +2691,7 @@ namespace Mono.CSharp { if (expr == null) return null; - if (!(expr is IMemoryLocation)) - temp = new LocalTemporary (ec, expr.Type); + temp = new LocalTemporary (ec, expr.Type); info = new NullableInfo (expr.Type); type = info.UnderlyingType; @@ -2706,6 +2711,11 @@ namespace Mono.CSharp { ec.ig.EmitCall (OpCodes.Call, info.HasValue, null); } + public void Store (EmitContext ec) + { + create_temp (ec); + } + void create_temp (EmitContext ec) { if ((temp != null) && !has_temp) { @@ -2740,14 +2750,35 @@ namespace Mono.CSharp { public void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool prepare_for_load) { - source.Emit (ec); - ec.ig.Emit (OpCodes.Newobj, info.Constructor); + InternalWrap wrap = new InternalWrap (source, info, loc); + ((IAssignMethod) expr).EmitAssign (ec, wrap, leave_copy, false); + } + + protected class InternalWrap : Expression + { + public Expression expr; + public NullableInfo info; + + public InternalWrap (Expression expr, NullableInfo info, Location loc) + { + this.expr = expr; + this.info = info; + this.loc = loc; - if (leave_copy) - ec.ig.Emit (OpCodes.Dup); + type = info.Type; + eclass = ExprClass.Value; + } - Expression empty = new EmptyExpression (expr.Type); - ((IAssignMethod) expr).EmitAssign (ec, empty, false, prepare_for_load); + public override Expression DoResolve (EmitContext ec) + { + return this; + } + + public override void Emit (EmitContext ec) + { + expr.Emit (ec); + ec.ig.Emit (OpCodes.Newobj, info.Constructor); + } } } @@ -2951,7 +2982,8 @@ namespace Mono.CSharp { { public readonly Binary.Operator Oper; - Expression left, right, underlying, null_value, bool_wrap; + Expression left, right, original_left, original_right; + Expression underlying, null_value, bool_wrap; Unwrap left_unwrap, right_unwrap; bool is_equality, is_comparision, is_boolean; @@ -2959,8 +2991,8 @@ namespace Mono.CSharp { Location loc) { this.Oper = op; - this.left = left; - this.right = right; + this.left = original_left = left; + this.right = original_right = right; this.loc = loc; } @@ -2980,8 +3012,16 @@ namespace Mono.CSharp { return null; } - if (((Oper == Binary.Operator.BitwiseAnd) || (Oper == Binary.Operator.BitwiseOr) || - (Oper == Binary.Operator.LogicalAnd) || (Oper == Binary.Operator.LogicalOr)) && + if ((Oper == Binary.Operator.LogicalAnd) || + (Oper == Binary.Operator.LogicalOr)) { + Binary.Error_OperatorCannotBeApplied ( + loc, Binary.OperName (Oper), + original_left.GetSignatureForError (), + original_right.GetSignatureForError ()); + return null; + } + + if (((Oper == Binary.Operator.BitwiseAnd) || (Oper == Binary.Operator.BitwiseOr)) && ((left.Type == TypeManager.bool_type) && (right.Type == TypeManager.bool_type))) { Expression empty = new EmptyExpression (TypeManager.bool_type); bool_wrap = new Wrap (empty, loc).Resolve (ec); @@ -3214,6 +3254,11 @@ namespace Mono.CSharp { public override void Emit (EmitContext ec) { + if (left_unwrap != null) + left_unwrap.Store (ec); + if (right_unwrap != null) + right_unwrap.Store (ec); + if (is_boolean) { EmitBoolean (ec); return; diff --git a/mcs/gmcs/typemanager.cs b/mcs/gmcs/typemanager.cs index 4784538348a..f300641d9e4 100644 --- a/mcs/gmcs/typemanager.cs +++ b/mcs/gmcs/typemanager.cs @@ -640,9 +640,9 @@ public partial class TypeManager { { PropertyInfo pi = mi as PropertyInfo; if (pi != null) { - MethodBase pmi = pi.GetGetMethod (true); + MethodBase pmi = pi.GetGetMethod (); if (pmi == null) - pmi = pi.GetSetMethod (true); + pmi = pi.GetSetMethod (); if (GetParameterData (pmi).Count > 0) mi = pmi; } |