public void EmitCallback(CompilerContext ctx, Local valueFrom, TypeModel.CallbackType callbackType) { _serializer.EmitCallback(ctx, valueFrom, callbackType); }
void IProtoTypeSerializer.EmitCallback(Compiler.CompilerContext ctx, Compiler.Local valueFrom, TypeModel.CallbackType callbackType) { head.EmitCallback(ctx, valueFrom, callbackType); }
void ProtoBuf.Serializers.IProtoTypeSerializer.EmitCallback(CompilerContext ctx, Local valueFrom, TypeModel.CallbackType callbackType) { MethodInfo item; bool flag = false; if (this.CanHaveInheritance) { for (int i = 0; i < (int)this.serializers.Length; i++) { IProtoSerializer protoSerializer = this.serializers[i]; if (protoSerializer.ExpectedType != this.forType && ((IProtoTypeSerializer)protoSerializer).HasCallbacks(callbackType)) { flag = true; } } } if (this.callbacks == null) { item = null; } else { item = this.callbacks[callbackType]; } MethodInfo methodInfo = item; if (methodInfo == null && !flag) { return; } ctx.LoadAddress(valueFrom, this.ExpectedType); TypeSerializer.EmitInvokeCallback(ctx, methodInfo, flag, null, this.forType); if (flag) { CodeLabel codeLabel = ctx.DefineLabel(); for (int j = 0; j < (int)this.serializers.Length; j++) { IProtoSerializer protoSerializer1 = this.serializers[j]; Type expectedType = protoSerializer1.ExpectedType; if (expectedType != this.forType) { IProtoTypeSerializer protoTypeSerializer = (IProtoTypeSerializer)protoSerializer1; IProtoTypeSerializer protoTypeSerializer1 = protoTypeSerializer; if (protoTypeSerializer.HasCallbacks(callbackType)) { CodeLabel codeLabel1 = ctx.DefineLabel(); CodeLabel codeLabel2 = ctx.DefineLabel(); ctx.CopyValue(); ctx.TryCast(expectedType); ctx.CopyValue(); ctx.BranchIfTrue(codeLabel1, true); ctx.DiscardValue(); ctx.Branch(codeLabel2, false); ctx.MarkLabel(codeLabel1); protoTypeSerializer1.EmitCallback(ctx, null, callbackType); ctx.Branch(codeLabel, false); ctx.MarkLabel(codeLabel2); } } } ctx.MarkLabel(codeLabel); ctx.DiscardValue(); } }