2015-01-05 14:46:40 +00:00
|
|
|
/*
|
|
|
|
This file is part of cpp-ethereum.
|
|
|
|
|
|
|
|
cpp-ethereum is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
cpp-ethereum is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @author Lefteris <lefteris@ethdev.com>
|
|
|
|
* @date 2015
|
|
|
|
* Converts the AST into json format
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <libsolidity/ASTJsonConverter.h>
|
2015-10-06 10:35:10 +00:00
|
|
|
#include <boost/algorithm/string/join.hpp>
|
2015-01-05 14:46:40 +00:00
|
|
|
#include <libsolidity/AST.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace dev
|
|
|
|
{
|
|
|
|
namespace solidity
|
|
|
|
{
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
void ASTJsonConverter::addKeyValue(Json::Value& _obj, string const& _key, string const& _val)
|
|
|
|
{
|
|
|
|
// special handling for booleans
|
|
|
|
if (_key == "const" || _key == "public" || _key == "local" ||
|
|
|
|
_key == "lvalue" || _key == "local_lvalue" || _key == "prefix")
|
|
|
|
_obj[_key] = (_val == "1") ? true : false;
|
|
|
|
else
|
|
|
|
// else simply add it as a string
|
|
|
|
_obj[_key] = _val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::addJsonNode(string const& _nodeName,
|
2015-01-06 15:50:04 +00:00
|
|
|
initializer_list<pair<string const, string const>> _list,
|
|
|
|
bool _hasChildren = false)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
|
|
|
Json::Value node;
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
node["name"] = _nodeName;
|
2015-01-16 10:44:55 +00:00
|
|
|
if (_list.size() != 0)
|
2015-01-15 15:54:59 +00:00
|
|
|
{
|
|
|
|
Json::Value attrs;
|
2015-01-16 10:44:55 +00:00
|
|
|
for (auto& e: _list)
|
2015-01-15 15:54:59 +00:00
|
|
|
addKeyValue(attrs, e.first, e.second);
|
|
|
|
node["attributes"] = attrs;
|
|
|
|
}
|
2015-01-05 14:46:40 +00:00
|
|
|
|
2015-01-16 10:44:55 +00:00
|
|
|
m_jsonNodePtrs.top()->append(node);
|
2015-01-06 15:50:04 +00:00
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
if (_hasChildren)
|
|
|
|
{
|
|
|
|
Json::Value& addedNode = (*m_jsonNodePtrs.top())[m_jsonNodePtrs.top()->size() - 1];
|
2015-01-06 15:50:04 +00:00
|
|
|
Json::Value children(Json::arrayValue);
|
2015-01-15 15:54:59 +00:00
|
|
|
addedNode["children"] = children;
|
|
|
|
m_jsonNodePtrs.push(&addedNode["children"]);
|
2015-01-06 15:50:04 +00:00
|
|
|
}
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
ASTJsonConverter::ASTJsonConverter(ASTNode const& _ast): m_ast(&_ast)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
Json::Value children(Json::arrayValue);
|
2015-01-05 14:46:40 +00:00
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
m_astJson["name"] = "root";
|
2015-01-05 14:46:40 +00:00
|
|
|
m_astJson["children"] = children;
|
2015-01-15 15:54:59 +00:00
|
|
|
m_jsonNodePtrs.push(&m_astJson["children"]);
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::print(ostream& _stream)
|
|
|
|
{
|
2015-01-28 07:50:53 +00:00
|
|
|
process();
|
2015-01-05 14:46:40 +00:00
|
|
|
_stream << m_astJson;
|
|
|
|
}
|
|
|
|
|
2015-01-28 07:50:53 +00:00
|
|
|
Json::Value const& ASTJsonConverter::json()
|
|
|
|
{
|
|
|
|
process();
|
|
|
|
return m_astJson;
|
|
|
|
}
|
|
|
|
|
2015-01-05 14:46:40 +00:00
|
|
|
bool ASTJsonConverter::visit(ImportDirective const& _node)
|
|
|
|
{
|
2015-08-31 16:44:29 +00:00
|
|
|
addJsonNode("Import", { make_pair("file", _node.identifier())});
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ContractDefinition const& _node)
|
|
|
|
{
|
2015-08-31 16:44:29 +00:00
|
|
|
addJsonNode("Contract", { make_pair("name", _node.name()) }, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(StructDefinition const& _node)
|
|
|
|
{
|
2015-08-31 16:44:29 +00:00
|
|
|
addJsonNode("Struct", { make_pair("name", _node.name()) }, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(ParameterList const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("ParameterList", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(FunctionDefinition const& _node)
|
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Function",
|
2015-08-31 16:44:29 +00:00
|
|
|
{ make_pair("name", _node.name()),
|
2015-01-06 15:50:04 +00:00
|
|
|
make_pair("public", boost::lexical_cast<std::string>(_node.isPublic())),
|
2015-01-16 10:44:55 +00:00
|
|
|
make_pair("const", boost::lexical_cast<std::string>(_node.isDeclaredConst())) },
|
2015-01-06 15:50:04 +00:00
|
|
|
true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(VariableDeclaration const& _node)
|
|
|
|
{
|
2015-09-24 10:12:31 +00:00
|
|
|
addJsonNode("VariableDeclaration", {
|
|
|
|
make_pair("name", _node.name()),
|
|
|
|
make_pair("name", _node.name()),
|
|
|
|
}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(TypeName const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ElementaryTypeName const& _node)
|
|
|
|
{
|
2015-08-31 16:44:29 +00:00
|
|
|
addJsonNode("ElementaryTypeName", { make_pair("name", Token::toString(_node.typeName())) });
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(UserDefinedTypeName const& _node)
|
|
|
|
{
|
2015-10-06 10:35:10 +00:00
|
|
|
addJsonNode("UserDefinedTypeName", {
|
|
|
|
make_pair("name", boost::algorithm::join(_node.namePath(), "."))
|
|
|
|
});
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(Mapping const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Mapping", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(Block const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Block", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(IfStatement const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("IfStatement", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(WhileStatement const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("WhileStatement", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(ForStatement const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("ForStatement", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(Continue const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Continue", {});
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(Break const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Break", {});
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(Return const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Return", {}, true);;
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-09-15 14:33:14 +00:00
|
|
|
bool ASTJsonConverter::visit(Throw const&)
|
|
|
|
{
|
|
|
|
addJsonNode("Throw", {}, true);;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-17 15:21:38 +00:00
|
|
|
bool ASTJsonConverter::visit(VariableDeclarationStatement const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("VariableDefinition", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:54:59 +00:00
|
|
|
bool ASTJsonConverter::visit(ExpressionStatement const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("ExpressionStatement", {}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Assignment const& _node)
|
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Assignment",
|
2015-08-31 16:44:29 +00:00
|
|
|
{ make_pair("operator", Token::toString(_node.assignmentOperator())),
|
2015-09-01 09:19:02 +00:00
|
|
|
make_pair("type", type(_node)) },
|
2015-01-15 15:54:59 +00:00
|
|
|
true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(UnaryOperation const& _node)
|
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("UnaryOperation",
|
2015-01-16 10:44:55 +00:00
|
|
|
{ make_pair("prefix", boost::lexical_cast<std::string>(_node.isPrefixOperation())),
|
2015-01-15 15:54:59 +00:00
|
|
|
make_pair("operator", Token::toString(_node.getOperator())),
|
2015-09-01 09:19:02 +00:00
|
|
|
make_pair("type", type(_node)) },
|
2015-01-06 15:50:04 +00:00
|
|
|
true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(BinaryOperation const& _node)
|
|
|
|
{
|
2015-09-16 14:56:30 +00:00
|
|
|
addJsonNode("BinaryOperation", {
|
|
|
|
make_pair("operator", Token::toString(_node.getOperator())),
|
|
|
|
make_pair("type", type(_node))
|
|
|
|
}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(FunctionCall const& _node)
|
|
|
|
{
|
2015-09-16 14:56:30 +00:00
|
|
|
addJsonNode("FunctionCall", {
|
|
|
|
make_pair("type_conversion", boost::lexical_cast<std::string>(_node.annotation().isTypeConversion)),
|
|
|
|
make_pair("type", type(_node))
|
|
|
|
}, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(NewExpression const& _node)
|
|
|
|
{
|
2015-09-01 09:19:02 +00:00
|
|
|
addJsonNode("NewExpression", { make_pair("type", type(_node)) }, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(MemberAccess const& _node)
|
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("MemberAccess",
|
2015-08-31 16:44:29 +00:00
|
|
|
{ make_pair("member_name", _node.memberName()),
|
2015-09-01 09:19:02 +00:00
|
|
|
make_pair("type", type(_node)) },
|
2015-01-15 15:54:59 +00:00
|
|
|
true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(IndexAccess const& _node)
|
|
|
|
{
|
2015-09-01 09:19:02 +00:00
|
|
|
addJsonNode("IndexAccess", { make_pair("type", type(_node)) }, true);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Identifier const& _node)
|
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Identifier",
|
2015-09-01 09:19:02 +00:00
|
|
|
{ make_pair("value", _node.name()), make_pair("type", type(_node)) });
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node)
|
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("ElementaryTypenameExpression",
|
2015-09-01 09:19:02 +00:00
|
|
|
{ make_pair("value", Token::toString(_node.typeToken())), make_pair("type", type(_node)) });
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Literal const& _node)
|
|
|
|
{
|
2015-08-31 16:44:29 +00:00
|
|
|
char const* tokenString = Token::toString(_node.token());
|
2015-01-15 15:54:59 +00:00
|
|
|
addJsonNode("Literal",
|
2015-01-16 10:44:55 +00:00
|
|
|
{ make_pair("string", (tokenString) ? tokenString : "null"),
|
2015-08-31 16:44:29 +00:00
|
|
|
make_pair("value", _node.value()),
|
2015-09-01 09:19:02 +00:00
|
|
|
make_pair("type", type(_node)) });
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ImportDirective const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ContractDefinition const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(StructDefinition const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ParameterList const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(FunctionDefinition const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(VariableDeclaration const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(TypeName const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ElementaryTypeName const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(UserDefinedTypeName const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Mapping const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Block const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(IfStatement const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(WhileStatement const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ForStatement const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Continue const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Break const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Return const&)
|
|
|
|
{
|
2015-01-15 15:54:59 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-09-15 14:33:14 +00:00
|
|
|
void ASTJsonConverter::endVisit(Throw const&)
|
|
|
|
{
|
|
|
|
goUp();
|
|
|
|
}
|
|
|
|
|
2015-02-17 15:21:38 +00:00
|
|
|
void ASTJsonConverter::endVisit(VariableDeclarationStatement const&)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ExpressionStatement const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Assignment const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(UnaryOperation const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(BinaryOperation const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(FunctionCall const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(NewExpression const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(MemberAccess const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(IndexAccess const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Identifier const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ElementaryTypeNameExpression const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Literal const&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-28 07:50:53 +00:00
|
|
|
void ASTJsonConverter::process()
|
|
|
|
{
|
|
|
|
if (!processed)
|
|
|
|
m_ast->accept(*this);
|
|
|
|
processed = true;
|
|
|
|
}
|
|
|
|
|
2015-09-01 09:19:02 +00:00
|
|
|
string ASTJsonConverter::type(Expression const& _expression)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
2015-09-16 14:56:30 +00:00
|
|
|
return _expression.annotation().type ? _expression.annotation().type->toString() : "Unknown";
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 10:12:31 +00:00
|
|
|
string ASTJsonConverter::type(VariableDeclaration const& _varDecl)
|
|
|
|
{
|
|
|
|
return _varDecl.annotation().type ? _varDecl.annotation().type->toString() : "Unknown";
|
|
|
|
}
|
|
|
|
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
}
|