Exemplo n.º 1
0
 public static MethodSignature CreateMethodSignature(TypeName memberCompositeName, MemberMetaInfo member, string methodName)
 {
     Debug.Assert(member.ReturnType != null);
     return(MethodSignatureBuilder.CreateMethod(memberCompositeName, methodName)
            .AddGenerics(T_STATE, GenericConstrainKind.Struct, new TypeName("Decuplr.Serialization.Binary", "IBinaryWriteState<TState>"))
            .AddArgument((RefKind.In, member.ReturnType.Symbol, "member"))
            .AddArgument((RefKind.In, member.ContainingFullType.Symbol, "source"))
            .AddArgument((TypeName.FromGenericArgument(T_STATE), "state"))
            .AddArgument((TypeName.FromType(typeof(Span <byte>)), "data"))
            .WithReturn(TypeName.FromType <int>()));
 }
Exemplo n.º 2
0
        /// <returns>Next state arg name</returns>
        private string LoadNextWriteState <TChainedMethod>(CodeNodeBuilder node, TChainedMethod chainedMethod) where TChainedMethod : MemberChainedMethods <TChainedMethod>
        {
            const string nextState = "nextState";

            var tstateTypeName = TypeName.FromGenericArgument(SerializeWriterChainedMethods.T_STATE);
            var state          = chainedMethod[tstateTypeName];
            var tsource        = chainedMethod[TypeName.FromType(_member.ContainingFullType.Symbol)];

            node.If($"!{state}.Write({tsource}, out var {nextState})", node => {
                node.Return();
            });

            return(nextState);
        }