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>
|
|
|
|
#include <libsolidity/AST.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace dev
|
|
|
|
{
|
|
|
|
namespace solidity
|
|
|
|
{
|
|
|
|
|
|
|
|
void ASTJsonConverter::addJsonNode(string const& _typeName,
|
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;
|
|
|
|
Json::Value attrs;
|
|
|
|
|
|
|
|
node["type"] = _typeName;
|
|
|
|
for (auto &e: _list)
|
|
|
|
attrs[e.first] = e.second;
|
|
|
|
node["attributes"] = attrs;
|
|
|
|
|
2015-01-14 14:27:31 +00:00
|
|
|
m_jsonNodePtrs.top().append(node);
|
2015-01-06 15:50:04 +00:00
|
|
|
|
|
|
|
if (_hasChildren) {
|
|
|
|
Json::Value children(Json::arrayValue);
|
|
|
|
node["children"] = children;
|
2015-01-14 14:27:31 +00:00
|
|
|
m_jsonNodePtrs.push(node["children"]);
|
2015-01-06 15:50:04 +00:00
|
|
|
m_depth ++;
|
|
|
|
cout << "goDown" << endl;
|
|
|
|
}
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 15:50:04 +00:00
|
|
|
ASTJsonConverter::ASTJsonConverter(ASTNode const& _ast): m_ast(&_ast), m_depth(0)
|
2015-01-05 14:46:40 +00:00
|
|
|
{
|
|
|
|
Json::Value attrs;
|
2015-01-06 15:50:04 +00:00
|
|
|
Json::Value children(Json::arrayValue);
|
2015-01-05 14:46:40 +00:00
|
|
|
|
|
|
|
m_astJson["type"] = "root";
|
|
|
|
m_astJson["attributes"] = attrs;
|
2015-01-06 15:50:04 +00:00
|
|
|
attrs["name"] = "nameoffile"; //TODO
|
2015-01-05 14:46:40 +00:00
|
|
|
m_astJson["children"] = children;
|
2015-01-14 14:27:31 +00:00
|
|
|
m_jsonNodePtrs.push(m_astJson["children"]);
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::print(ostream& _stream)
|
|
|
|
{
|
|
|
|
m_ast->accept(*this);
|
|
|
|
_stream << m_astJson;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ImportDirective const& _node)
|
|
|
|
{
|
|
|
|
addJsonNode("import", { make_pair("file", _node.getIdentifier())});
|
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-01-06 15:50:04 +00:00
|
|
|
addJsonNode("contract", { make_pair("name", _node.getName())}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(StructDefinition const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("struct", { make_pair("name", _node.getName())}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ParameterList const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("parameter_list", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(FunctionDefinition const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("function",
|
|
|
|
{ make_pair("name", _node.getName()),
|
|
|
|
make_pair("public", boost::lexical_cast<std::string>(_node.isPublic())),
|
|
|
|
make_pair("const", boost::lexical_cast<std::string>(_node.isDeclaredConst()))},
|
|
|
|
true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(VariableDeclaration const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("variable_declaration",
|
|
|
|
{ //make_pair("type", _node.getTypeName()->getName()),
|
|
|
|
make_pair("name", _node.getName()),
|
|
|
|
make_pair("local", boost::lexical_cast<std::string>(_node.isLocalVariable()))});
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(TypeName const& _node)
|
|
|
|
{
|
|
|
|
// writeLine("TypeName");
|
|
|
|
// printSourcePart(_node);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ElementaryTypeName const& _node)
|
|
|
|
{
|
|
|
|
// writeLine(string("ElementaryTypeName ") + Token::toString(_node.getTypeName()));
|
|
|
|
// printSourcePart(_node);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(UserDefinedTypeName const& _node)
|
|
|
|
{
|
|
|
|
// writeLine("UserDefinedTypeName \"" + _node.getName() + "\"");
|
|
|
|
// printSourcePart(_node);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Mapping const& _node)
|
|
|
|
{
|
|
|
|
// writeLine("Mapping");
|
|
|
|
// printSourcePart(_node);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Statement const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("statement", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Block const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("block", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(IfStatement const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("if_statement", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(BreakableStatement const& _node)
|
|
|
|
{
|
|
|
|
// writeLine("BreakableStatement");
|
|
|
|
// printSourcePart(_node);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(WhileStatement const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("while_statement", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ForStatement const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("for_statement", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Continue const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("continue", {});
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Break const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("break", {});
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Return const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("return", {});;
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(VariableDefinition const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("variable_definition", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(ExpressionStatement const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("expression_statement", {}, true);
|
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(Expression const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("expression",
|
|
|
|
{
|
|
|
|
make_pair("type", _node.getType()->toString()),
|
|
|
|
make_pair("lvalue", boost::lexical_cast<std::string>(_node.isLValue())),
|
|
|
|
make_pair("local_lvalue", boost::lexical_cast<std::string>(_node.isLocalLValue())),
|
|
|
|
},
|
|
|
|
true);
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine("Expression");
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
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-06 15:50:04 +00:00
|
|
|
addJsonNode("assignment", {make_pair("operator", Token::toString(_node.getAssignmentOperator()))}, true);
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine(string("Assignment using operator ") + Token::toString(_node.getAssignmentOperator()));
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
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-06 15:50:04 +00:00
|
|
|
addJsonNode("unary_op",
|
|
|
|
{make_pair("prefix", boost::lexical_cast<std::string>(_node.isPrefixOperation())),
|
|
|
|
make_pair("operator", Token::toString(_node.getOperator()))},
|
|
|
|
true);
|
|
|
|
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine(string("UnaryOperation (") + (_node.isPrefixOperation() ? "prefix" : "postfix") +
|
|
|
|
// ") " + Token::toString(_node.getOperator()));
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(BinaryOperation const& _node)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
addJsonNode("binary_op",
|
|
|
|
{make_pair("operator", Token::toString(_node.getOperator()))},
|
|
|
|
true);
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine(string("BinaryOperation using operator ") + Token::toString(_node.getOperator()));
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
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-01-06 15:50:04 +00:00
|
|
|
addJsonNode("function_call",
|
|
|
|
{make_pair("type_conversion", boost::lexical_cast<std::string>(_node.isTypeConversion()))},
|
|
|
|
true);
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine("FunctionCall");
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
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-01-06 15:50:04 +00:00
|
|
|
addJsonNode("new_expression", {}, true);
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine("NewExpression");
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
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-06 15:50:04 +00:00
|
|
|
addJsonNode("member_access", {make_pair("member_name", _node.getMemberName())}, true);
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine("MemberAccess to member " + _node.getMemberName());
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
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-01-06 15:50:04 +00:00
|
|
|
addJsonNode("index_access", {}, true);
|
2015-01-05 14:46:40 +00:00
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
2015-01-06 15:50:04 +00:00
|
|
|
return true;
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ASTJsonConverter::visit(PrimaryExpression const& _node)
|
|
|
|
{
|
|
|
|
// writeLine("PrimaryExpression");
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_node);
|
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-06 15:50:04 +00:00
|
|
|
addJsonNode("identifier", {make_pair("value", _node.getName())});
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine(string("Identifier ") + _node.getName());
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_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-06 15:50:04 +00:00
|
|
|
addJsonNode("elementary_typename_expression",
|
|
|
|
{make_pair("value", Token::toString(_node.getTypeToken()))});
|
2015-01-05 14:46:40 +00:00
|
|
|
// writeLine(string("ElementaryTypeNameExpression ") + Token::toString(_node.getTypeToken()));
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_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-01-06 15:50:04 +00:00
|
|
|
char const* tokenString = Token::toString(_node.getToken());
|
|
|
|
addJsonNode("literal",
|
|
|
|
{
|
|
|
|
make_pair("string", (tokenString) ? tokenString : "null"),
|
|
|
|
make_pair("value", _node.getValue())});
|
|
|
|
|
2015-01-05 14:46:40 +00:00
|
|
|
// char const* tokenString = Token::toString(_node.getToken());
|
|
|
|
// if (!tokenString)
|
|
|
|
// tokenString = "[no token]";
|
|
|
|
// writeLine(string("Literal, token: ") + tokenString + " value: " + _node.getValue());
|
|
|
|
// printType(_node);
|
|
|
|
// printSourcePart(_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(Statement const&)
|
|
|
|
{
|
2015-01-06 15:50:04 +00:00
|
|
|
goUp();
|
2015-01-05 14:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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(BreakableStatement const&)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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&)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(VariableDefinition const&)
|
|
|
|
{
|
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(Expression 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(PrimaryExpression const&)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Identifier const&)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(ElementaryTypeNameExpression const&)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::endVisit(Literal const&)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTJsonConverter::printType(Expression const& _expression)
|
|
|
|
{
|
|
|
|
// if (_expression.getType())
|
|
|
|
// *m_ostream << getIndentation() << " Type: " << _expression.getType()->toString() << "\n";
|
|
|
|
// else
|
|
|
|
// *m_ostream << getIndentation() << " Type unknown.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|