private static JArray GetMethods(NeoModule module, IReadOnlyDictionary <string, int> docMap, IReadOnlyDictionary <int, int> addrConvTable)
        {
            var outjson = new JArray();

            foreach (var method in module.mapMethods.Values)
            {
                if (method.body_Codes.Values.Count == 0)
                {
                    continue;
                }

                var name = string.Format("{0},{1}",
                                         method._namespace, method.displayName);

                var range = string.Format("{0}-{1}",
                                          method.body_Codes.Values.First().addr,
                                          method.body_Codes.Values.Last().addr);

                var methodJson = new JObject();
                methodJson["id"]              = method.name;
                methodJson["name"]            = name;
                methodJson["range"]           = range;
                methodJson["params"]          = ConvertParamList(method.paramtypes);
                methodJson["return"]          = FuncExport.ConvType(method.returntype);
                methodJson["variables"]       = ConvertParamList(method.method?.body_Variables);
                methodJson["sequence-points"] = GetSequencePoints(method.body_Codes.Values, docMap, addrConvTable);
                outjson.Add(methodJson);
            }
            return(outjson);
        }
        private static JArray ConvertParamList(IEnumerable <NeoParam> @params)
        {
            @params ??= Enumerable.Empty <NeoParam>();
            var paramsJson = new JArray();

            foreach (var param in @params)
            {
                var value = string.Format("{0},{1}", param.name, FuncExport.ConvType(param.type));
                paramsJson.Add(value);
            }

            return(paramsJson);
        }
Example #3
0
        public JObject GenJson()
        {
            JObject json = new JObject();

            json["name"]       = this.name;
            json["returntype"] = FuncExport.ConvType(this.returntype);
            json["paramcount"] = this.paramtypes.Count;
            JArray jsonparams = new JArray();

            json["params"] = jsonparams;
            for (var i = 0; i < this.paramtypes.Count; i++)
            {
                JObject item = new JObject();
                item["name"] = this.paramtypes[i].name;
                item["type"] = FuncExport.ConvType(this.paramtypes[i].type);
                jsonparams.Add(item);
            }
            return(json);
        }