Open yz1019117968 opened 5 years ago
@yz1019117968 Do you have any file exhibiting the problems? I have tried with first, it worked perfectly. Also, what does the third one mean?
Yes, sorry, there's no fault in the first one.
For the rest two:
{"type":"SourceUnit","children":[{"type":"PragmaDirective","name":"solidity","value":"^0.4.18"},{"type":"ContractDefinition","name":"Ownable","baseContracts":[],"subNodes":[{"type":"FunctionDefinition","name":"transferOwnership","parameters":[{"type":"VariableDeclaration","typeName":{"type":"ElementaryTypeName","name":"address"},"name":"newOwner","storageLocation":null,"isStateVar":false,"isIndexed":false}],"returnParameters":null,"body":{"type":"Block","statements":[{"type":"ForStatement","initExpression":{"type":"VariableDeclarationStatement","variables":[{"type":"VariableDeclaration","typeName":{"type":"ElementaryTypeName","name":"uint"},"name":"i","storageLocation":null,"isStateVar":false,"isIndexed":false}],"initialValue":{"type":"NumberLiteral","number":"0","subdenomination":null}},"conditionExpression":{"type":"BinaryOperation","operator":"<","left":{"type":"Identifier","name":"i"},"right":{"type":"NumberLiteral","number":"5","subdenomination":null}},"loopExpression":{"type":"ExpressionStatement","expression":{"type":"UnaryOperation","operator":"++","subExpression":{"type":"Identifier","name":"i"},"isPrefix":false}},"body":{"type":"Block","statements":[]}}]},"visibility":"public","modifiers":[{"type":"ModifierInvocation","name":"onlyOwner","arguments":[{"type":"NumberLiteral","number":"5","subdenomination":null}]}],"isConstructor":false,"stateMutability":null}],"kind":"contract"}]}
This jsonString ast is produced by the following code:
pragma solidity ^0.4.18;
contract Ownable {
function transferOwnership(address newOwner) public onlyOwner(5) {
for (uint i=0; i<5; i++) {
}
}
}
For point 2: In ForStatement, there's no "=" or "let" show in any places in its initExpression.
For point 3: You see in the jsonString ast. The modifierInvocation obj is the almost last item to show in a function obj, causing when I traverse the json ast by your api, the modifierInvocation always show at the end of function.
Thank you so much!
For second, initialValue
object is the one you are looking for.
For third, what is the problem you are encountering in particular?