Browse Source

Merge branch 'develop' into p2p-udp-nodetable

cl-refactor
subtly 10 years ago
parent
commit
42293bfa79
  1. 21
      libsolidity/Scanner.cpp
  2. 1
      libsolidity/Scanner.h
  3. 59
      libweb3jsonrpc/WebThreeStubServer.cpp
  4. 7
      test/SolidityScanner.cpp

21
libsolidity/Scanner.cpp

@ -285,8 +285,6 @@ Token::Value Scanner::scanMultiLineDocComment()
bool endFound = false;
bool charsAdded = false;
advance(); //consume the last '*' at /**
skipWhitespaceExceptLF();
while (!isSourcePastEndOfInput())
{
//handle newlines in multline comments
@ -354,11 +352,20 @@ Token::Value Scanner::scanSlash()
return Token::WHITESPACE;
else if (m_char == '*')
{
Token::Value comment;
m_nextSkippedComment.location.start = firstSlashPosition;
comment = scanMultiLineDocComment();
m_nextSkippedComment.location.end = getSourcePos();
m_nextSkippedComment.token = comment;
advance(); //consume the last '*' at /**
skipWhitespaceExceptLF();
// special case of a closed normal multiline comment
if (!m_source.isPastEndOfInput() && m_source.get(0) == '/')
advance(); //skip the closing slash
else // we actually have a multiline documentation comment
{
Token::Value comment;
m_nextSkippedComment.location.start = firstSlashPosition;
comment = scanMultiLineDocComment();
m_nextSkippedComment.location.end = getSourcePos();
m_nextSkippedComment.token = comment;
}
return Token::WHITESPACE;
}
else

1
libsolidity/Scanner.h

@ -119,6 +119,7 @@ public:
{
return m_currentToken.token;
}
Location getCurrentLocation() const { return m_currentToken.location; }
std::string const& getCurrentLiteral() const { return m_currentToken.literal; }
///@}

59
libweb3jsonrpc/WebThreeStubServer.cpp

@ -266,21 +266,16 @@ std::string WebThreeStubServer::shh_addToGroup(std::string const& _group, std::s
std::string WebThreeStubServer::eth_balanceAt(string const& _address)
{
int block = 0;
return toJS(client()->balanceAt(jsToAddress(_address), block));
return toJS(client()->balanceAt(jsToAddress(_address), client()->getDefault()));
}
Json::Value WebThreeStubServer::eth_blockByHash(std::string const& _hash)
{
if (!client())
return "";
return toJson(client()->blockInfo(jsToFixed<32>(_hash)));
}
Json::Value WebThreeStubServer::eth_blockByNumber(int const& _number)
{
if (!client())
return "";
return toJson(client()->blockInfo(client()->hashFromNumber(_number)));
}
@ -332,8 +327,6 @@ static TransactionSkeleton toTransaction(Json::Value const& _json)
std::string WebThreeStubServer::eth_call(Json::Value const& _json)
{
std::string ret;
if (!client())
return ret;
TransactionSkeleton t = toTransaction(_json);
if (!t.from && m_accounts.size())
{
@ -355,31 +348,27 @@ std::string WebThreeStubServer::eth_call(Json::Value const& _json)
bool WebThreeStubServer::eth_changed(int const& _id)
{
if (!client())
return false;
return client()->checkWatch(_id);
}
std::string WebThreeStubServer::eth_codeAt(string const& _address)
{
int block = 0;
return client() ? jsFromBinary(client()->codeAt(jsToAddress(_address), block)) : "";
return jsFromBinary(client()->codeAt(jsToAddress(_address), client()->getDefault()));
}
std::string WebThreeStubServer::eth_coinbase()
{
return client() ? toJS(client()->address()) : "";
return toJS(client()->address());
}
double WebThreeStubServer::eth_countAt(string const& _address)
{
int block = 0;
return client() ? (double)(uint64_t)client()->countAt(jsToAddress(_address), block) : 0;
return (double)(uint64_t)client()->countAt(jsToAddress(_address), client()->getDefault());
}
int WebThreeStubServer::eth_defaultBlock()
{
return client() ? client()->getDefault() : 0;
return client()->getDefault();
}
std::string WebThreeStubServer::eth_gasPrice()
@ -397,15 +386,11 @@ std::string WebThreeStubServer::db_get(std::string const& _name, std::string con
Json::Value WebThreeStubServer::eth_filterLogs(int const& _id)
{
if (!client())
return Json::Value(Json::arrayValue);
return toJson(client()->logs(_id));
}
Json::Value WebThreeStubServer::eth_logs(Json::Value const& _json)
{
if (!client())
return Json::Value(Json::arrayValue);
return toJson(client()->logs(toLogFilter(_json)));
}
@ -429,15 +414,12 @@ bool WebThreeStubServer::eth_listening()
bool WebThreeStubServer::eth_mining()
{
return client() ? client()->isMining() : false;
return client()->isMining();
}
int WebThreeStubServer::eth_newFilter(Json::Value const& _json)
{
unsigned ret = -1;
if (!client())
return ret;
// ret = client()->installWatch(toMessageFilter(_json));
ret = client()->installWatch(toLogFilter(_json));
return ret;
}
@ -445,8 +427,6 @@ int WebThreeStubServer::eth_newFilter(Json::Value const& _json)
int WebThreeStubServer::eth_newFilterString(std::string const& _filter)
{
unsigned ret = -1;
if (!client())
return ret;
if (_filter.compare("chain") == 0)
ret = client()->installWatch(dev::eth::ChainChangedFilter);
else if (_filter.compare("pending") == 0)
@ -528,7 +508,7 @@ std::string WebThreeStubServer::eth_solidity(std::string const& _code)
int WebThreeStubServer::eth_number()
{
return client() ? client()->number() + 1 : 0;
return client()->number() + 1;
}
int WebThreeStubServer::eth_peerCount()
@ -538,7 +518,6 @@ int WebThreeStubServer::eth_peerCount()
bool WebThreeStubServer::shh_post(Json::Value const& _json)
{
// cnote << this << m_ids;
shh::Message m = toMessage(_json);
Secret from;
@ -571,16 +550,12 @@ bool WebThreeStubServer::db_putString(std::string const& _name, std::string cons
bool WebThreeStubServer::eth_setCoinbase(std::string const& _address)
{
if (!client())
return false;
client()->setAddress(jsToAddress(_address));
return true;
}
bool WebThreeStubServer::eth_setDefaultBlock(int const& _block)
{
if (!client())
return false;
client()->setDefault(_block);
return true;
}
@ -596,9 +571,6 @@ bool WebThreeStubServer::eth_setListening(bool const& _listening)
bool WebThreeStubServer::eth_setMining(bool const& _mining)
{
if (!client())
return false;
if (_mining)
client()->startMining();
else
@ -646,22 +618,17 @@ bool WebThreeStubServer::shh_uninstallFilter(int const& _id)
std::string WebThreeStubServer::eth_stateAt(string const& _address, string const& _storage)
{
int block = 0;
return client() ? toJS(client()->stateAt(jsToAddress(_address), jsToU256(_storage), block)) : "";
return toJS(client()->stateAt(jsToAddress(_address), jsToU256(_storage), client()->getDefault()));
}
Json::Value WebThreeStubServer::eth_storageAt(string const& _address)
{
if (!client())
return Json::Value(Json::objectValue);
return toJson(client()->storageAt(jsToAddress(_address)));
}
std::string WebThreeStubServer::eth_transact(Json::Value const& _json)
{
std::string ret;
if (!client())
return ret;
TransactionSkeleton t = toTransaction(_json);
if (!t.from && m_accounts.size())
{
@ -689,36 +656,26 @@ std::string WebThreeStubServer::eth_transact(Json::Value const& _json)
Json::Value WebThreeStubServer::eth_transactionByHash(std::string const& _hash, int const& _i)
{
if (!client())
return "";
return toJson(client()->transaction(jsToFixed<32>(_hash), _i));
}
Json::Value WebThreeStubServer::eth_transactionByNumber(int const& _number, int const& _i)
{
if (!client())
return "";
return toJson(client()->transaction(client()->hashFromNumber(_number), _i));
}
Json::Value WebThreeStubServer::eth_uncleByHash(std::string const& _hash, int const& _i)
{
if (!client())
return "";
return toJson(client()->uncle(jsToFixed<32>(_hash), _i));
}
Json::Value WebThreeStubServer::eth_uncleByNumber(int const& _number, int const& _i)
{
if (!client())
return "";
return toJson(client()->uncle(client()->hashFromNumber(_number), _i));
}
bool WebThreeStubServer::eth_uninstallFilter(int const& _id)
{
if (!client())
return false;
client()->uninstallWatch(_id);
return true;
}

7
test/SolidityScanner.cpp

@ -227,6 +227,13 @@ BOOST_AUTO_TEST_CASE(documentation_comment_before_eos)
BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
}
BOOST_AUTO_TEST_CASE(empty_multiline_comment)
{
Scanner scanner(CharStream("/**/"));
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
}
BOOST_AUTO_TEST_CASE(empty_multiline_documentation_comment_before_eos)
{
Scanner scanner(CharStream("/***/"));

Loading…
Cancel
Save