public void EmitRead(JITContext context)
        {
            LocalBuilder top = context.PeekTypeDef();

            if (top != null)
            {
                context.ReadFieldBlob();
                context.PushType(typeof(BlobReader));
            }

            context.CreateType(targetType);
            context.PushType(targetType);
            context.PushTypeDef(context.PeekTop(targetType));

            Label readField = context.CreateLabel();
            Label cleanup   = context.CreateLabel();

            context.MarkLabel(readField);
            context.CanReadBytes(BlobReader.FieldHeaderLength);
            context.GotoWhenFalse(cleanup);

            context.ReadFieldHeader();

            for (int i = 0; i < fields.Length; i++)
            {
                Label nextField = context.CreateLabel();

                if (fields[i].PeekIntKey != -1)
                {
                    context.EmitKeyPeekTest(fields[i].PeekIntKey, nextField);
                }
                else
                {
                    context.EmitKeyTest(fields[i].ByteKey, nextField);
                }

                fields[i].Serializer.EmitRead(context);

                context.Goto(readField);
                context.MarkLabel(nextField);
            }

            context.SkipField();
            context.Goto(readField);

            context.MarkLabel(cleanup);
            context.SkipSpare();

            if (top != null)
            {
                context.DisposeReaderOnTop();
                context.PopType(typeof(BlobReader));
            }

            context.LoadLocal(context.PeekTypeDef());
            context.PopTypeDef();
            context.PopType(targetType);
        }
Exemple #2
0
        public void EmitRead(JITContext context)
        {
            context.LoadLocal(context.PeekTypeDef());

            if (from is ListSerializer || from is DictionarySerializer)
            {
                context.CreateType(field.FieldType);
                context.PushType(field.FieldType);
                context.PushTypeDef(context.PeekTop(field.FieldType));

                context.LoadLocal(context.PeekTop(field.FieldType));
                context.StoreField(field);

                from.EmitRead(context);
                context.PopTypeDef();
                context.PopType(field.FieldType);
            }
            else
            {
                from.EmitRead(context);
                context.StoreField(field);
            }
        }
        public void EmitRead(JITContext context)
        {
            context.LoadLocal(context.PeekTypeDef());

            if (from is ListSerializer || from is DictionarySerializer)
            {
                context.CreateType(prop.PropertyType);
                context.PushType(prop.PropertyType);
                context.PushTypeDef(context.PeekTop(prop.PropertyType));

                context.LoadLocal(context.PeekTop(prop.PropertyType));
                context.StoreProp(prop);

                from.EmitRead(context);
                context.PopTypeDef();
                context.PopType(prop.PropertyType);
            }
            else
            {
                from.EmitRead(context);
                context.StoreProp(prop);
            }
        }
        public void EmitRead(JITContext context)
        {
            LocalBuilder top = context.PeekTypeDef();
            if (top != null)
            {
                context.ReadFieldBlob();
                context.PushType(typeof(BlobReader));
            }

            context.CreateType(targetType);
            context.PushType(targetType);
            context.PushTypeDef(context.PeekTop(targetType));

            Label readField = context.CreateLabel();
            Label cleanup = context.CreateLabel();

            context.MarkLabel(readField);
            context.CanReadBytes(BlobReader.FieldHeaderLength);
            context.GotoWhenFalse(cleanup);

            context.ReadFieldHeader();

            for (int i = 0; i < fields.Length; i++)
            {
                Label nextField = context.CreateLabel();

                if (fields[i].PeekIntKey != -1)
                {
                    context.EmitKeyPeekTest(fields[i].PeekIntKey, nextField);
                }
                else
                {
                    context.EmitKeyTest(fields[i].ByteKey, nextField);
                }

                fields[i].Serializer.EmitRead(context);

                context.Goto(readField);
                context.MarkLabel(nextField);
            }

            context.SkipField();
            context.Goto(readField);

            context.MarkLabel(cleanup);
            context.SkipSpare();

            if (top != null)
            {
                context.DisposeReaderOnTop();
                context.PopType(typeof(BlobReader));
            }

            context.LoadLocal(context.PeekTypeDef());
            context.PopTypeDef();
            context.PopType(targetType);
        }