public void EmitRead(JITContext context)
        {
            context.ReadFieldBlob();
            context.PushType(typeof(BlobReader));

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

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

            context.ReadFieldHeader();

            context.LoadLocal(context.PeekTypeDef());

            switch (Type.GetTypeCode(leftType))
            {
            case TypeCode.Int32:
                context.LoadByteKey();
                context.LoadIntConstant(0);
                context.BitConvertToInt32();
                break;

            case TypeCode.String:
                context.PushUTF8Encoding();
                context.LoadByteKey();
                context.LoadIntConstant(0);
                context.GetFieldKeyBytes();
                context.ByteConvertToString();
                break;

            default:
                throw new NotImplementedException();
            }

            from.EmitRead(context);
            context.EmitCall(add);
            context.Goto(readField);

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

            context.DisposeReaderOnTop();
            context.PopType(typeof(BlobReader));
        }
        public void EmitRead(JITContext context)
        {
            context.ReadFieldBlob();
            context.PushType(typeof(BlobReader));

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

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

            context.ReadFieldHeader();

            context.LoadLocal(context.PeekTypeDef());

            // is this a safe optimization?
            if (from.ExpectedType.IsValueType)
            {
                context.LoadByteKey();
                context.LoadIntConstant(0);
                context.BitConvertToInt32();
                context.EmitCall(add);
                context.Goto(readField);
            }
            else
            {
                from.EmitRead(context);
                context.EmitCall(add);
                context.Goto(readField);
            }

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

            context.DisposeReaderOnTop();
            context.PopType(typeof(BlobReader));
        }
Exemple #3
0
        public void EmitRead(JITContext context)
        {
            context.ReadFieldBlob();
            context.PushType(typeof(BlobReader));

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

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

            context.ReadFieldHeader();

            context.LoadLocal(context.PeekTypeDef());

            // is this a safe optimization?
            if (from.ExpectedType.IsValueType)
            {
                context.LoadByteKey();
                context.LoadIntConstant(0);
                context.BitConvertToInt32();
                context.EmitCall(add);
                context.Goto(readField);
            }
            else
            {
                from.EmitRead(context);
                context.EmitCall(add);
                context.Goto(readField);
            }

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

            context.DisposeReaderOnTop();
            context.PopType(typeof(BlobReader));
        }
        public void EmitRead(JITContext context)
        {
            context.ReadFieldBlob();
            context.PushType(typeof(BlobReader));

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

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

            context.ReadFieldHeader();

            context.LoadLocal(context.PeekTypeDef());

            switch (Type.GetTypeCode(leftType))
            {
                case TypeCode.Int32:
                    context.LoadByteKey();
                    context.LoadIntConstant(0);
                    context.BitConvertToInt32();
                    break;
                case TypeCode.String:
                    context.PushUTF8Encoding();
                    context.LoadByteKey();
                    context.LoadIntConstant(0);
                    context.GetFieldKeyBytes();
                    context.ByteConvertToString();
                    break;
                default:
                    throw new NotImplementedException();
            }

            from.EmitRead(context);
            context.EmitCall(add);
            context.Goto(readField);
           
            context.MarkLabel(cleanup);
            context.SkipSpare();

            context.DisposeReaderOnTop();
            context.PopType(typeof(BlobReader));
        }