protected override void EmitWrite(AqlaSerializer.Compiler.CompilerContext ctx, AqlaSerializer.Compiler.Local valueFrom)
        {
            var g = ctx.G;

            using (ctx.StartDebugBlockAuto(this))
                using (Compiler.Local value = ctx.GetLocalWithValue(_arrayType, valueFrom))
                {
                    _listHelpers.EmitWrite(ctx.G, value,
                                           () =>
                    {
                        var arr = value;
                        for (int i = 0; i < _rank; i++)
                        {
                            g.Writer.WriteFieldHeader(ListHelpers.FieldLength, WireType.Variant);
                            g.Writer.WriteInt32(arr.AsOperand.Invoke("GetLength", i));
                        }
                    }, null);
                }
        }
Exemplo n.º 2
0
        protected override void EmitWrite(AqlaSerializer.Compiler.CompilerContext ctx, AqlaSerializer.Compiler.Local valueFrom)
        {
            var g = ctx.G;

            using (ctx.StartDebugBlockAuto(this))
                using (Compiler.Local value = ctx.GetLocalWithValue(_arrayType, valueFrom))
                {
                    _listHelpers.EmitWrite(ctx.G, value,
                                           () =>
                    {
                        var length = value.AsOperand.Property("Length");
                        g.If(length > 0);
                        {
                            g.Writer.WriteFieldHeader(ListHelpers.FieldLength, WireType.Variant);
                            g.Writer.WriteInt32(length);
                        }
                        g.End();
                    }, null);
                }
        }
Exemplo n.º 3
0
        protected override void EmitWrite(AqlaSerializer.Compiler.CompilerContext ctx, AqlaSerializer.Compiler.Local valueFrom)
        {
            var g = ctx.G;

            using (ctx.StartDebugBlockAuto(this))
                using (Compiler.Local value = ctx.GetLocalWithValue(ExpectedType, valueFrom))
                    using (Compiler.Local t = ctx.Local(typeof(System.Type)))
                        using (Compiler.Local length = ctx.Local(typeof(int)))
                            using (var icol = !_protoCompatibility ? ctx.Local(typeof(ICollection)) : null)
                            {
                                ListHelpers.EmitWrite(
                                    ctx.G,
                                    value,
                                    () =>
                                {
                                    g.Assign(icol, value.AsOperand.As(icol.Type));
                                    g.Assign(length, (icol.AsOperand != null).Conditional(icol.AsOperand.Property("Count"), -1));
                                    g.If(length.AsOperand > 0);
                                    {
                                        g.Writer.WriteFieldHeader(ListHelpers.FieldLength, WireType.Variant);
                                        g.Writer.WriteInt32(length);
                                    }
                                    g.End();

                                    if (_writeSubType)
                                    {
                                        g.Assign(t, value.AsOperand.InvokeGetType());
                                        g.If(_concreteTypeDefault != t.AsOperand);
                                        {
                                            g.Writer.WriteFieldHeaderBegin(ListHelpers.FieldSubtype);
                                            _subTypeHelpers.EmitWrite(g, _metaType, value);
                                        }
                                        g.End();
                                    }
                                },
                                    null);
                            }
        }