anchor.diff:       f("    NewMsg = ~p(Value, Msg),~n", [mk_fn(add_field_, MsgName, FName)]),
        f("    ~p(Rest, 0, 0, NewMsg).~n",
          [mk_fn(d_read_field_def_, MsgName)])].
  -
  -format_packed_field_seq_decoder(MsgName, #field{type=Type}=FieldDef, Opts) ->
  -    case Type of
  -        fixed32  -> format_dpacked_nonvi(MsgName, FieldDef, 32, 'little');
  -        sfixed32 -> format_dpacked_nonvi(MsgName, FieldDef, 32, 'little-signed');
  -        float    -> format_dpacked_nonvi(MsgName, FieldDef, 32, 'little-float');
  -        fixed64  -> format_dpacked_nonvi(MsgName, FieldDef, 64, 'little');
  -        sfixed64 -> format_dpacked_nonvi(MsgName, FieldDef, 64, 'little-signed');
  -        double   -> format_dpacked_nonvi(MsgName, FieldDef, 64, 'little-float');
  -        _        -> format_dpacked_vi(MsgName, FieldDef, Opts)
  -    end.
  -
  -format_dpacked_nonvi(MsgName, #field{name=FName}, BitLen, BitType) ->
  -    FnName = mk_fn(d_packed_field_, MsgName, FName),
  -    [f("~p(<<Value:~p/~s, Rest/binary>>, AccSeq) ->~n",
  -       [FnName, BitLen, BitType]),
  -     f("    ~p(Rest, [Value | AccSeq]);~n", [FnName]),
  -     f("~p(<<>>, AccSeq) ->~n", [FnName]),
  -     f("    AccSeq.~n")].
  -
  -format_dpacked_vi(MsgName, #field{name=FName, type=Type}, Opts) ->
  -    FnName = mk_fn(d_packed_field_, MsgName, FName),
  -    BValueExpr = "X bsl N + Acc",
  -    {FValueCode, RestVar} = mk_unpack_vi(4, "FValue", BValueExpr, Type, "Rest",
  -                                         Opts),
  -    [f("~p(<<1:1, X:7, Rest/binary>>, N, Acc, AccSeq) ->~n", [FnName]),
  -     f("    ~p(Rest, N+7, X bsl N + Acc, AccSeq);~n", [FnName]),
  -     f("~p(<<0:1, X:7, Rest/binary>>, N, Acc, AccSeq) ->~n", [FnName]),
  -     f("~s", [FValueCode]),
  -     f("    ~p(~s, 0, 0, [FValue | AccSeq]);~n", [FnName, RestVar]),
  -     f("~p(<<>>, 0, 0, AccSeq) ->~n", [FnName]),
  -     f("    AccSeq.~n~n")].
   
   format_msg_decoder_reverse_toplevel(MsgName, MsgDef, AnRes) ->
       case get_field_pass(MsgName, AnRes) of
  
positive.code: merge_warns({ok, M, B}, Warns, binary)           -> {ok, M, B, Warns};
  merge_warns({ok, M, B, Warns1}, Warns2, binary)  -> {ok, M, B, Warns2++Warns1};
  merge_warns({error, R}, Warns, _OutFmt)          -> {error, R, Warns};
  merge_warns({error, R, Warns1}, Warns2, _OutFmt) -> {error, R, Warns2++Warns1}.
  
  possibly_report_warnings(Result, Opts) ->
      Warns = case Result of
  
negative.code:     end.
  
  format_packed_field_decoder(MsgName, FieldDef, AnRes, Opts) ->
      #field{name=FName, rnum=RNum, opts=FOpts} = FieldDef,
      FieldDefAsNonpacked = FieldDef#field{opts = FOpts -- [packed]},
      Zeros = compute_decoder_call_fill(FieldDefAsNonpacked, no_fill),
      DecodePackWrapFn = mk_fn(d_field_, MsgName, FName),
      Params = decoder_params(MsgName, AnRes),
      Param = case get_field_pass(MsgName, AnRes) of
                  pass_as_params ->
                      lists:nth(RNum - 1, Params);
                  pass_as_record ->
                      MsgVar = hd(Params),
                      record_access(MsgVar, MsgName, FName)
              end,
      OutParams = case get_field_pass(MsgName, AnRes) of
                      pass_as_params ->
                          lists_setelement(RNum - 1, Params, ?expr(NewSeq));
                      pass_as_record ->
                          [record_update(hd(Params), MsgName,
                                         [{FName, ?expr(NewSeq)}])]
                  end,
      [gpb_codegen:format_fn(
         DecodePackWrapFn,
         fun(<<1:1, X:7, Rest/binary>>, N, Acc, '<Params>') ->
                 '<call-recursively>'(Rest, N + 7, X bsl N + Acc, '<Params>');
            (<<0:1, X:7, Rest/binary>>, N, Acc, '<InParams>') ->
                 Len = X bsl N + Acc,
                 <<PackedBytes:Len/binary, Rest2/binary>> = Rest,
                 NewSeq = decode_packed(PackedBytes, '<Zeros>', '<Param>'),
                 '<call-read-field>'(Rest2, 0, 0, '<OutParams>')
         end,
         [replace_term('<call-recursively>', DecodePackWrapFn),
          splice_trees('<Params>', Params),
          splice_trees('<InParams>', Params),
          replace_term(decode_packed, mk_fn(d_packed_field_, MsgName, FName)),
          splice_trees('<Zeros>', Zeros),
          replace_tree('<Param>', Param),
          replace_term('<call-read-field>', mk_fn(d_read_field_def_, MsgName)),
          splice_trees('<OutParams>', OutParams)]),
       "\n\n",
       format_packed_field_seq_decoder(MsgName, FieldDef, Opts)].
  
  format_packed_field_seq_decoder(MsgName, #field{type=Type}=Field, Opts) ->
      case Type of
          fixed32  -> format_dpacked_nonvi(MsgName, Field, 32, [little]);
          sfixed32 -> format_dpacked_nonvi(MsgName, Field, 32, [little,signed]);
          float    -> format_dpacked_nonvi(MsgName, Field, 32, [little,float]);
          fixed64  -> format_dpacked_nonvi(MsgName, Field, 64, [little]);
          sfixed64 -> format_dpacked_nonvi(MsgName, Field, 64, [little,signed]);
          double   -> format_dpacked_nonvi(MsgName, Field, 64, [little,float]);
          _        -> format_dpacked_vi(MsgName, Field, Opts)
      end.
  
  format_dpacked_nonvi(MsgName, #field{name=FName}, BitLen, BitTypes) ->
      FnName = mk_fn(d_packed_field_, MsgName, FName),
      [gpb_codegen:format_fn(
         FnName,
         fun(<<Value:'<N>'/'<T>', Rest/binary>>, AccSeq) ->
                 '<call-recursively>'(Rest, [Value | AccSeq]);
            (<<>>, AccSeq) ->
                 AccSeq
         end,
         [replace_term('<call-recursively>', FnName),
          replace_term('<N>', BitLen),
          splice_trees('<T>', [erl_syntax:atom(BT) || BT <- BitTypes])]),
       "\n\n"].
  
  format_dpacked_vi(MsgName, #field{name=FName}=FieldDef, Opts) ->
      FnName = mk_fn(d_packed_field_, MsgName, FName),
      ExtValue = ?expr(X bsl N + Acc),
      FVar = ?expr(NewFValue), %% result is to be put in this variable
      Rest = ?expr(Rest),
      Bindings = new_bindings([{'<Value>', ExtValue},
                               {'<Rest>', Rest}]),
      BodyTailFn =
          fun(DecodeExprs, Rest2Var) ->
                  C = ?exprs('<call-recursively>'('<Rest2>', 0, 0,
                                                  ['<Res>' | AccSeq]),
                             [replace_tree('<Rest2>', Rest2Var),
                              replace_tree('<Res>', FVar)]),
                  DecodeExprs ++ C
          end,
      Body = decode_int_value(FVar, Bindings, FieldDef, Opts, BodyTailFn),
      [gpb_codegen:format_fn(
         FnName,
         fun(<<1:1, X:7, Rest/binary>>, N, Acc, AccSeq) ->
                 '<call-recursively>'(Rest, N + 7, X bsl N + Acc, AccSeq);
            (<<0:1, X:7, Rest/binary>>, N, Acc, AccSeq) ->
                 '<body>';
            (<<>>, 0, 0, AccSeq) ->
                 AccSeq
         end,
         [splice_trees('<body>', Body),
          replace_term('<call-recursively>', FnName)]),
       "\n\n"].
  
  format_vi_based_field_decoder(MsgName, FieldDef, AnRes, Opts) ->
      #field{name=FName}=FieldDef,
  