Esempio n. 1
0
        protected override void EmitRead(CompilerContext ctx, Local valueFrom)
        {
            bool flag;

            SanityCheck(ctx.Model, this.property, base.Tail, out flag, ctx.NonPublic, ctx.AllowInternal(this.property));
            if (this.ExpectedType.IsValueType && (valueFrom == null))
            {
                throw new InvalidOperationException("Attempt to mutate struct on the head of the stack; changes would be lost");
            }
            ctx.LoadAddress(valueFrom, this.ExpectedType);
            if (flag && base.Tail.RequiresOldValue)
            {
                ctx.CopyValue();
            }
            if (base.Tail.RequiresOldValue)
            {
                ctx.LoadValue(this.property);
            }
            Type propertyType = this.property.PropertyType;

            ctx.ReadNullCheckedTail(propertyType, base.Tail, null);
            if (flag)
            {
                CodeLabel label  = new CodeLabel();
                CodeLabel label2 = new CodeLabel();
                if (!propertyType.IsValueType)
                {
                    ctx.CopyValue();
                    label  = ctx.DefineLabel();
                    label2 = ctx.DefineLabel();
                    ctx.BranchIfFalse(label, true);
                }
                if (this.shadowSetter == null)
                {
                    ctx.StoreValue(this.property);
                }
                else
                {
                    ctx.EmitCall(this.shadowSetter);
                }
                if (!propertyType.IsValueType)
                {
                    ctx.Branch(label2, true);
                    ctx.MarkLabel(label);
                    ctx.DiscardValue();
                    ctx.DiscardValue();
                    ctx.MarkLabel(label2);
                }
            }
            else if (base.Tail.ReturnsValue)
            {
                ctx.DiscardValue();
            }
        }
Esempio n. 2
0
        protected override void EmitRead(CompilerContext ctx, Local valueFrom)
        {
            bool flag;

            PropertyDecorator.SanityCheck(ctx.Model, this.property, this.Tail, out flag, ctx.NonPublic, ctx.AllowInternal(this.property));
            if (this.ExpectedType.IsValueType && valueFrom == null)
            {
                throw new InvalidOperationException("Attempt to mutate struct on the head of the stack; changes would be lost");
            }
            using (Local localWithValue = ctx.GetLocalWithValue(this.ExpectedType, valueFrom))
            {
                if (this.Tail.RequiresOldValue)
                {
                    ctx.LoadAddress(localWithValue, this.ExpectedType);
                    ctx.LoadValue(this.property);
                }
                Type propertyType = this.property.PropertyType;
                ctx.ReadNullCheckedTail(propertyType, this.Tail, null);
                if (flag)
                {
                    using (Local local = new Local(ctx, this.property.PropertyType))
                    {
                        ctx.StoreValue(local);
                        CodeLabel codeLabel = new CodeLabel();
                        if (!propertyType.IsValueType)
                        {
                            codeLabel = ctx.DefineLabel();
                            ctx.LoadValue(local);
                            ctx.BranchIfFalse(codeLabel, true);
                        }
                        ctx.LoadAddress(localWithValue, this.ExpectedType);
                        ctx.LoadValue(local);
                        if (this.shadowSetter != null)
                        {
                            ctx.EmitCall(this.shadowSetter);
                        }
                        else
                        {
                            ctx.StoreValue(this.property);
                        }
                        if (!propertyType.IsValueType)
                        {
                            ctx.MarkLabel(codeLabel);
                        }
                    }
                }
                else if (this.Tail.ReturnsValue)
                {
                    ctx.DiscardValue();
                }
            }
        }