public static List <DecodedContainer> DecodeIntoContainerList(string path, string address, string ethURL, List <string> searchpath, Dictionary <string, string> multiContracts, string className = "") { StreamReader txt = new StreamReader(path); AntlrInputStream inputStream; if (String.IsNullOrEmpty(className)) { inputStream = new AntlrInputStream(txt.ReadToEnd()); } else { if (!multiContracts.ContainsKey(className)) { throw new KeyNotFoundException("Error the className " + className + " Not in file"); } inputStream = new AntlrInputStream(multiContracts[className]); } SolidityLexer speakLexer = new SolidityLexer(inputStream); CommonTokenStream commonTokenStream = new CommonTokenStream(speakLexer); SolidityParser solParser = new SolidityParser(commonTokenStream); var lst = new SolList(searchpath, multiContracts); solParser.AddParseListener(lst); solParser.sourceUnit(); Web3 connect = new Web3(ethURL); return(DecodIntoContainer(lst.variableList, connect, address, 0)); }
public static SolList DecodeInoSubDecoder(string txtContent, string address, string ethURL, List <string> searchpath, Dictionary <string, string> subcontracts) { AntlrInputStream inputStream = new AntlrInputStream(txtContent); SolidityLexer speakLexer = new SolidityLexer(inputStream); CommonTokenStream commonTokenStream = new CommonTokenStream(speakLexer); SolidityParser solParser = new SolidityParser(commonTokenStream); var lst = new SolList(searchpath, subcontracts); solParser.AddParseListener(lst); solParser.sourceUnit(); return(lst); }
public override void ExitInheritanceSpecifier([NotNull] InheritanceSpecifierContext context) { string importName = context.Start.Text + ".sol"; if (multiContracts != null && multiContracts.ContainsKey(context.Start.Text)) { SolList subdecoder = solidtyDecoder.DecodeInoSubDecoder(multiContracts[context.Start.Text], address, ethURL, searchpath, multiContracts); } else { foreach (string filepath in searchpath) { if (File.Exists(Path.Combine(filepath, importName))) { StreamReader txt = new StreamReader(Path.Combine(filepath, importName)); SolList subdecoder = solidtyDecoder.DecodeInoSubDecoder(txt.ReadToEnd(), address, ethURL, searchpath, multiContracts); this.MergeSubDecoder(subdecoder); return; } } } errorList.Add("File for import not found :" + importName); }
public void MergeSubDecoder(SolList subdecoder) { variableList.AddRange(subdecoder.variableList); }