mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Updates after code review
This commit is contained in:
parent
23bea46d04
commit
9ce1ded86f
@ -312,7 +312,7 @@ errorDefinition:
|
|||||||
Semicolon;
|
Semicolon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User type operators.
|
* Customizable operators of user-defined types.
|
||||||
*/
|
*/
|
||||||
userOp: Add | Sub | Mul | Div | Mod | BitAnd | BitOr | BitXor | BitNot | Equal | NotEqual | LessThan | GreaterThan | LessThanOrEqual | GreaterThanOrEqual | Shl | Sar | Exp | Not;
|
userOp: Add | Sub | Mul | Div | Mod | BitAnd | BitOr | BitXor | BitNot | Equal | NotEqual | LessThan | GreaterThan | LessThanOrEqual | GreaterThanOrEqual | Shl | Sar | Exp | Not;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ userOp: Add | Sub | Mul | Div | Mod | BitAnd | BitOr | BitXor | BitNot | Equal |
|
|||||||
* Using directive to bind library functions and free functions to types.
|
* Using directive to bind library functions and free functions to types.
|
||||||
* Can occur within contracts and libraries and at the file level.
|
* Can occur within contracts and libraries and at the file level.
|
||||||
*/
|
*/
|
||||||
usingDirective: Using (identifierPath (As userOp)? | (LBrace identifierPath (As userOp)? (Comma identifierPath (As userOp)?)* RBrace)) For (Mul | typeName) Global? Semicolon;
|
usingDirective: Using (identifierPath | (LBrace identifierPath (As userOp)? (Comma identifierPath (As userOp)?)* RBrace)) For (Mul | typeName) Global? Semicolon;
|
||||||
/**
|
/**
|
||||||
* A type name can be an elementary type, a function type, a mapping type, a user-defined type
|
* A type name can be an elementary type, a function type, a mapping type, a user-defined type
|
||||||
* (e.g. a contract or struct) or an array type.
|
* (e.g. a contract or struct) or an array type.
|
||||||
|
@ -81,6 +81,7 @@ bool ControlFlowBuilder::visit(BinaryOperation const& _operation)
|
|||||||
_operation.leftExpression().accept(*this);
|
_operation.leftExpression().accept(*this);
|
||||||
_operation.rightExpression().accept(*this);
|
_operation.rightExpression().accept(*this);
|
||||||
|
|
||||||
|
solAssert(*_operation.annotation().userDefinedFunction);
|
||||||
m_currentNode->functionDefinition = *_operation.annotation().userDefinedFunction;
|
m_currentNode->functionDefinition = *_operation.annotation().userDefinedFunction;
|
||||||
|
|
||||||
auto nextNode = newLabel();
|
auto nextNode = newLabel();
|
||||||
@ -102,13 +103,15 @@ bool ControlFlowBuilder::visit(UnaryOperation const& _operation)
|
|||||||
if (_operation.annotation().userDefinedFunction.set())
|
if (_operation.annotation().userDefinedFunction.set())
|
||||||
{
|
{
|
||||||
visitNode(_operation);
|
visitNode(_operation);
|
||||||
|
_operation.subExpression().accept(*this);
|
||||||
|
solAssert(*_operation.annotation().userDefinedFunction);
|
||||||
m_currentNode->functionDefinition = *_operation.annotation().userDefinedFunction;
|
m_currentNode->functionDefinition = *_operation.annotation().userDefinedFunction;
|
||||||
|
|
||||||
auto nextNode = newLabel();
|
auto nextNode = newLabel();
|
||||||
|
|
||||||
connect(m_currentNode, nextNode);
|
connect(m_currentNode, nextNode);
|
||||||
m_currentNode = nextNode;
|
m_currentNode = nextNode;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ASTConstVisitor::visit(_operation);
|
return ASTConstVisitor::visit(_operation);
|
||||||
|
@ -19,15 +19,11 @@
|
|||||||
#include <libsolidity/analysis/ControlFlowGraph.h>
|
#include <libsolidity/analysis/ControlFlowGraph.h>
|
||||||
|
|
||||||
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
||||||
#include <libsolutil/Visitor.h>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace solidity::util;
|
|
||||||
using namespace solidity::langutil;
|
using namespace solidity::langutil;
|
||||||
using namespace solidity::frontend;
|
using namespace solidity::frontend;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CFG::constructFlow(ASTNode const& _astRoot)
|
bool CFG::constructFlow(ASTNode const& _astRoot)
|
||||||
{
|
{
|
||||||
_astRoot.accept(*this);
|
_astRoot.accept(*this);
|
||||||
|
@ -98,8 +98,8 @@ struct CFGNode
|
|||||||
std::vector<CFGNode*> entries;
|
std::vector<CFGNode*> entries;
|
||||||
/// Exit nodes. All CFG nodes to which control flow may continue after this node.
|
/// Exit nodes. All CFG nodes to which control flow may continue after this node.
|
||||||
std::vector<CFGNode*> exits;
|
std::vector<CFGNode*> exits;
|
||||||
/// Function call done by this node
|
/// Resolved definition of the function called by this node
|
||||||
FunctionDefinition const* functionDefinition;
|
FunctionDefinition const* functionDefinition = nullptr;
|
||||||
/// Variable occurrences in the node.
|
/// Variable occurrences in the node.
|
||||||
std::vector<VariableOccurrence> variableOccurrences;
|
std::vector<VariableOccurrence> variableOccurrences;
|
||||||
// Source location of this control flow block.
|
// Source location of this control flow block.
|
||||||
|
@ -207,14 +207,20 @@ bool FunctionCallGraphBuilder::visit(MemberAccess const& _memberAccess)
|
|||||||
bool FunctionCallGraphBuilder::visit(BinaryOperation const& _binaryOperation)
|
bool FunctionCallGraphBuilder::visit(BinaryOperation const& _binaryOperation)
|
||||||
{
|
{
|
||||||
if (_binaryOperation.annotation().userDefinedFunction.set())
|
if (_binaryOperation.annotation().userDefinedFunction.set())
|
||||||
|
{
|
||||||
|
solAssert(*_binaryOperation.annotation().userDefinedFunction);
|
||||||
functionReferenced(**_binaryOperation.annotation().userDefinedFunction, true /* called directly */);
|
functionReferenced(**_binaryOperation.annotation().userDefinedFunction, true /* called directly */);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionCallGraphBuilder::visit(UnaryOperation const& _unaryOperation)
|
bool FunctionCallGraphBuilder::visit(UnaryOperation const& _unaryOperation)
|
||||||
{
|
{
|
||||||
if (_unaryOperation.annotation().userDefinedFunction.set())
|
if (_unaryOperation.annotation().userDefinedFunction.set())
|
||||||
|
{
|
||||||
|
solAssert(*_unaryOperation.annotation().userDefinedFunction);
|
||||||
functionReferenced(**_unaryOperation.annotation().userDefinedFunction, true /* called directly */);
|
functionReferenced(**_unaryOperation.annotation().userDefinedFunction, true /* called directly */);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user