sbip-sg / solc-json-parser

A Powerful AST Parser for Solidity
12 stars 1 forks source link

support compile old binary, but ast format is not compatible #68

Closed minhhn2910 closed 3 months ago

minhhn2910 commented 1 year ago

Now the old solc will use either exact given binary from user by setting solc_binary_path Can compile and get compilation result. However, the structure of ast object is too different, the current parser can't handle it For example the contract mapping_write.sol

{'children': [{'attributes': {'literals': ['solidity', '^', '0.4', '.9']},
               'id': 1,
               'name': 'PragmaDirective',
               'src': '159:23:1'},
              {'attributes': {'fullyImplemented': True,
                              'isLibrary': False,
                              'linearizedBaseContracts': [51],
                              'name': 'Map'},
{'attributes': {'absolutePath': '<stdin>', 'exportedSymbols': {'Map': [69]}},
 'children': [{'attributes': {'literals': ['solidity', '^', '0.4', '.24']},
               'id': 1,
               'name': 'PragmaDirective',
               'src': '159:24:0'},
              {'attributes': {'baseContracts': [None],
                              'contractDependencies': [None],
                              'contractKind': 'contract',
                              'documentation': None,
                              'fullyImplemented': True,
                              'linearizedBaseContracts': [69],
                              'name': 'Map',
                              'scope': 70},

Error of the parser in this branch when running :

File "/solc_json_parser/parser.py", line 140, in symbols_to_ids_from_ast_v7
    syms = [c['ast']['attributes']['exportedSymbols'] for c in ast.values()]
  File "/solc_json_parser/parser.py", line 140, in <listcomp>
    syms = [c['ast']['attributes']['exportedSymbols'] for c in ast.values()]
KeyError: 'attributes'
minhhn2910 commented 3 months ago

The cost of supporting this is too high but does not help much except running some outdated datasets, let's close it.