(input)
| 72 | } |
| 73 | |
| 74 | function parseContract(input) { |
| 75 | |
| 76 | const elements = []; |
| 77 | const AST = input; |
| 78 | traverseAST(AST, elements); |
| 79 | // console.log(elements); |
| 80 | |
| 81 | // filter out all Contract Definitions |
| 82 | const contractDefinitions = _.filter(elements, (e, i) => e.name == "ContractDefinition"); |
| 83 | |
| 84 | // filter out all linearizedBaseContracts |
| 85 | // pick the last one as the last contract always has the full inheritance |
| 86 | const linearizedBaseContracts = _.last(_.map(contractDefinitions, e => e.attributes.linearizedBaseContracts)); |
| 87 | |
| 88 | // get all stateVariables |
| 89 | const stateVariables = _.filter(elements, e => e.attributes && e.attributes.stateVariable); |
| 90 | |
| 91 | // group them by scope |
| 92 | const stateVariableMap = _.groupBy(stateVariables, e => e.attributes.scope); |
| 93 | |
| 94 | orderedStateVariables = _.reduceRight( |
| 95 | linearizedBaseContracts, |
| 96 | (a, b) => { |
| 97 | return a.concat(stateVariableMap[b] || []); |
| 98 | }, |
| 99 | [] |
| 100 | ); |
| 101 | return orderedStateVariables; |
| 102 | } |
| 103 | |
| 104 | var walkSync = function(dir, filelist) { |
| 105 | files = fs.readdirSync(dir); |
no test coverage detected