aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authordjudjuu <julfaber@gmail.com>2017-05-19 21:45:01 +0800
committerdjudjuu <julfaber@gmail.com>2017-05-19 21:48:07 +0800
commit1d22233a43453a21d9fde6e4ba91e26d651045bd (patch)
treece28a2c414b76cd074ae7b6eb15fb8484d92828a /libsolidity/ast
parent6316a76ab915e03e02825ce391d3812098c6b682 (diff)
downloaddexon-solidity-1d22233a43453a21d9fde6e4ba91e26d651045bd.tar.gz
dexon-solidity-1d22233a43453a21d9fde6e4ba91e26d651045bd.tar.zst
dexon-solidity-1d22233a43453a21d9fde6e4ba91e26d651045bd.zip
refactoring functionCallAnnotation
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/ASTAnnotations.h13
-rw-r--r--libsolidity/ast/ASTJsonConverter.cpp35
-rw-r--r--libsolidity/ast/ASTJsonConverter.h1
3 files changed, 38 insertions, 11 deletions
diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h
index a7d89248..45a6dd1a 100644
--- a/libsolidity/ast/ASTAnnotations.h
+++ b/libsolidity/ast/ASTAnnotations.h
@@ -200,12 +200,17 @@ struct BinaryOperationAnnotation: ExpressionAnnotation
TypePointer commonType;
};
+enum class FunctionCallKind
+{
+ Unset,
+ FunctionCall,
+ TypeConversion,
+ StructConstructorCall
+};
+
struct FunctionCallAnnotation: ExpressionAnnotation
{
- /// Whether this is an explicit type conversion.
- bool isTypeConversion = false;
- /// Whether this is a struct constructor call.
- bool isStructConstructorCall = false;
+ FunctionCallKind kind = FunctionCallKind::Unset;
};
}
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp
index 3c3ceae8..81996678 100644
--- a/libsolidity/ast/ASTJsonConverter.cpp
+++ b/libsolidity/ast/ASTJsonConverter.cpp
@@ -156,19 +156,19 @@ Json::Value ASTJsonConverter::typePointerToJson(std::shared_ptr<std::vector<Type
}
void ASTJsonConverter::appendExpressionAttributes(
- std::vector<pair<string, Json::Value>> &_attributes,
+ std::vector<pair<string, Json::Value>>& _attributes,
ExpressionAnnotation const& _annotation
)
{
std::vector<pair<string, Json::Value>> exprAttributes = {
- make_pair("typeDescriptions", typePointerToJson(_annotation.type)),
+ make_pair("typeDescriptions", typePointerToJson(_annotation.type)),
make_pair("isConstant", _annotation.isConstant),
make_pair("isPure", _annotation.isPure),
make_pair("isLValue", _annotation.isLValue),
make_pair("lValueRequested", _annotation.lValueRequested),
make_pair("argumentTypes", typePointerToJson(_annotation.argumentTypes))
};
- _attributes.insert(_attributes.end(), exprAttributes.begin(), exprAttributes.end());
+ _attributes += exprAttributes;
}
Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<assembly::Identifier const* ,InlineAssemblyAnnotation::ExternalIdentifierInfo> _info)
@@ -344,6 +344,7 @@ bool ASTJsonConverter::visit(VariableDeclaration const& _node)
make_pair("name", _node.name()),
make_pair("typeName", toJsonOrNull(_node.typeName())),
make_pair("constant", _node.isConstant()),
+ make_pair("stateVariable", _node.isStateVariable()),
make_pair("storageLocation", location(_node.referenceLocation())),
make_pair("visibility", visibility(_node.visibility())),
make_pair("value", _node.value() ? toJson(*_node.value()) : Json::nullValue),
@@ -627,12 +628,17 @@ bool ASTJsonConverter::visit(FunctionCall const& _node)
for (auto const& name: _node.names())
names.append(Json::Value(*name));
std::vector<pair<string, Json::Value>> attributes = {
- make_pair(m_legacy ? "type_conversion" : "isTypeConversion", _node.annotation().isTypeConversion),
- make_pair("isStructConstructorCall", _node.annotation().isStructConstructorCall),
make_pair("expression", toJson(_node.expression())),
make_pair("names", std::move(names)),
make_pair("arguments", toJson(_node.arguments()))
- };
+ };
+ if (m_legacy)
+ {
+ attributes.push_back(make_pair("isStructConstructorCall", functionCallKind(_node.annotation().kind)));
+ attributes.push_back(make_pair("type_conversion", _node.annotation().kind == FunctionCallKind::TypeConversion));
+ }
+ else
+ attributes.push_back(make_pair("kind", functionCallKind(_node.annotation().kind)));
appendExpressionAttributes(attributes, _node.annotation());
setJsonNode(_node, "FunctionCall", std::move(attributes));
return false;
@@ -768,7 +774,22 @@ string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind)
case ContractDefinition::ContractKind::Library:
return "library";
default:
- BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown contract kind."));
+ BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of contract."));
+ }
+}
+
+string ASTJsonConverter::functionCallKind(FunctionCallKind _kind)
+{
+ switch (_kind)
+ {
+ case FunctionCallKind::FunctionCall:
+ return "functionCall";
+ case FunctionCallKind::TypeConversion:
+ return "typeConversion";
+ case FunctionCallKind::StructConstructorCall:
+ return "structConstructorCall";
+ default:
+ BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of function call ."));
}
}
diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h
index 3d6035a4..5ee40536 100644
--- a/libsolidity/ast/ASTJsonConverter.h
+++ b/libsolidity/ast/ASTJsonConverter.h
@@ -132,6 +132,7 @@ private:
std::string visibility(Declaration::Visibility const& _visibility);
std::string location(VariableDeclaration::Location _location);
std::string contractKind(ContractDefinition::ContractKind _kind);
+ std::string functionCallKind(FunctionCallKind _kind);
std::string type(Expression const& _expression);
std::string type(VariableDeclaration const& _varDecl);
int nodeId(ASTNode const& _node)