Пример #1
0
 void EmitWriteElement(SerializerCodeGen g, Operand obj, Operand fieldNumber, bool pack, Operand isFirst)
 {
     if (_protoCompatibility)
     {
         if (!pack)
         {
             g.Writer.WriteFieldHeaderBegin(fieldNumber);
         }
         else
         {
             g.Writer.WriteFieldHeaderBeginIgnored();
         }
     }
     else
     {
         // this can only be supported when wire type of elements will be the same each time and no field cancellations
         // we write only first header to get wire type
         // the difference between standard pack and this
         // is that we write wiretype here at the first time
         if (pack)
         {
             g.If(isFirst);
         }
         g.Writer.WriteFieldHeaderBegin(fieldNumber);
         if (pack)
         {
             g.Else();
             g.Writer.WriteFieldHeaderBeginIgnored();
             g.End();
         }
     }
     g.LeaveNextReturnOnStack();
     g.Eval(obj);
     _tail.EmitWrite(g.ctx, null);
 }