From 96a47bc739a34b8aa01addc623680e09e3ac7149 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 9 Mar 2006 09:54:16 +0000 Subject: 2006-03-09 Martin Baulig * 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. svn path=/trunk/mcs/; revision=57715 --- mcs/gmcs/ChangeLog | 9 ++++++++ mcs/gmcs/ecore.cs | 3 ++- mcs/gmcs/generic.cs | 65 ++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 63 insertions(+), 14 deletions(-) (limited to 'mcs/gmcs') diff --git a/mcs/gmcs/ChangeLog b/mcs/gmcs/ChangeLog index 625bf8a1ecd..9c401112e06 100644 --- a/mcs/gmcs/ChangeLog +++ b/mcs/gmcs/ChangeLog @@ -1,3 +1,12 @@ +2006-03-09 Martin Baulig + + * 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 * generic.cs (TypeManager.InferType): Allow infering diff --git a/mcs/gmcs/ecore.cs b/mcs/gmcs/ecore.cs index 57b7b66a2aa..7413bd3e3f6 100644 --- a/mcs/gmcs/ecore.cs +++ b/mcs/gmcs/ecore.cs @@ -3382,7 +3382,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); } } diff --git a/mcs/gmcs/generic.cs b/mcs/gmcs/generic.cs index d52299761d6..72a6be3b574 100644 --- a/mcs/gmcs/generic.cs +++ b/mcs/gmcs/generic.cs @@ -2685,8 +2685,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 +2705,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 +2744,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); + } - if (leave_copy) - ec.ig.Emit (OpCodes.Dup); + 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; - Expression empty = new EmptyExpression (expr.Type); - ((IAssignMethod) expr).EmitAssign (ec, empty, false, prepare_for_load); + type = info.Type; + eclass = ExprClass.Value; + } + + 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 +2976,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 +2985,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 +3006,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 +3248,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; -- cgit v1.2.3