Example #1
0
 public static Text GenTypeDeserializer(TgType type) =>
 type.Match(
     primitive: x => Concat("Read", x.Type.ToString()),
     typeRef: x => Concat("T.", x.Name, ".Deserialize"),
     vector: x => Concat(
         "ReadVector(",
         GenTypeDeserializer(x.Type),
         ")"
         )
     );
Example #2
0
        public static string ConvertType(TgType type) => type.Match(
            primitive: x =>
        {
            switch (x.Type)
            {
            case PrimitiveType.Bytes: return("Bytes");

            case PrimitiveType.Int128: return("BigMath.Int128");

            case PrimitiveType.Int256: return("BigMath.Int256");

            default: return(x.Type.ToString().ToLower());
            }
        },
            vector: x => $"Arr<{ConvertType(x.Type)}>",
            typeRef: x => x.Name == "X" || x.Name == "!X" ? "TFunc" : $"T.{x.Name}"
            );
Example #3
0
 public static bool IsRefType(TgType type) => type.Match(
     primitive: x => x.Type == PrimitiveType.String,
     vector: _ => false,
     typeRef: _ => true
     );