diff options
author | chriseth <chris@ethereum.org> | 2016-09-06 18:25:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-06 18:25:04 +0800 |
commit | 171c74843bb231c4663ec0fe7f4252ac03266f53 (patch) | |
tree | ce79c2ec2342ec658f625c8e5bf4cc3b80957308 /libsolidity | |
parent | 3713cee49d65fd0dee508a4371147c4769367bfa (diff) | |
parent | 43c28c1ede33a80b6c259988dde6059f493a41a9 (diff) | |
download | dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar.gz dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar.zst dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.zip |
Merge pull request #995 from chriseth/fixutf8astjson
Do not emit non-utf8 strings for ast json.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 49ee6d34..0ea5e093 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -22,6 +22,7 @@ #include <libsolidity/ast/ASTJsonConverter.h> #include <boost/algorithm/string/join.hpp> +#include <libdevcore/UTF8.h> #include <libsolidity/ast/AST.h> using namespace std; @@ -397,9 +398,21 @@ bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node) bool ASTJsonConverter::visit(Literal const& _node) { char const* tokenString = Token::toString(_node.token()); + size_t invalidPos = 0; + Json::Value value{_node.value()}; + if (!dev::validate(_node.value(), invalidPos)) + value = Json::nullValue; + Token::Value subdenomination = Token::Value(_node.subDenomination()); addJsonNode(_node, "Literal", { - make_pair("string", tokenString ? tokenString : Json::Value()), - make_pair("value", _node.value()), + make_pair("token", tokenString ? tokenString : Json::Value()), + make_pair("value", value), + make_pair("hexvalue", toHex(_node.value())), + make_pair( + "subdenomination", + subdenomination == Token::Illegal ? + Json::nullValue : + Json::Value{Token::toString(subdenomination)} + ), make_pair("type", type(_node)) }); return true; |