Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
b786d27032
  1. 3
      cmake/EthCompilerSettings.cmake
  2. 4
      cmake/EthDependencies.cmake
  3. 47
      cmake/FindMHD.cmake
  4. 2
      evmjit/libevmjit/Arith256.cpp
  5. 8
      extdep/CMakeLists.txt
  6. 13
      libethcore/CommonJS.cpp
  7. 2
      libethcore/CommonJS.h
  8. 6
      libp2p/NodeTable.h
  9. 25
      libsolidity/AST.cpp
  10. 43
      libsolidity/AST.h
  11. 2
      libsolidity/ASTForward.h
  12. 22
      libsolidity/ASTPrinter.cpp
  13. 4
      libsolidity/ASTPrinter.h
  14. 8
      libsolidity/ASTVisitor.h
  15. 28
      libsolidity/AST_accept.h
  16. 29
      libsolidity/ExpressionCompiler.cpp
  17. 15
      libsolidity/NameAndTypeResolver.cpp
  18. 2
      libsolidity/NameAndTypeResolver.h
  19. 35
      libsolidity/Parser.cpp
  20. 2
      libsolidity/Parser.h
  21. 80
      libsolidity/Token.h
  22. 48
      libsolidity/Types.cpp
  23. 33
      libsolidity/Types.h
  24. 5
      libsolidity/grammar.txt
  25. 5
      libweb3jsonrpc/CMakeLists.txt
  26. 26
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  27. 26
      libweb3jsonrpc/WebThreeStubServerBase.h
  28. 146
      libweb3jsonrpc/abstractwebthreestubserver.h
  29. 2
      mix/Web3Server.cpp
  30. 2
      mix/Web3Server.h
  31. 3
      mix/qml/CodeEditorView.qml
  32. 4
      mix/qml/Debugger.qml
  33. 124
      mix/qml/WebPreview.qml
  34. 14
      mix/qml/WebPreviewStyle.qml
  35. BIN
      mix/qml/img/available_updates.png
  36. 1
      mix/qml/qmldir
  37. 2
      mix/res.qrc
  38. 17
      test/PerformaceTester.sol
  39. 20
      test/SolidityEndToEndTest.cpp
  40. 91
      test/SolidityNameAndTypeResolution.cpp
  41. 32
      test/SolidityParser.cpp
  42. 4
      test/vm.cpp
  43. 131
      test/vmPerformanceTestFiller.json
  44. 30
      test/webthreestubclient.h

3
cmake/EthCompilerSettings.cmake

@ -27,13 +27,14 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# enable parallel compilation
# specify Exception Handling Model in msvc # specify Exception Handling Model in msvc
# disable unknown pragma warning (4068) # disable unknown pragma warning (4068)
# disable unsafe function warning (4996) # disable unsafe function warning (4996)
# disable decorated name length exceeded, name was truncated (4503) # disable decorated name length exceeded, name was truncated (4503)
# disable warning C4535: calling _set_se_translator() requires /EHa (for boost tests) # disable warning C4535: calling _set_se_translator() requires /EHa (for boost tests)
# declare Windows XP requirement # declare Windows XP requirement
add_compile_options(/EHsc /wd4068 /wd4996 /wd4503 -D_WIN32_WINNT=0x0501) add_compile_options(/MP /EHsc /wd4068 /wd4996 /wd4503 -D_WIN32_WINNT=0x0501)
# disable empty object file warning # disable empty object file warning
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
# warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification # warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification

4
cmake/EthDependencies.cmake

@ -59,6 +59,10 @@ if (JSONRPC)
message (" - json-rpc-cpp lib : ${JSON_RPC_CPP_LIBRARIES}") message (" - json-rpc-cpp lib : ${JSON_RPC_CPP_LIBRARIES}")
add_definitions(-DETH_JSONRPC) add_definitions(-DETH_JSONRPC)
find_package(MHD)
message(" - microhttpd header: ${MHD_INCLUDE_DIRS}")
message(" - microhttpd lib : ${MHD_LIBRARIES}")
endif() #JSONRPC endif() #JSONRPC
# TODO readline package does not yet check for correct version number # TODO readline package does not yet check for correct version number

47
cmake/FindMHD.cmake

@ -0,0 +1,47 @@
# Find microhttpd
#
# Find the microhttpd includes and library
#
# if you need to add a custom library search path, do it via via CMAKE_PREFIX_PATH
#
# This module defines
# MHD_INCLUDE_DIRS, where to find header, etc.
# MHD_LIBRARIES, the libraries needed to use jsoncpp.
# MHD_FOUND, If false, do not try to use jsoncpp.
find_path(
MHD_INCLUDE_DIR
NAMES microhttpd.h
DOC "microhttpd include dir"
)
find_library(
MHD_LIBRARY
NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
DOC "microhttpd library"
)
set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
set(MHD_LIBRARIES ${MHD_LIBRARY})
# debug library on windows
# same naming convention as in QT (appending debug library with d)
# boost is using the same "hack" as us with "optimized" and "debug"
# official MHD project actually uses _d suffix
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
find_library(
MHD_LIBRARY_DEBUG
NAMES microhttpd_d microhttpd-10_d libmicrohttpd_d libmicrohttpd-dll_d
DOC "mhd debug library"
)
set(MHD_LIBRARIES optimized ${MHD_LIBRARIES} debug ${MHD_LIBRARY_DEBUG})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(mhd DEFAULT_MSG
MHD_INCLUDE_DIR MHD_LIBRARY)
mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY)

2
evmjit/libevmjit/Arith256.cpp

@ -416,7 +416,7 @@ namespace
explicit operator uint128() explicit operator uint128()
{ {
uint128 r = lo; uint128 r = lo;
r |= ((uint128) mid) << 64; r = r + ((uint128) mid) << 64;
return r; return r;
} }

8
extdep/CMakeLists.txt

@ -35,14 +35,18 @@ if (ETH_COMPILE)
include(compile/boost.cmake) include(compile/boost.cmake)
else() else()
eth_download(jsoncpp) eth_download(jsoncpp)
eth_download(json-rpc-cpp OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/json-rpc-cpp_osx.sh) eth_download(microhttpd)
eth_download(json-rpc-cpp
VERSION 4.2
OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/json-rpc-cpp_osx.sh
)
if (APPLE) if (APPLE)
eth_download(snappy OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snappy_osx.sh) eth_download(snappy OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snappy_osx.sh)
endif() endif()
eth_download(leveldb OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/leveldb_osx.sh) eth_download(leveldb OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/leveldb_osx.sh)
eth_download(qt) eth_download(qt VERSION 5.4)
eth_download(cryptopp) eth_download(cryptopp)
eth_download(boost) eth_download(boost)
eth_download(curl) eth_download(curl)

13
libethcore/CommonJS.cpp

@ -97,7 +97,7 @@ std::string fromRaw(h256 _n, unsigned* _inc)
return ""; return "";
} }
std::string prettyU256(u256 _n) std::string prettyU256(u256 _n, bool _abridged)
{ {
unsigned inc = 0; unsigned inc = 0;
std::string raw; std::string raw;
@ -110,11 +110,16 @@ std::string prettyU256(u256 _n)
{ {
Address a = right160(_n); Address a = right160(_n);
std::string n = a.abridged(); std::string n;
if (_abridged)
n = a.abridged();
else
n = toHex(a.ref());
if (n.empty()) if (n.empty())
s << "0x" << a; s << "0";
else else
s << n << "(0x" << a.abridged() << ")"; s << _n << "(0x" << n << ")";
} }
else if ((raw = fromRaw((h256)_n, &inc)).size()) else if ((raw = fromRaw((h256)_n, &inc)).size())
return "\"" + raw + "\"" + (inc ? " + " + std::to_string(inc) : ""); return "\"" + raw + "\"" + (inc ? " + " + std::to_string(inc) : "");

2
libethcore/CommonJS.h

@ -59,7 +59,7 @@ bytes unpadded(bytes _s);
/// Remove all 0 byte on the head of @a _s. /// Remove all 0 byte on the head of @a _s.
bytes unpadLeft(bytes _s); bytes unpadLeft(bytes _s);
/// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256.
std::string prettyU256(u256 _n); std::string prettyU256(u256 _n, bool _abridged = true);
/// Convert h256 into user-readable string (by directly using std::string constructor). /// Convert h256 into user-readable string (by directly using std::string constructor).
std::string fromRaw(h256 _n, unsigned* _inc = nullptr); std::string fromRaw(h256 _n, unsigned* _inc = nullptr);
/// Convert string to Address (h160), returns empty address if (_a.size != 40). /// Convert string to Address (h160), returns empty address if (_a.size != 40).

6
libp2p/NodeTable.h

@ -168,10 +168,10 @@ public:
/// Returns the Node to the corresponding node id or the empty Node if that id is not found. /// Returns the Node to the corresponding node id or the empty Node if that id is not found.
Node node(NodeId const& _id); Node node(NodeId const& _id);
#ifndef BOOST_AUTO_TEST_SUITE #if defined(BOOST_AUTO_TEST_SUITE) || defined(_MSC_VER) // MSVC includes access specifier in symbol name
private:
#else
protected: protected:
#else
private:
#endif #endif
/// Constants for Kademlia, derived from address space. /// Constants for Kademlia, derived from address space.

25
libsolidity/AST.cpp

@ -206,6 +206,13 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::getIn
return *m_interfaceFunctionList; return *m_interfaceFunctionList;
} }
TypePointer EnumValue::getType(ContractDefinition const*) const
{
EnumDefinition const* parentDef = dynamic_cast<EnumDefinition const*>(getScope());
solAssert(parentDef, "Enclosing Scope of EnumValue was not set");
return make_shared<EnumType>(*parentDef);
}
void InheritanceSpecifier::checkTypeRequirements() void InheritanceSpecifier::checkTypeRequirements()
{ {
m_baseName->checkTypeRequirements(); m_baseName->checkTypeRequirements();
@ -255,6 +262,24 @@ void StructDefinition::checkRecursion() const
} }
} }
void EnumDefinition::checkValidityOfMembers() const
{
vector<ASTPointer<EnumValue>> members(getMembers());
auto compareDecls = [](ASTPointer<EnumValue> a, ASTPointer<EnumValue> b)
{
return a->getName() < b->getName();
};
sort(begin(members), end(members), compareDecls);
for (size_t i = 0; i < members.size() - 1; ++i)
if (members[i]->getName() == members[i + 1]->getName())
BOOST_THROW_EXCEPTION(members[i]->createTypeError("Duplicate member detected in Enum"));
}
TypePointer EnumDefinition::getType(ContractDefinition const*) const
{
return make_shared<TypeType>(make_shared<EnumType>(*this));
}
TypePointer FunctionDefinition::getType(ContractDefinition const*) const TypePointer FunctionDefinition::getType(ContractDefinition const*) const
{ {
return make_shared<FunctionType>(*this); return make_shared<FunctionType>(*this);

43
libsolidity/AST.h

@ -209,6 +209,7 @@ public:
ASTPointer<ASTString> const& _documentation, ASTPointer<ASTString> const& _documentation,
std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts, std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts,
std::vector<ASTPointer<StructDefinition>> const& _definedStructs, std::vector<ASTPointer<StructDefinition>> const& _definedStructs,
std::vector<ASTPointer<EnumDefinition>> const& _definedEnums,
std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables, std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables,
std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions, std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions,
std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers, std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers,
@ -216,6 +217,7 @@ public:
Declaration(_location, _name), Documented(_documentation), Declaration(_location, _name), Documented(_documentation),
m_baseContracts(_baseContracts), m_baseContracts(_baseContracts),
m_definedStructs(_definedStructs), m_definedStructs(_definedStructs),
m_definedEnums(_definedEnums),
m_stateVariables(_stateVariables), m_stateVariables(_stateVariables),
m_definedFunctions(_definedFunctions), m_definedFunctions(_definedFunctions),
m_functionModifiers(_functionModifiers), m_functionModifiers(_functionModifiers),
@ -227,6 +229,7 @@ public:
std::vector<ASTPointer<InheritanceSpecifier>> const& getBaseContracts() const { return m_baseContracts; } std::vector<ASTPointer<InheritanceSpecifier>> const& getBaseContracts() const { return m_baseContracts; }
std::vector<ASTPointer<StructDefinition>> const& getDefinedStructs() const { return m_definedStructs; } std::vector<ASTPointer<StructDefinition>> const& getDefinedStructs() const { return m_definedStructs; }
std::vector<ASTPointer<EnumDefinition>> const& getDefinedEnums() const { return m_definedEnums; }
std::vector<ASTPointer<VariableDeclaration>> const& getStateVariables() const { return m_stateVariables; } std::vector<ASTPointer<VariableDeclaration>> const& getStateVariables() const { return m_stateVariables; }
std::vector<ASTPointer<ModifierDefinition>> const& getFunctionModifiers() const { return m_functionModifiers; } std::vector<ASTPointer<ModifierDefinition>> const& getFunctionModifiers() const { return m_functionModifiers; }
std::vector<ASTPointer<FunctionDefinition>> const& getDefinedFunctions() const { return m_definedFunctions; } std::vector<ASTPointer<FunctionDefinition>> const& getDefinedFunctions() const { return m_definedFunctions; }
@ -260,6 +263,7 @@ private:
std::vector<ASTPointer<InheritanceSpecifier>> m_baseContracts; std::vector<ASTPointer<InheritanceSpecifier>> m_baseContracts;
std::vector<ASTPointer<StructDefinition>> m_definedStructs; std::vector<ASTPointer<StructDefinition>> m_definedStructs;
std::vector<ASTPointer<EnumDefinition>> m_definedEnums;
std::vector<ASTPointer<VariableDeclaration>> m_stateVariables; std::vector<ASTPointer<VariableDeclaration>> m_stateVariables;
std::vector<ASTPointer<FunctionDefinition>> m_definedFunctions; std::vector<ASTPointer<FunctionDefinition>> m_definedFunctions;
std::vector<ASTPointer<ModifierDefinition>> m_functionModifiers; std::vector<ASTPointer<ModifierDefinition>> m_functionModifiers;
@ -315,6 +319,43 @@ private:
std::vector<ASTPointer<VariableDeclaration>> m_members; std::vector<ASTPointer<VariableDeclaration>> m_members;
}; };
class EnumDefinition: public Declaration
{
public:
EnumDefinition(Location const& _location,
ASTPointer<ASTString> const& _name,
std::vector<ASTPointer<EnumValue>> const& _members):
Declaration(_location, _name), m_members(_members) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
std::vector<ASTPointer<EnumValue>> const& getMembers() const { return m_members; }
virtual TypePointer getType(ContractDefinition const*) const override;
/// Checks that the members do not include any duplicate names
void checkValidityOfMembers() const;
private:
std::vector<ASTPointer<EnumValue>> m_members;
};
/**
* Declaration of an Enum Value
*/
class EnumValue: public Declaration
{
public:
EnumValue(Location const& _location,
ASTPointer<ASTString> const& _name):
Declaration(_location, _name) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
TypePointer getType(ContractDefinition const* = nullptr) const;
};
/** /**
* Parameter list, used as function parameter list and return list. * Parameter list, used as function parameter list and return list.
* None of the parameters is allowed to contain mappings (not even recursively * None of the parameters is allowed to contain mappings (not even recursively
@ -679,7 +720,7 @@ public:
Expression const& getCondition() const { return *m_condition; } Expression const& getCondition() const { return *m_condition; }
Statement const& getTrueStatement() const { return *m_trueBody; } Statement const& getTrueStatement() const { return *m_trueBody; }
/// @returns the "else" part of the if statement or nullptr if there is no "else" part. /// @returns the "else" part of the if statement or nullptr if there is no "else" part.
Statement const* getFalseStatement() const { return m_falseBody.get(); } Statement const* getFalseStatement() const { return m_falseBody.get(); }
private: private:

2
libsolidity/ASTForward.h

@ -40,6 +40,8 @@ class Declaration;
class ContractDefinition; class ContractDefinition;
class InheritanceSpecifier; class InheritanceSpecifier;
class StructDefinition; class StructDefinition;
class EnumDefinition;
class EnumValue;
class ParameterList; class ParameterList;
class FunctionDefinition; class FunctionDefinition;
class VariableDeclaration; class VariableDeclaration;

22
libsolidity/ASTPrinter.cpp

@ -71,6 +71,18 @@ bool ASTPrinter::visit(StructDefinition const& _node)
return goDeeper(); return goDeeper();
} }
bool ASTPrinter::visit(EnumDefinition const& _node)
{
writeLine("EnumDefinition \"" + _node.getName() + "\"");
return goDeeper();
}
bool ASTPrinter::visit(EnumValue const& _node)
{
writeLine("EnumValue \"" + _node.getName() + "\"");
return goDeeper();
}
bool ASTPrinter::visit(ParameterList const& _node) bool ASTPrinter::visit(ParameterList const& _node)
{ {
writeLine("ParameterList"); writeLine("ParameterList");
@ -347,6 +359,16 @@ void ASTPrinter::endVisit(StructDefinition const&)
m_indentation--; m_indentation--;
} }
void ASTPrinter::endVisit(EnumDefinition const&)
{
m_indentation--;
}
void ASTPrinter::endVisit(EnumValue const&)
{
m_indentation--;
}
void ASTPrinter::endVisit(ParameterList const&) void ASTPrinter::endVisit(ParameterList const&)
{ {
m_indentation--; m_indentation--;

4
libsolidity/ASTPrinter.h

@ -46,6 +46,8 @@ public:
bool visit(ContractDefinition const& _node) override; bool visit(ContractDefinition const& _node) override;
bool visit(InheritanceSpecifier const& _node) override; bool visit(InheritanceSpecifier const& _node) override;
bool visit(StructDefinition const& _node) override; bool visit(StructDefinition const& _node) override;
bool visit(EnumDefinition const& _node) override;
bool visit(EnumValue const& _node) override;
bool visit(ParameterList const& _node) override; bool visit(ParameterList const& _node) override;
bool visit(FunctionDefinition const& _node) override; bool visit(FunctionDefinition const& _node) override;
bool visit(VariableDeclaration const& _node) override; bool visit(VariableDeclaration const& _node) override;
@ -85,6 +87,8 @@ public:
void endVisit(ContractDefinition const&) override; void endVisit(ContractDefinition const&) override;
void endVisit(InheritanceSpecifier const&) override; void endVisit(InheritanceSpecifier const&) override;
void endVisit(StructDefinition const&) override; void endVisit(StructDefinition const&) override;
void endVisit(EnumDefinition const&) override;
void endVisit(EnumValue const&) override;
void endVisit(ParameterList const&) override; void endVisit(ParameterList const&) override;
void endVisit(FunctionDefinition const&) override; void endVisit(FunctionDefinition const&) override;
void endVisit(VariableDeclaration const&) override; void endVisit(VariableDeclaration const&) override;

8
libsolidity/ASTVisitor.h

@ -47,6 +47,8 @@ public:
virtual bool visit(ContractDefinition&) { return true; } virtual bool visit(ContractDefinition&) { return true; }
virtual bool visit(InheritanceSpecifier&) { return true; } virtual bool visit(InheritanceSpecifier&) { return true; }
virtual bool visit(StructDefinition&) { return true; } virtual bool visit(StructDefinition&) { return true; }
virtual bool visit(EnumDefinition&) { return true; }
virtual bool visit(EnumValue&) { return true; }
virtual bool visit(ParameterList&) { return true; } virtual bool visit(ParameterList&) { return true; }
virtual bool visit(FunctionDefinition&) { return true; } virtual bool visit(FunctionDefinition&) { return true; }
virtual bool visit(VariableDeclaration&) { return true; } virtual bool visit(VariableDeclaration&) { return true; }
@ -88,6 +90,8 @@ public:
virtual void endVisit(ContractDefinition&) { } virtual void endVisit(ContractDefinition&) { }
virtual void endVisit(InheritanceSpecifier&) { } virtual void endVisit(InheritanceSpecifier&) { }
virtual void endVisit(StructDefinition&) { } virtual void endVisit(StructDefinition&) { }
virtual void endVisit(EnumDefinition&) { }
virtual void endVisit(EnumValue&) { }
virtual void endVisit(ParameterList&) { } virtual void endVisit(ParameterList&) { }
virtual void endVisit(FunctionDefinition&) { } virtual void endVisit(FunctionDefinition&) { }
virtual void endVisit(VariableDeclaration&) { } virtual void endVisit(VariableDeclaration&) { }
@ -133,6 +137,8 @@ public:
virtual bool visit(ContractDefinition const&) { return true; } virtual bool visit(ContractDefinition const&) { return true; }
virtual bool visit(InheritanceSpecifier const&) { return true; } virtual bool visit(InheritanceSpecifier const&) { return true; }
virtual bool visit(StructDefinition const&) { return true; } virtual bool visit(StructDefinition const&) { return true; }
virtual bool visit(EnumDefinition const&) { return true; }
virtual bool visit(EnumValue const&) { return true; }
virtual bool visit(ParameterList const&) { return true; } virtual bool visit(ParameterList const&) { return true; }
virtual bool visit(FunctionDefinition const&) { return true; } virtual bool visit(FunctionDefinition const&) { return true; }
virtual bool visit(VariableDeclaration const&) { return true; } virtual bool visit(VariableDeclaration const&) { return true; }
@ -174,6 +180,8 @@ public:
virtual void endVisit(ContractDefinition const&) { } virtual void endVisit(ContractDefinition const&) { }
virtual void endVisit(InheritanceSpecifier const&) { } virtual void endVisit(InheritanceSpecifier const&) { }
virtual void endVisit(StructDefinition const&) { } virtual void endVisit(StructDefinition const&) { }
virtual void endVisit(EnumDefinition const&) { }
virtual void endVisit(EnumValue const&) { }
virtual void endVisit(ParameterList const&) { } virtual void endVisit(ParameterList const&) { }
virtual void endVisit(FunctionDefinition const&) { } virtual void endVisit(FunctionDefinition const&) { }
virtual void endVisit(VariableDeclaration const&) { } virtual void endVisit(VariableDeclaration const&) { }

28
libsolidity/AST_accept.h

@ -63,6 +63,7 @@ void ContractDefinition::accept(ASTVisitor& _visitor)
{ {
listAccept(m_baseContracts, _visitor); listAccept(m_baseContracts, _visitor);
listAccept(m_definedStructs, _visitor); listAccept(m_definedStructs, _visitor);
listAccept(m_definedEnums, _visitor);
listAccept(m_stateVariables, _visitor); listAccept(m_stateVariables, _visitor);
listAccept(m_events, _visitor); listAccept(m_events, _visitor);
listAccept(m_functionModifiers, _visitor); listAccept(m_functionModifiers, _visitor);
@ -77,6 +78,7 @@ void ContractDefinition::accept(ASTConstVisitor& _visitor) const
{ {
listAccept(m_baseContracts, _visitor); listAccept(m_baseContracts, _visitor);
listAccept(m_definedStructs, _visitor); listAccept(m_definedStructs, _visitor);
listAccept(m_definedEnums, _visitor);
listAccept(m_stateVariables, _visitor); listAccept(m_stateVariables, _visitor);
listAccept(m_events, _visitor); listAccept(m_events, _visitor);
listAccept(m_functionModifiers, _visitor); listAccept(m_functionModifiers, _visitor);
@ -105,6 +107,32 @@ void InheritanceSpecifier::accept(ASTConstVisitor& _visitor) const
_visitor.endVisit(*this); _visitor.endVisit(*this);
} }
void EnumDefinition::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
listAccept(m_members, _visitor);
_visitor.endVisit(*this);
}
void EnumDefinition::accept(ASTConstVisitor& _visitor) const
{
if (_visitor.visit(*this))
listAccept(m_members, _visitor);
_visitor.endVisit(*this);
}
void EnumValue::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
void EnumValue::accept(ASTConstVisitor& _visitor) const
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
void StructDefinition::accept(ASTVisitor& _visitor) void StructDefinition::accept(ASTVisitor& _visitor)
{ {
if (_visitor.visit(*this)) if (_visitor.visit(*this))

29
libsolidity/ExpressionCompiler.cpp

@ -489,13 +489,23 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
m_currentLValue.retrieveValueIfLValueNotRequested(_memberAccess); m_currentLValue.retrieveValueIfLValueNotRequested(_memberAccess);
break; break;
} }
case Type::Category::Enum:
{
EnumType const& type = dynamic_cast<EnumType const&>(*_memberAccess.getExpression().getType());
m_context << type.getMemberValue(_memberAccess.getMemberName());
break;
}
case Type::Category::TypeType: case Type::Category::TypeType:
{ {
TypeType const& type = dynamic_cast<TypeType const&>(*_memberAccess.getExpression().getType()); TypeType const& type = dynamic_cast<TypeType const&>(*_memberAccess.getExpression().getType());
if (type.getMembers().getMemberType(member)) ContractType const* contractType;
EnumType const* enumType;
if (!type.getMembers().getMemberType(member))
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to " + type.toString()));
if ((contractType = dynamic_cast<ContractType const*>(type.getActualType().get())))
{ {
ContractDefinition const& contract = dynamic_cast<ContractType const&>(*type.getActualType()) ContractDefinition const& contract = contractType->getContractDefinition();
.getContractDefinition();
for (ASTPointer<FunctionDefinition> const& function: contract.getDefinedFunctions()) for (ASTPointer<FunctionDefinition> const& function: contract.getDefinedFunctions())
if (function->getName() == member) if (function->getName() == member)
{ {
@ -503,7 +513,12 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
return; return;
} }
} }
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to " + type.toString())); else if ((enumType = dynamic_cast<EnumType const*>(type.getActualType().get())))
{
m_context << enumType->getMemberValue(_memberAccess.getMemberName());
return;
}
} }
case Type::Category::ByteArray: case Type::Category::ByteArray:
{ {
@ -562,6 +577,10 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier)
{ {
// no-op // no-op
} }
else if (dynamic_cast<EnumDefinition const*>(declaration))
{
// no-op
}
else else
{ {
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier type not expected in expression context.")); BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier type not expected in expression context."));
@ -746,7 +765,7 @@ void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type con
} }
} }
else if (stackTypeCategory == Type::Category::Integer || stackTypeCategory == Type::Category::Contract || else if (stackTypeCategory == Type::Category::Integer || stackTypeCategory == Type::Category::Contract ||
stackTypeCategory == Type::Category::IntegerConstant) stackTypeCategory == Type::Category::IntegerConstant || stackTypeCategory == Type::Category::Enum)
{ {
if (targetTypeCategory == Type::Category::String && stackTypeCategory == Type::Category::Integer) if (targetTypeCategory == Type::Category::String && stackTypeCategory == Type::Category::Integer)
{ {

15
libsolidity/NameAndTypeResolver.cpp

@ -58,6 +58,8 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs()) for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs())
ReferencesResolver resolver(*structDef, *this, &_contract, nullptr); ReferencesResolver resolver(*structDef, *this, &_contract, nullptr);
for (ASTPointer<EnumDefinition> const& enumDef: _contract.getDefinedEnums())
ReferencesResolver resolver(*enumDef, *this, &_contract, nullptr);
for (ASTPointer<VariableDeclaration> const& variable: _contract.getStateVariables()) for (ASTPointer<VariableDeclaration> const& variable: _contract.getStateVariables())
ReferencesResolver resolver(*variable, *this, &_contract, nullptr); ReferencesResolver resolver(*variable, *this, &_contract, nullptr);
for (ASTPointer<EventDefinition> const& event: _contract.getEvents()) for (ASTPointer<EventDefinition> const& event: _contract.getEvents())
@ -79,6 +81,8 @@ void NameAndTypeResolver::checkTypeRequirements(ContractDefinition& _contract)
{ {
for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs()) for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs())
structDef->checkValidityOfMembers(); structDef->checkValidityOfMembers();
for (ASTPointer<EnumDefinition> const& enumDef: _contract.getDefinedEnums())
enumDef->checkValidityOfMembers();
_contract.checkTypeRequirements(); _contract.checkTypeRequirements();
} }
@ -221,6 +225,17 @@ void DeclarationRegistrationHelper::endVisit(StructDefinition&)
closeCurrentScope(); closeCurrentScope();
} }
bool DeclarationRegistrationHelper::visit(EnumDefinition& _enum)
{
registerDeclaration(_enum, true);
return true;
}
void DeclarationRegistrationHelper::endVisit(EnumDefinition&)
{
closeCurrentScope();
}
bool DeclarationRegistrationHelper::visit(FunctionDefinition& _function) bool DeclarationRegistrationHelper::visit(FunctionDefinition& _function)
{ {
registerDeclaration(_function, true); registerDeclaration(_function, true);

2
libsolidity/NameAndTypeResolver.h

@ -98,6 +98,8 @@ private:
void endVisit(ContractDefinition& _contract) override; void endVisit(ContractDefinition& _contract) override;
bool visit(StructDefinition& _struct) override; bool visit(StructDefinition& _struct) override;
void endVisit(StructDefinition& _struct) override; void endVisit(StructDefinition& _struct) override;
bool visit(EnumDefinition& _enum) override;
void endVisit(EnumDefinition& _enum) override;
bool visit(FunctionDefinition& _function) override; bool visit(FunctionDefinition& _function) override;
void endVisit(FunctionDefinition& _function) override; void endVisit(FunctionDefinition& _function) override;
bool visit(ModifierDefinition& _modifier) override; bool visit(ModifierDefinition& _modifier) override;

35
libsolidity/Parser.cpp

@ -119,6 +119,7 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
ASTPointer<ASTString> name = expectIdentifierToken(); ASTPointer<ASTString> name = expectIdentifierToken();
vector<ASTPointer<InheritanceSpecifier>> baseContracts; vector<ASTPointer<InheritanceSpecifier>> baseContracts;
vector<ASTPointer<StructDefinition>> structs; vector<ASTPointer<StructDefinition>> structs;
vector<ASTPointer<EnumDefinition>> enums;
vector<ASTPointer<VariableDeclaration>> stateVariables; vector<ASTPointer<VariableDeclaration>> stateVariables;
vector<ASTPointer<FunctionDefinition>> functions; vector<ASTPointer<FunctionDefinition>> functions;
vector<ASTPointer<ModifierDefinition>> modifiers; vector<ASTPointer<ModifierDefinition>> modifiers;
@ -140,6 +141,8 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
functions.push_back(parseFunctionDefinition(name.get())); functions.push_back(parseFunctionDefinition(name.get()));
else if (currentToken == Token::Struct) else if (currentToken == Token::Struct)
structs.push_back(parseStructDefinition()); structs.push_back(parseStructDefinition());
else if (currentToken == Token::Enum)
enums.push_back(parseEnumDefinition());
else if (currentToken == Token::Identifier || currentToken == Token::Mapping || else if (currentToken == Token::Identifier || currentToken == Token::Mapping ||
Token::isElementaryTypeName(currentToken)) Token::isElementaryTypeName(currentToken))
{ {
@ -157,7 +160,7 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
} }
nodeFactory.markEndPosition(); nodeFactory.markEndPosition();
expectToken(Token::RBrace); expectToken(Token::RBrace);
return nodeFactory.createNode<ContractDefinition>(name, docString, baseContracts, structs, return nodeFactory.createNode<ContractDefinition>(name, docString, baseContracts, structs, enums,
stateVariables, functions, modifiers, events); stateVariables, functions, modifiers, events);
} }
@ -263,6 +266,36 @@ ASTPointer<StructDefinition> Parser::parseStructDefinition()
return nodeFactory.createNode<StructDefinition>(name, members); return nodeFactory.createNode<StructDefinition>(name, members);
} }
ASTPointer<EnumValue> Parser::parseEnumValue()
{
ASTNodeFactory nodeFactory(*this);
nodeFactory.markEndPosition();
return nodeFactory.createNode<EnumValue>(expectIdentifierToken());
}
ASTPointer<EnumDefinition> Parser::parseEnumDefinition()
{
ASTNodeFactory nodeFactory(*this);
expectToken(Token::Enum);
ASTPointer<ASTString> name = expectIdentifierToken();
vector<ASTPointer<EnumValue>> members;
expectToken(Token::LBrace);
while (m_scanner->getCurrentToken() != Token::RBrace)
{
members.push_back(parseEnumValue());
if (m_scanner->getCurrentToken() == Token::RBrace)
break;
expectToken(Token::Comma);
if (m_scanner->getCurrentToken() != Token::Identifier)
BOOST_THROW_EXCEPTION(createParserError("Expected Identifier after ','"));
}
nodeFactory.markEndPosition();
expectToken(Token::RBrace);
return nodeFactory.createNode<EnumDefinition>(name, members);
}
ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(VarDeclParserOptions const& _options) ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(VarDeclParserOptions const& _options)
{ {
ASTNodeFactory nodeFactory(*this); ASTNodeFactory nodeFactory(*this);

2
libsolidity/Parser.h

@ -61,6 +61,8 @@ private:
Declaration::Visibility parseVisibilitySpecifier(Token::Value _token); Declaration::Visibility parseVisibilitySpecifier(Token::Value _token);
ASTPointer<FunctionDefinition> parseFunctionDefinition(ASTString const* _contractName); ASTPointer<FunctionDefinition> parseFunctionDefinition(ASTString const* _contractName);
ASTPointer<StructDefinition> parseStructDefinition(); ASTPointer<StructDefinition> parseStructDefinition();
ASTPointer<EnumDefinition> parseEnumDefinition();
ASTPointer<EnumValue> parseEnumValue();
ASTPointer<VariableDeclaration> parseVariableDeclaration(VarDeclParserOptions const& _options = VarDeclParserOptions()); ASTPointer<VariableDeclaration> parseVariableDeclaration(VarDeclParserOptions const& _options = VarDeclParserOptions());
ASTPointer<ModifierDefinition> parseModifierDefinition(); ASTPointer<ModifierDefinition> parseModifierDefinition();
ASTPointer<EventDefinition> parseEventDefinition(); ASTPointer<EventDefinition> parseEventDefinition();

80
libsolidity/Token.h

@ -67,31 +67,31 @@ namespace solidity
#define IGNORE_TOKEN(name, string, precedence) #define IGNORE_TOKEN(name, string, precedence)
#define TOKEN_LIST(T, K) \ #define TOKEN_LIST(T, K) \
/* End of source indicator. */ \ /* End of source indicator. */ \
T(EOS, "EOS", 0) \ T(EOS, "EOS", 0) \
\
/* Punctuators (ECMA-262, section 7.7, page 15). */ \
T(LParen, "(", 0) \
T(RParen, ")", 0) \
T(LBrack, "[", 0) \
T(RBrack, "]", 0) \
T(LBrace, "{", 0) \
T(RBrace, "}", 0) \
T(Colon, ":", 0) \
T(Semicolon, ";", 0) \
T(Period, ".", 0) \
T(Conditional, "?", 3) \
T(Arrow, "=>", 0) \
\ \
/* Punctuators (ECMA-262, section 7.7, page 15). */ \ /* Assignment operators. */ \
T(LParen, "(", 0) \ /* IsAssignmentOp() relies on this block of enum values being */ \
T(RParen, ")", 0) \ /* contiguous and sorted in the same order!*/ \
T(LBrack, "[", 0) \ T(Assign, "=", 2) \
T(RBrack, "]", 0) \
T(LBrace, "{", 0) \
T(RBrace, "}", 0) \
T(Colon, ":", 0) \
T(Semicolon, ";", 0) \
T(Period, ".", 0) \
T(Conditional, "?", 3) \
T(Arrow, "=>", 0) \
\
/* Assignment operators. */ \
/* IsAssignmentOp() relies on this block of enum values being */ \
/* contiguous and sorted in the same order!*/ \
T(Assign, "=", 2) \
/* The following have to be in exactly the same order as the simple binary operators*/ \ /* The following have to be in exactly the same order as the simple binary operators*/ \
T(AssignBitOr, "|=", 2) \ T(AssignBitOr, "|=", 2) \
T(AssignBitXor, "^=", 2) \ T(AssignBitXor, "^=", 2) \
T(AssignBitAnd, "&=", 2) \ T(AssignBitAnd, "&=", 2) \
T(AssignShl, "<<=", 2) \ T(AssignShl, "<<=", 2) \
T(AssignSar, ">>=", 2) \ T(AssignSar, ">>=", 2) \
T(AssignShr, ">>>=", 2) \ T(AssignShr, ">>>=", 2) \
@ -107,9 +107,9 @@ namespace solidity
T(Comma, ",", 1) \ T(Comma, ",", 1) \
T(Or, "||", 4) \ T(Or, "||", 4) \
T(And, "&&", 5) \ T(And, "&&", 5) \
T(BitOr, "|", 8) \ T(BitOr, "|", 8) \
T(BitXor, "^", 9) \ T(BitXor, "^", 9) \
T(BitAnd, "&", 10) \ T(BitAnd, "&", 10) \
T(SHL, "<<", 11) \ T(SHL, "<<", 11) \
T(SAR, ">>", 11) \ T(SAR, ">>", 11) \
T(SHR, ">>>", 11) \ T(SHR, ">>>", 11) \
@ -123,19 +123,19 @@ namespace solidity
/* Compare operators sorted by precedence. */ \ /* Compare operators sorted by precedence. */ \
/* IsCompareOp() relies on this block of enum values */ \ /* IsCompareOp() relies on this block of enum values */ \
/* being contiguous and sorted in the same order! */ \ /* being contiguous and sorted in the same order! */ \
T(Equal, "==", 6) \ T(Equal, "==", 6) \
T(NotEqual, "!=", 6) \ T(NotEqual, "!=", 6) \
T(LessThan, "<", 7) \ T(LessThan, "<", 7) \
T(GreaterThan, ">", 7) \ T(GreaterThan, ">", 7) \
T(LessThanOrEqual, "<=", 7) \ T(LessThanOrEqual, "<=", 7) \
T(GreaterThanOrEqual, ">=", 7) \ T(GreaterThanOrEqual, ">=", 7) \
K(In, "in", 7) \ K(In, "in", 7) \
\ \
/* Unary operators. */ \ /* Unary operators. */ \
/* IsUnaryOp() relies on this block of enum values */ \ /* IsUnaryOp() relies on this block of enum values */ \
/* being contiguous and sorted in the same order! */ \ /* being contiguous and sorted in the same order! */ \
T(Not, "!", 0) \ T(Not, "!", 0) \
T(BitNot, "~", 0) \ T(BitNot, "~", 0) \
T(Inc, "++", 0) \ T(Inc, "++", 0) \
T(Dec, "--", 0) \ T(Dec, "--", 0) \
K(Delete, "delete", 0) \ K(Delete, "delete", 0) \
@ -168,7 +168,7 @@ namespace solidity
K(Switch, "switch", 0) \ K(Switch, "switch", 0) \
K(Var, "var", 0) \ K(Var, "var", 0) \
K(While, "while", 0) \ K(While, "while", 0) \
\ K(Enum, "enum", 0) \
\ \
/* Ether subdenominations */ \ /* Ether subdenominations */ \
K(SubWei, "wei", 0) \ K(SubWei, "wei", 0) \
@ -316,15 +316,15 @@ namespace solidity
K(Text, "text", 0) \ K(Text, "text", 0) \
K(Real, "real", 0) \ K(Real, "real", 0) \
K(UReal, "ureal", 0) \ K(UReal, "ureal", 0) \
T(TypesEnd, NULL, 0) /* used as type enum end marker */ \ T(TypesEnd, NULL, 0) /* used as type enum end marker */ \
\ \
/* Literals */ \ /* Literals */ \
K(NullLiteral, "null", 0) \ K(NullLiteral, "null", 0) \
K(TrueLiteral, "true", 0) \ K(TrueLiteral, "true", 0) \
K(FalseLiteral, "false", 0) \ K(FalseLiteral, "false", 0) \
T(Number, NULL, 0) \ T(Number, NULL, 0) \
T(StringLiteral, NULL, 0) \ T(StringLiteral, NULL, 0) \
T(CommentLiteral, NULL, 0) \ T(CommentLiteral, NULL, 0) \
\ \
/* Identifiers (not keywords or future reserved words). */ \ /* Identifiers (not keywords or future reserved words). */ \
T(Identifier, NULL, 0) \ T(Identifier, NULL, 0) \

48
libsolidity/Types.cpp

@ -74,6 +74,8 @@ TypePointer Type::fromUserDefinedTypeName(UserDefinedTypeName const& _typeName)
Declaration const* declaration = _typeName.getReferencedDeclaration(); Declaration const* declaration = _typeName.getReferencedDeclaration();
if (StructDefinition const* structDef = dynamic_cast<StructDefinition const*>(declaration)) if (StructDefinition const* structDef = dynamic_cast<StructDefinition const*>(declaration))
return make_shared<StructType>(*structDef); return make_shared<StructType>(*structDef);
else if (EnumDefinition const* enumDef = dynamic_cast<EnumDefinition const*>(declaration))
return make_shared<EnumType>(*enumDef);
else if (FunctionDefinition const* function = dynamic_cast<FunctionDefinition const*>(declaration)) else if (FunctionDefinition const* function = dynamic_cast<FunctionDefinition const*>(declaration))
return make_shared<FunctionType>(*function); return make_shared<FunctionType>(*function);
else if (ContractDefinition const* contract = dynamic_cast<ContractDefinition const*>(declaration)) else if (ContractDefinition const* contract = dynamic_cast<ContractDefinition const*>(declaration))
@ -154,7 +156,9 @@ bool IntegerType::isExplicitlyConvertibleTo(Type const& _convertTo) const
StaticStringType const& convertTo = dynamic_cast<StaticStringType const&>(_convertTo); StaticStringType const& convertTo = dynamic_cast<StaticStringType const&>(_convertTo);
return isHash() && (m_bits == convertTo.getNumBytes() * 8); return isHash() && (m_bits == convertTo.getNumBytes() * 8);
} }
return _convertTo.getCategory() == getCategory() || _convertTo.getCategory() == Category::Contract; return _convertTo.getCategory() == getCategory() ||
_convertTo.getCategory() == Category::Contract ||
_convertTo.getCategory() == Category::Enum;
} }
TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const
@ -662,6 +666,41 @@ u256 StructType::getStorageOffsetOfMember(string const& _name) const
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage offset of non-existing member requested.")); BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage offset of non-existing member requested."));
} }
TypePointer EnumType::unaryOperatorResult(Token::Value _operator) const
{
return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer();
}
bool EnumType::operator==(Type const& _other) const
{
if (_other.getCategory() != getCategory())
return false;
EnumType const& other = dynamic_cast<EnumType const&>(_other);
return other.m_enum == m_enum;
}
string EnumType::toString() const
{
return string("enum ") + m_enum.getName();
}
bool EnumType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{
return _convertTo.getCategory() == getCategory() || _convertTo.getCategory() == Category::Integer;
}
unsigned int EnumType::getMemberValue(ASTString const& _member) const
{
unsigned int index = 0;
for (ASTPointer<EnumValue> const& decl: m_enum.getMembers())
{
if (decl->getName() == _member)
return index;
++index;
}
BOOST_THROW_EXCEPTION(m_enum.createTypeError("Requested unknown enum value ." + _member));
}
FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal): FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal):
m_location(_isInternal ? Location::Internal : Location::External), m_location(_isInternal ? Location::Internal : Location::External),
m_isConstant(_function.isDeclaredConst()), m_isConstant(_function.isDeclaredConst()),
@ -924,6 +963,13 @@ MemberList const& TypeType::getMembers() const
if (!f->isConstructor() && !f->getName().empty()) if (!f->isConstructor() && !f->getName().empty())
members[f->getName()] = make_shared<FunctionType>(*f); members[f->getName()] = make_shared<FunctionType>(*f);
} }
else if (m_actualType->getCategory() == Category::Enum)
{
EnumDefinition const& enumDef = dynamic_cast<EnumType const&>(*m_actualType).getEnumDefinition();
auto enumType = make_shared<EnumType>(enumDef);
for (ASTPointer<EnumValue> const& enumValue: enumDef.getMembers())
members.insert(make_pair(enumValue->getName(), enumType));
}
m_members.reset(new MemberList(members)); m_members.reset(new MemberList(members));
} }
return *m_members; return *m_members;

33
libsolidity/Types.h

@ -76,10 +76,9 @@ class Type: private boost::noncopyable, public std::enable_shared_from_this<Type
public: public:
enum class Category enum class Category
{ {
Integer, IntegerConstant, Bool, Real, String, Integer, IntegerConstant, Bool, Real, ByteArray,
ByteArray, Mapping, String, Contract, Struct, Function, Enum,
Contract, Struct, Function, Mapping, Void, TypeType, Modifier, Magic
Void, TypeType, Modifier, Magic
}; };
///@{ ///@{
@ -368,6 +367,32 @@ private:
mutable std::unique_ptr<MemberList> m_members; mutable std::unique_ptr<MemberList> m_members;
}; };
/**
* The type of an enum instance, there is one distinct type per enum definition.
*/
class EnumType: public Type
{
public:
virtual Category getCategory() const override { return Category::Enum; }
explicit EnumType(EnumDefinition const& _enum): m_enum(_enum) {}
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual bool operator==(Type const& _other) const override;
virtual unsigned getSizeOnStack() const override { return 1; }
virtual std::string toString() const override;
virtual bool isValueType() const override { return true; }
virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const override;
EnumDefinition const& getEnumDefinition() const { return m_enum; }
/// @returns the value that the string has in the Enum
unsigned int getMemberValue(ASTString const& _member) const;
private:
EnumDefinition const& m_enum;
/// List of member types, will be lazy-initialized because of recursive references.
mutable std::unique_ptr<MemberList> m_members;
};
/** /**
* The type of a function, identified by its (return) parameter types. * The type of a function, identified by its (return) parameter types.
* @todo the return parameters should also have names, i.e. return parameters should be a struct * @todo the return parameters should also have names, i.e. return parameters should be a struct

5
libsolidity/grammar.txt

@ -1,7 +1,7 @@
ContractDefinition = 'contract' Identifier ContractDefinition = 'contract' Identifier
( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )? ( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )?
'{' ContractPart* '}' '{' ContractPart* '}'
ContractPart = StateVariableDeclaration | StructDefinition | ModifierDefinition | FunctionDefinition ContractPart = StateVariableDeclaration | StructDefinition | ModifierDefinition | FunctionDefinition | EnumDefinition
InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )? InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )?
StructDefinition = 'struct' Identifier '{' StructDefinition = 'struct' Identifier '{'
@ -11,6 +11,9 @@ ModifierDefinition = 'modifier' Identifier ParameterList? Block
FunctionDefinition = 'function' Identifier ParameterList FunctionDefinition = 'function' Identifier ParameterList
( Identifier | 'constant' | 'public' | 'protected' | 'private' )* ( Identifier | 'constant' | 'public' | 'protected' | 'private' )*
( 'returns' ParameterList )? Block ( 'returns' ParameterList )? Block
EnumValue = Identifier
EnumDefinition = 'enum' '{' EnumValue (',' EnumValue)* '}'
ParameterList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')' ParameterList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')'
// semantic restriction: mappings and structs (recursively) containing mappings // semantic restriction: mappings and structs (recursively) containing mappings
// are not allowed in argument lists // are not allowed in argument lists

5
libweb3jsonrpc/CMakeLists.txt

@ -9,9 +9,11 @@ set(CMAKE_AUTOMOC OFF)
aux_source_directory(. SRC_LIST) aux_source_directory(. SRC_LIST)
include_directories(..)
include_directories(${JSONCPP_INCLUDE_DIRS})
include_directories(${MHD_INCLUDE_DIRS})
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
include_directories(${LEVELDB_INCLUDE_DIRS}) include_directories(${LEVELDB_INCLUDE_DIRS})
include_directories(..)
set(EXECUTABLE web3jsonrpc) set(EXECUTABLE web3jsonrpc)
@ -26,6 +28,7 @@ endif()
target_link_libraries(${EXECUTABLE} ${LEVELDB_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${LEVELDB_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_SERVER_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_SERVER_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${MHD_LIBRARIES})
target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} secp256k1) target_link_libraries(${EXECUTABLE} secp256k1)

26
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -264,7 +264,7 @@ Json::Value WebThreeStubServerBase::eth_blockByHash(std::string const& _hash)
return toJson(client()->blockInfo(jsToFixed<32>(_hash))); return toJson(client()->blockInfo(jsToFixed<32>(_hash)));
} }
Json::Value WebThreeStubServerBase::eth_blockByNumber(int const& _number) Json::Value WebThreeStubServerBase::eth_blockByNumber(int _number)
{ {
return toJson(client()->blockInfo(client()->hashFromNumber(_number))); return toJson(client()->blockInfo(client()->hashFromNumber(_number)));
} }
@ -342,7 +342,7 @@ std::string WebThreeStubServerBase::eth_call(Json::Value const& _json)
return ret; return ret;
} }
Json::Value WebThreeStubServerBase::eth_changed(int const& _id) Json::Value WebThreeStubServerBase::eth_changed(int _id)
{ {
auto entries = client()->checkWatch(_id); auto entries = client()->checkWatch(_id);
if (entries.size()) if (entries.size())
@ -381,7 +381,7 @@ std::string WebThreeStubServerBase::db_get(std::string const& _name, std::string
return toJS(dev::asBytes(ret)); return toJS(dev::asBytes(ret));
} }
Json::Value WebThreeStubServerBase::eth_filterLogs(int const& _id) Json::Value WebThreeStubServerBase::eth_filterLogs(int _id)
{ {
return toJson(client()->logs(_id)); return toJson(client()->logs(_id));
} }
@ -563,13 +563,13 @@ bool WebThreeStubServerBase::eth_setCoinbase(std::string const& _address)
return true; return true;
} }
bool WebThreeStubServerBase::eth_setDefaultBlock(int const& _block) bool WebThreeStubServerBase::eth_setDefaultBlock(int _block)
{ {
client()->setDefault(_block); client()->setDefault(_block);
return true; return true;
} }
bool WebThreeStubServerBase::eth_setListening(bool const& _listening) bool WebThreeStubServerBase::eth_setListening(bool _listening)
{ {
if (_listening) if (_listening)
network()->startNetwork(); network()->startNetwork();
@ -578,7 +578,7 @@ bool WebThreeStubServerBase::eth_setListening(bool const& _listening)
return true; return true;
} }
bool WebThreeStubServerBase::eth_setMining(bool const& _mining) bool WebThreeStubServerBase::eth_setMining(bool _mining)
{ {
if (_mining) if (_mining)
client()->startMining(); client()->startMining();
@ -587,7 +587,7 @@ bool WebThreeStubServerBase::eth_setMining(bool const& _mining)
return true; return true;
} }
Json::Value WebThreeStubServerBase::shh_changed(int const& _id) Json::Value WebThreeStubServerBase::shh_changed(int _id)
{ {
Json::Value ret(Json::arrayValue); Json::Value ret(Json::arrayValue);
auto pub = m_shhWatches[_id]; auto pub = m_shhWatches[_id];
@ -619,7 +619,7 @@ int WebThreeStubServerBase::shh_newFilter(Json::Value const& _json)
return ret; return ret;
} }
bool WebThreeStubServerBase::shh_uninstallFilter(int const& _id) bool WebThreeStubServerBase::shh_uninstallFilter(int _id)
{ {
face()->uninstallWatch(_id); face()->uninstallWatch(_id);
return true; return true;
@ -671,27 +671,27 @@ bool WebThreeStubServerBase::authenticate(TransactionSkeleton const& _t)
return true; return true;
} }
Json::Value WebThreeStubServerBase::eth_transactionByHash(std::string const& _hash, int const& _i) Json::Value WebThreeStubServerBase::eth_transactionByHash(std::string const& _hash, int _i)
{ {
return toJson(client()->transaction(jsToFixed<32>(_hash), _i)); return toJson(client()->transaction(jsToFixed<32>(_hash), _i));
} }
Json::Value WebThreeStubServerBase::eth_transactionByNumber(int const& _number, int const& _i) Json::Value WebThreeStubServerBase::eth_transactionByNumber(int _number, int _i)
{ {
return toJson(client()->transaction(client()->hashFromNumber(_number), _i)); return toJson(client()->transaction(client()->hashFromNumber(_number), _i));
} }
Json::Value WebThreeStubServerBase::eth_uncleByHash(std::string const& _hash, int const& _i) Json::Value WebThreeStubServerBase::eth_uncleByHash(std::string const& _hash, int _i)
{ {
return toJson(client()->uncle(jsToFixed<32>(_hash), _i)); return toJson(client()->uncle(jsToFixed<32>(_hash), _i));
} }
Json::Value WebThreeStubServerBase::eth_uncleByNumber(int const& _number, int const& _i) Json::Value WebThreeStubServerBase::eth_uncleByNumber(int _number, int _i)
{ {
return toJson(client()->uncle(client()->hashFromNumber(_number), _i)); return toJson(client()->uncle(client()->hashFromNumber(_number), _i));
} }
bool WebThreeStubServerBase::eth_uninstallFilter(int const& _id) bool WebThreeStubServerBase::eth_uninstallFilter(int _id)
{ {
client()->uninstallWatch(_id); client()->uninstallWatch(_id);
return true; return true;

26
libweb3jsonrpc/WebThreeStubServerBase.h

@ -69,16 +69,16 @@ public:
virtual Json::Value eth_accounts(); virtual Json::Value eth_accounts();
virtual std::string eth_balanceAt(std::string const& _address); virtual std::string eth_balanceAt(std::string const& _address);
virtual Json::Value eth_blockByHash(std::string const& _hash); virtual Json::Value eth_blockByHash(std::string const& _hash);
virtual Json::Value eth_blockByNumber(int const& _number); virtual Json::Value eth_blockByNumber(int _number);
virtual std::string eth_call(Json::Value const& _json); virtual std::string eth_call(Json::Value const& _json);
virtual Json::Value eth_changed(int const& _id); virtual Json::Value eth_changed(int _id);
virtual std::string eth_codeAt(std::string const& _address); virtual std::string eth_codeAt(std::string const& _address);
virtual std::string eth_coinbase(); virtual std::string eth_coinbase();
virtual Json::Value eth_compilers(); virtual Json::Value eth_compilers();
virtual double eth_countAt(std::string const& _address); virtual double eth_countAt(std::string const& _address);
virtual int eth_defaultBlock(); virtual int eth_defaultBlock();
virtual std::string eth_gasPrice(); virtual std::string eth_gasPrice();
virtual Json::Value eth_filterLogs(int const& _id); virtual Json::Value eth_filterLogs(int _id);
virtual bool eth_flush(); virtual bool eth_flush();
virtual Json::Value eth_logs(Json::Value const& _json); virtual Json::Value eth_logs(Json::Value const& _json);
virtual bool eth_listening(); virtual bool eth_listening();
@ -88,20 +88,20 @@ public:
virtual int eth_number(); virtual int eth_number();
virtual int eth_peerCount(); virtual int eth_peerCount();
virtual bool eth_setCoinbase(std::string const& _address); virtual bool eth_setCoinbase(std::string const& _address);
virtual bool eth_setDefaultBlock(int const& _block); virtual bool eth_setDefaultBlock(int _block);
virtual bool eth_setListening(bool const& _listening); virtual bool eth_setListening(bool _listening);
virtual std::string eth_lll(std::string const& _s); virtual std::string eth_lll(std::string const& _s);
virtual std::string eth_serpent(std::string const& _s); virtual std::string eth_serpent(std::string const& _s);
virtual bool eth_setMining(bool const& _mining); virtual bool eth_setMining(bool _mining);
virtual std::string eth_solidity(std::string const& _code); virtual std::string eth_solidity(std::string const& _code);
virtual std::string eth_stateAt(std::string const& _address, std::string const& _storage); virtual std::string eth_stateAt(std::string const& _address, std::string const& _storage);
virtual Json::Value eth_storageAt(std::string const& _address); virtual Json::Value eth_storageAt(std::string const& _address);
virtual std::string eth_transact(Json::Value const& _json); virtual std::string eth_transact(Json::Value const& _json);
virtual Json::Value eth_transactionByHash(std::string const& _hash, int const& _i); virtual Json::Value eth_transactionByHash(std::string const& _hash, int _i);
virtual Json::Value eth_transactionByNumber(int const& _number, int const& _i); virtual Json::Value eth_transactionByNumber(int _number, int _i);
virtual Json::Value eth_uncleByHash(std::string const& _hash, int const& _i); virtual Json::Value eth_uncleByHash(std::string const& _hash, int _i);
virtual Json::Value eth_uncleByNumber(int const& _number, int const& _i); virtual Json::Value eth_uncleByNumber(int _number, int _i);
virtual bool eth_uninstallFilter(int const& _id); virtual bool eth_uninstallFilter(int _id);
virtual Json::Value eth_getWork(); virtual Json::Value eth_getWork();
virtual bool eth_submitWork(std::string const& _nonce); virtual bool eth_submitWork(std::string const& _nonce);
@ -112,13 +112,13 @@ public:
virtual bool db_putString(std::string const& _name, std::string const& _key, std::string const& _value); virtual bool db_putString(std::string const& _name, std::string const& _key, std::string const& _value);
virtual std::string shh_addToGroup(std::string const& _group, std::string const& _who); virtual std::string shh_addToGroup(std::string const& _group, std::string const& _who);
virtual Json::Value shh_changed(int const& _id); virtual Json::Value shh_changed(int _id);
virtual bool shh_haveIdentity(std::string const& _id); virtual bool shh_haveIdentity(std::string const& _id);
virtual int shh_newFilter(Json::Value const& _json); virtual int shh_newFilter(Json::Value const& _json);
virtual std::string shh_newGroup(std::string const& _id, std::string const& _who); virtual std::string shh_newGroup(std::string const& _id, std::string const& _who);
virtual std::string shh_newIdentity(); virtual std::string shh_newIdentity();
virtual bool shh_post(Json::Value const& _json); virtual bool shh_post(Json::Value const& _json);
virtual bool shh_uninstallFilter(int const& _id); virtual bool shh_uninstallFilter(int _id);
void setAccounts(std::vector<dev::KeyPair> const& _accounts); void setAccounts(std::vector<dev::KeyPair> const& _accounts);
void setIdentities(std::vector<dev::KeyPair> const& _ids); void setIdentities(std::vector<dev::KeyPair> const& _ids);

146
libweb3jsonrpc/abstractwebthreestubserver.h

@ -10,59 +10,59 @@
class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThreeStubServer> class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThreeStubServer>
{ {
public: public:
AbstractWebThreeStubServer(jsonrpc::AbstractServerConnector &conn) : jsonrpc::AbstractServer<AbstractWebThreeStubServer>(conn) AbstractWebThreeStubServer(jsonrpc::AbstractServerConnector &conn, jsonrpc::serverVersion_t type = jsonrpc::JSONRPC_SERVER_V2) : jsonrpc::AbstractServer<AbstractWebThreeStubServer>(conn, type)
{ {
this->bindAndAddMethod(new jsonrpc::Procedure("web3_sha3", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::web3_sha3I); this->bindAndAddMethod(jsonrpc::Procedure("web3_sha3", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::web3_sha3I);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_coinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_coinbaseI); this->bindAndAddMethod(jsonrpc::Procedure("eth_coinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_coinbaseI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_setCoinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_setCoinbaseI); this->bindAndAddMethod(jsonrpc::Procedure("eth_setCoinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_setCoinbaseI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_listeningI); this->bindAndAddMethod(jsonrpc::Procedure("eth_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_listeningI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_setListening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_setListeningI); this->bindAndAddMethod(jsonrpc::Procedure("eth_setListening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_setListeningI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI); this->bindAndAddMethod(jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_setMining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_setMiningI); this->bindAndAddMethod(jsonrpc::Procedure("eth_setMining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_setMiningI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI); this->bindAndAddMethod(jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_accounts", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_accountsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_accounts", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_accountsI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_peerCountI); this->bindAndAddMethod(jsonrpc::Procedure("eth_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_peerCountI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_defaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_defaultBlockI); this->bindAndAddMethod(jsonrpc::Procedure("eth_defaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_defaultBlockI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_setDefaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_setDefaultBlockI); this->bindAndAddMethod(jsonrpc::Procedure("eth_setDefaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_setDefaultBlockI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_number", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_numberI); this->bindAndAddMethod(jsonrpc::Procedure("eth_number", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_numberI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_balanceAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_balanceAtI); this->bindAndAddMethod(jsonrpc::Procedure("eth_balanceAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_balanceAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_stateAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_stateAtI); this->bindAndAddMethod(jsonrpc::Procedure("eth_stateAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_stateAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_storageAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_storageAtI); this->bindAndAddMethod(jsonrpc::Procedure("eth_storageAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_storageAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_countAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_countAtI); this->bindAndAddMethod(jsonrpc::Procedure("eth_countAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_countAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_codeAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_codeAtI); this->bindAndAddMethod(jsonrpc::Procedure("eth_codeAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_codeAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_transact", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_transactI); this->bindAndAddMethod(jsonrpc::Procedure("eth_transact", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_transactI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_call", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_callI); this->bindAndAddMethod(jsonrpc::Procedure("eth_call", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_callI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_flush", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_flushI); this->bindAndAddMethod(jsonrpc::Procedure("eth_flush", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_flushI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_blockByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_blockByHashI); this->bindAndAddMethod(jsonrpc::Procedure("eth_blockByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_blockByHashI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_blockByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_blockByNumberI); this->bindAndAddMethod(jsonrpc::Procedure("eth_blockByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_blockByNumberI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_transactionByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_transactionByHashI); this->bindAndAddMethod(jsonrpc::Procedure("eth_transactionByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_transactionByHashI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_transactionByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_transactionByNumberI); this->bindAndAddMethod(jsonrpc::Procedure("eth_transactionByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_transactionByNumberI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_uncleByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uncleByHashI); this->bindAndAddMethod(jsonrpc::Procedure("eth_uncleByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uncleByHashI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_uncleByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uncleByNumberI); this->bindAndAddMethod(jsonrpc::Procedure("eth_uncleByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uncleByNumberI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_compilers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_compilersI); this->bindAndAddMethod(jsonrpc::Procedure("eth_compilers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_compilersI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_lll", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_lllI); this->bindAndAddMethod(jsonrpc::Procedure("eth_lll", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_lllI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_solidity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_solidityI); this->bindAndAddMethod(jsonrpc::Procedure("eth_solidity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_solidityI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_serpent", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_serpentI); this->bindAndAddMethod(jsonrpc::Procedure("eth_serpent", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_serpentI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterI); this->bindAndAddMethod(jsonrpc::Procedure("eth_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_newFilterString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newFilterStringI); this->bindAndAddMethod(jsonrpc::Procedure("eth_newFilterString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newFilterStringI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uninstallFilterI); this->bindAndAddMethod(jsonrpc::Procedure("eth_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uninstallFilterI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_changed", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_changedI); this->bindAndAddMethod(jsonrpc::Procedure("eth_changed", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_changedI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_filterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_filterLogsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_filterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_filterLogsI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_logs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_logsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_logs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_logsI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_getWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getWorkI); this->bindAndAddMethod(jsonrpc::Procedure("eth_getWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getWorkI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI); this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI);
this->bindAndAddMethod(new jsonrpc::Procedure("db_put", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_putI); this->bindAndAddMethod(jsonrpc::Procedure("db_put", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_putI);
this->bindAndAddMethod(new jsonrpc::Procedure("db_get", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_getI); this->bindAndAddMethod(jsonrpc::Procedure("db_get", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_getI);
this->bindAndAddMethod(new jsonrpc::Procedure("db_putString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_putStringI); this->bindAndAddMethod(jsonrpc::Procedure("db_putString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_putStringI);
this->bindAndAddMethod(new jsonrpc::Procedure("db_getString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_getStringI); this->bindAndAddMethod(jsonrpc::Procedure("db_getString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_getStringI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_post", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::shh_postI); this->bindAndAddMethod(jsonrpc::Procedure("shh_post", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::shh_postI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_newIdentity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_newIdentityI); this->bindAndAddMethod(jsonrpc::Procedure("shh_newIdentity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_newIdentityI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_haveIdentity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_haveIdentityI); this->bindAndAddMethod(jsonrpc::Procedure("shh_haveIdentity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_haveIdentityI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_newGroup", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_newGroupI); this->bindAndAddMethod(jsonrpc::Procedure("shh_newGroup", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_newGroupI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_addToGroup", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_addToGroupI); this->bindAndAddMethod(jsonrpc::Procedure("shh_addToGroup", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_addToGroupI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::shh_newFilterI); this->bindAndAddMethod(jsonrpc::Procedure("shh_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::shh_newFilterI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::shh_uninstallFilterI); this->bindAndAddMethod(jsonrpc::Procedure("shh_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::shh_uninstallFilterI);
this->bindAndAddMethod(new jsonrpc::Procedure("shh_changed", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::shh_changedI); this->bindAndAddMethod(jsonrpc::Procedure("shh_changed", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::shh_changedI);
} }
inline virtual void web3_sha3I(const Json::Value &request, Json::Value &response) inline virtual void web3_sha3I(const Json::Value &request, Json::Value &response)
@ -71,6 +71,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_coinbaseI(const Json::Value &request, Json::Value &response) inline virtual void eth_coinbaseI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_coinbase(); response = this->eth_coinbase();
} }
inline virtual void eth_setCoinbaseI(const Json::Value &request, Json::Value &response) inline virtual void eth_setCoinbaseI(const Json::Value &request, Json::Value &response)
@ -79,6 +80,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_listeningI(const Json::Value &request, Json::Value &response) inline virtual void eth_listeningI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_listening(); response = this->eth_listening();
} }
inline virtual void eth_setListeningI(const Json::Value &request, Json::Value &response) inline virtual void eth_setListeningI(const Json::Value &request, Json::Value &response)
@ -87,6 +89,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_miningI(const Json::Value &request, Json::Value &response) inline virtual void eth_miningI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_mining(); response = this->eth_mining();
} }
inline virtual void eth_setMiningI(const Json::Value &request, Json::Value &response) inline virtual void eth_setMiningI(const Json::Value &request, Json::Value &response)
@ -95,18 +98,22 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_gasPriceI(const Json::Value &request, Json::Value &response) inline virtual void eth_gasPriceI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_gasPrice(); response = this->eth_gasPrice();
} }
inline virtual void eth_accountsI(const Json::Value &request, Json::Value &response) inline virtual void eth_accountsI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_accounts(); response = this->eth_accounts();
} }
inline virtual void eth_peerCountI(const Json::Value &request, Json::Value &response) inline virtual void eth_peerCountI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_peerCount(); response = this->eth_peerCount();
} }
inline virtual void eth_defaultBlockI(const Json::Value &request, Json::Value &response) inline virtual void eth_defaultBlockI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_defaultBlock(); response = this->eth_defaultBlock();
} }
inline virtual void eth_setDefaultBlockI(const Json::Value &request, Json::Value &response) inline virtual void eth_setDefaultBlockI(const Json::Value &request, Json::Value &response)
@ -115,6 +122,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_numberI(const Json::Value &request, Json::Value &response) inline virtual void eth_numberI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_number(); response = this->eth_number();
} }
inline virtual void eth_balanceAtI(const Json::Value &request, Json::Value &response) inline virtual void eth_balanceAtI(const Json::Value &request, Json::Value &response)
@ -147,6 +155,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_flushI(const Json::Value &request, Json::Value &response) inline virtual void eth_flushI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_flush(); response = this->eth_flush();
} }
inline virtual void eth_blockByHashI(const Json::Value &request, Json::Value &response) inline virtual void eth_blockByHashI(const Json::Value &request, Json::Value &response)
@ -175,6 +184,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_compilersI(const Json::Value &request, Json::Value &response) inline virtual void eth_compilersI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_compilers(); response = this->eth_compilers();
} }
inline virtual void eth_lllI(const Json::Value &request, Json::Value &response) inline virtual void eth_lllI(const Json::Value &request, Json::Value &response)
@ -215,6 +225,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void eth_getWorkI(const Json::Value &request, Json::Value &response) inline virtual void eth_getWorkI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->eth_getWork(); response = this->eth_getWork();
} }
inline virtual void eth_submitWorkI(const Json::Value &request, Json::Value &response) inline virtual void eth_submitWorkI(const Json::Value &request, Json::Value &response)
@ -243,6 +254,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
} }
inline virtual void shh_newIdentityI(const Json::Value &request, Json::Value &response) inline virtual void shh_newIdentityI(const Json::Value &request, Json::Value &response)
{ {
(void)request;
response = this->shh_newIdentity(); response = this->shh_newIdentity();
} }
inline virtual void shh_haveIdentityI(const Json::Value &request, Json::Value &response) inline virtual void shh_haveIdentityI(const Json::Value &request, Json::Value &response)
@ -273,14 +285,14 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual std::string eth_coinbase() = 0; virtual std::string eth_coinbase() = 0;
virtual bool eth_setCoinbase(const std::string& param1) = 0; virtual bool eth_setCoinbase(const std::string& param1) = 0;
virtual bool eth_listening() = 0; virtual bool eth_listening() = 0;
virtual bool eth_setListening(const bool& param1) = 0; virtual bool eth_setListening(bool param1) = 0;
virtual bool eth_mining() = 0; virtual bool eth_mining() = 0;
virtual bool eth_setMining(const bool& param1) = 0; virtual bool eth_setMining(bool param1) = 0;
virtual std::string eth_gasPrice() = 0; virtual std::string eth_gasPrice() = 0;
virtual Json::Value eth_accounts() = 0; virtual Json::Value eth_accounts() = 0;
virtual int eth_peerCount() = 0; virtual int eth_peerCount() = 0;
virtual int eth_defaultBlock() = 0; virtual int eth_defaultBlock() = 0;
virtual bool eth_setDefaultBlock(const int& param1) = 0; virtual bool eth_setDefaultBlock(int param1) = 0;
virtual int eth_number() = 0; virtual int eth_number() = 0;
virtual std::string eth_balanceAt(const std::string& param1) = 0; virtual std::string eth_balanceAt(const std::string& param1) = 0;
virtual std::string eth_stateAt(const std::string& param1, const std::string& param2) = 0; virtual std::string eth_stateAt(const std::string& param1, const std::string& param2) = 0;
@ -291,20 +303,20 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual std::string eth_call(const Json::Value& param1) = 0; virtual std::string eth_call(const Json::Value& param1) = 0;
virtual bool eth_flush() = 0; virtual bool eth_flush() = 0;
virtual Json::Value eth_blockByHash(const std::string& param1) = 0; virtual Json::Value eth_blockByHash(const std::string& param1) = 0;
virtual Json::Value eth_blockByNumber(const int& param1) = 0; virtual Json::Value eth_blockByNumber(int param1) = 0;
virtual Json::Value eth_transactionByHash(const std::string& param1, const int& param2) = 0; virtual Json::Value eth_transactionByHash(const std::string& param1, int param2) = 0;
virtual Json::Value eth_transactionByNumber(const int& param1, const int& param2) = 0; virtual Json::Value eth_transactionByNumber(int param1, int param2) = 0;
virtual Json::Value eth_uncleByHash(const std::string& param1, const int& param2) = 0; virtual Json::Value eth_uncleByHash(const std::string& param1, int param2) = 0;
virtual Json::Value eth_uncleByNumber(const int& param1, const int& param2) = 0; virtual Json::Value eth_uncleByNumber(int param1, int param2) = 0;
virtual Json::Value eth_compilers() = 0; virtual Json::Value eth_compilers() = 0;
virtual std::string eth_lll(const std::string& param1) = 0; virtual std::string eth_lll(const std::string& param1) = 0;
virtual std::string eth_solidity(const std::string& param1) = 0; virtual std::string eth_solidity(const std::string& param1) = 0;
virtual std::string eth_serpent(const std::string& param1) = 0; virtual std::string eth_serpent(const std::string& param1) = 0;
virtual int eth_newFilter(const Json::Value& param1) = 0; virtual int eth_newFilter(const Json::Value& param1) = 0;
virtual int eth_newFilterString(const std::string& param1) = 0; virtual int eth_newFilterString(const std::string& param1) = 0;
virtual bool eth_uninstallFilter(const int& param1) = 0; virtual bool eth_uninstallFilter(int param1) = 0;
virtual Json::Value eth_changed(const int& param1) = 0; virtual Json::Value eth_changed(int param1) = 0;
virtual Json::Value eth_filterLogs(const int& param1) = 0; virtual Json::Value eth_filterLogs(int param1) = 0;
virtual Json::Value eth_logs(const Json::Value& param1) = 0; virtual Json::Value eth_logs(const Json::Value& param1) = 0;
virtual Json::Value eth_getWork() = 0; virtual Json::Value eth_getWork() = 0;
virtual bool eth_submitWork(const std::string& param1) = 0; virtual bool eth_submitWork(const std::string& param1) = 0;
@ -318,8 +330,8 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual std::string shh_newGroup(const std::string& param1, const std::string& param2) = 0; virtual std::string shh_newGroup(const std::string& param1, const std::string& param2) = 0;
virtual std::string shh_addToGroup(const std::string& param1, const std::string& param2) = 0; virtual std::string shh_addToGroup(const std::string& param1, const std::string& param2) = 0;
virtual int shh_newFilter(const Json::Value& param1) = 0; virtual int shh_newFilter(const Json::Value& param1) = 0;
virtual bool shh_uninstallFilter(const int& param1) = 0; virtual bool shh_uninstallFilter(int param1) = 0;
virtual Json::Value shh_changed(const int& param1) = 0; virtual Json::Value shh_changed(int param1) = 0;
}; };
#endif //JSONRPC_CPP_ABSTRACTWEBTHREESTUBSERVER_H_ #endif //JSONRPC_CPP_STUB_ABSTRACTWEBTHREESTUBSERVER_H_

2
mix/Web3Server.cpp

@ -55,7 +55,7 @@ void Web3Server::put(std::string const& _name, std::string const& _key, std::str
m_db[k] = _value; m_db[k] = _value;
} }
Json::Value Web3Server::eth_changed(int const& _id) Json::Value Web3Server::eth_changed(int _id)
{ {
return WebThreeStubServerBase::eth_changed(_id); return WebThreeStubServerBase::eth_changed(_id);
} }

2
mix/Web3Server.h

@ -44,7 +44,7 @@ signals:
void newTransaction(); void newTransaction();
protected: protected:
virtual Json::Value eth_changed(int const& _id) override; virtual Json::Value eth_changed(int _id) override;
virtual std::string eth_transact(Json::Value const& _json) override; virtual std::string eth_transact(Json::Value const& _json) override;
virtual std::string eth_call(Json::Value const& _json) override; virtual std::string eth_call(Json::Value const& _json) override;

3
mix/qml/CodeEditorView.qml

@ -19,7 +19,8 @@ Item {
function isDocumentOpen(documentId) { function isDocumentOpen(documentId) {
for (var i = 0; i < editorListModel.count; i++) for (var i = 0; i < editorListModel.count; i++)
if (editorListModel.get(i).documentId === documentId) if (editorListModel.get(i).documentId === documentId &&
editors.itemAt(i).item)
return true; return true;
return false; return false;
} }

4
mix/qml/Debugger.qml

@ -598,9 +598,11 @@ Rectangle {
Layout.minimumWidth: parent.width / 2 Layout.minimumWidth: parent.width / 2
Layout.maximumWidth: parent.width / 2 Layout.maximumWidth: parent.width / 2
Text { Text {
maximumLineCount: 1
clip: true
anchors.leftMargin: 5 anchors.leftMargin: 5
width: parent.width - 5 width: parent.width - 5
wrapMode: Text.NoWrap wrapMode: Text.WrapAnywhere
anchors.left: parent.left anchors.left: parent.left
font.family: "monospace" font.family: "monospace"
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter

124
mix/qml/WebPreview.qml

@ -6,6 +6,7 @@ import QtQuick.Controls.Styles 1.1
import QtWebEngine 1.0 import QtWebEngine 1.0
import QtWebEngine.experimental 1.0 import QtWebEngine.experimental 1.0
import HttpServer 1.0 import HttpServer 1.0
import "."
Item { Item {
id: webPreview id: webPreview
@ -38,7 +39,7 @@ Item {
function updateDocument(documentId, action) { function updateDocument(documentId, action) {
for (var i = 0; i < pageListModel.count; i++) for (var i = 0; i < pageListModel.count; i++)
if (pageListModel.get(i).documentId === i) if (pageListModel.get(i).documentId === documentId)
action(i); action(i);
} }
@ -82,10 +83,22 @@ Item {
onDocumentRemoved: { onDocumentRemoved: {
updateDocument(documentId, function(i) { pageListModel.remove(i) } ) updateDocument(documentId, function(i) { pageListModel.remove(i) } )
} }
onDocumentUpdated: { onDocumentUpdated: {
updateDocument(documentId, function(i) { pageListModel.set(i, projectModel.getDocument(documentId)) } ) updateDocument(documentId, function(i) { pageListModel.set(i, projectModel.getDocument(documentId)) } )
} }
onDocumentOpened: {
if (!document.isHtml)
return;
for (var i = 0; i < pageListModel.count; i++) {
var doc = pageListModel.get(i);
if (doc.documentId === document.documentId) {
pageCombo.currentIndex = i;
}
}
}
onProjectLoading: { onProjectLoading: {
for (var i = 0; i < target.listModel.count; i++) { for (var i = 0; i < target.listModel.count; i++) {
var document = target.listModel.get(i); var document = target.listModel.get(i);
@ -146,45 +159,86 @@ Item {
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: 0
RowLayout { Rectangle
anchors.top: parent.top {
Layout.fillWidth: true; SourceSansProLight
Text { {
text: qsTr("Page") id: regularFont
}
ComboBox {
id: pageCombo
model: pageListModel
textRole: "name"
currentIndex: -1
onCurrentIndexChanged: changePage()
}
Button {
text: qsTr("Reload")
onClicked: reload()
} }
CheckBox {
id: autoReloadOnSave anchors.leftMargin: 4
checked: true color: WebPreviewStyle.general.headerBackgroundColor
text: qsTr("Auto reload on save") Layout.preferredWidth: parent.width
Layout.preferredHeight: 32
Row {
anchors.top: parent.top
anchors.fill: parent
anchors.leftMargin: 3
spacing: 3
DefaultLabel {
text: qsTr("Preview of")
anchors.verticalCenter: parent.verticalCenter
}
ComboBox {
id: pageCombo
model: pageListModel
textRole: "name"
currentIndex: -1
onCurrentIndexChanged: changePage()
anchors.verticalCenter: parent.verticalCenter
style: ComboBoxStyle {
font: regularFont.name
}
}
Action {
tooltip: qsTr("Reload")
id: buttonReloadAction
onTriggered: {
reload();
}
}
Button {
iconSource: "qrc:/qml/img/available_updates.png"
action: buttonReloadAction
anchors.verticalCenter: parent.verticalCenter
width: 26
height: 26
}
CheckBox {
id: autoReloadOnSave
checked: true
anchors.verticalCenter: parent.verticalCenter
style: CheckBoxStyle {
label: DefaultLabel {
text: qsTr("Auto reload on save")
}
}
}
} }
} }
WebEngineView { Rectangle
Layout.fillWidth: true {
Layout.preferredWidth: parent.width
Layout.fillHeight: true Layout.fillHeight: true
id: webView WebEngineView {
experimental.settings.localContentCanAccessRemoteUrls: true anchors.fill: parent
onJavaScriptConsoleMessage: { id: webView
console.log(sourceID + ":" + lineNumber + ":" + message); experimental.settings.localContentCanAccessRemoteUrls: true
} onJavaScriptConsoleMessage: {
onLoadingChanged: { console.log(sourceID + ":" + lineNumber + ":" + message);
if (!loading) { }
initialized = true; onLoadingChanged: {
webView.runJavaScript("init(\"" + httpServer.url + "/rpc/\")"); if (!loading) {
if (pendingPageUrl) initialized = true;
setPreviewUrl(pendingPageUrl); webView.runJavaScript("init(\"" + httpServer.url + "/rpc/\")");
if (pendingPageUrl)
setPreviewUrl(pendingPageUrl);
}
} }
} }
} }

14
mix/qml/WebPreviewStyle.qml

@ -0,0 +1,14 @@
pragma Singleton
import QtQuick 2.0
QtObject {
function absoluteSize(rel)
{
return systemPointSize + rel;
}
property QtObject general: QtObject {
property string headerBackgroundColor: "#f0f0f0"
}
}

BIN
mix/qml/img/available_updates.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

1
mix/qml/qmldir

@ -4,3 +4,4 @@ singleton ProjectFilesStyle 1.0 ProjectFilesStyle.qml
singleton DebuggerPaneStyle 1.0 DebuggerPaneStyle.qml singleton DebuggerPaneStyle 1.0 DebuggerPaneStyle.qml
singleton StateStyle 1.0 StateStyle.qml singleton StateStyle 1.0 StateStyle.qml
singleton StatusPaneStyle 1.0 StatusPaneStyle.qml singleton StatusPaneStyle 1.0 StatusPaneStyle.qml
singleton WebPreviewStyle 1.0 WebPreviewStyle.qml

2
mix/res.qrc

@ -97,5 +97,7 @@
<file>qml/DefaultTextField.qml</file> <file>qml/DefaultTextField.qml</file>
<file>qml/CommonSeparator.qml</file> <file>qml/CommonSeparator.qml</file>
<file>qml/Style.qml</file> <file>qml/Style.qml</file>
<file>qml/WebPreviewStyle.qml</file>
<file>qml/img/available_updates.png</file>
</qresource> </qresource>
</RCC> </RCC>

17
test/PerformaceTester.sol

@ -0,0 +1,17 @@
contract PerformanceTester {
function ackermann(uint m, uint n) returns (uint) {
if (m == 0)
return n + 1;
if (n == 0)
return ackermann(m - 1, 1);
return ackermann(m - 1, ackermann(m, n - 1));
}
function fibonacci(uint n) returns (uint) {
if (n == 0 || n == 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
}

20
test/SolidityEndToEndTest.cpp

@ -2499,6 +2499,26 @@ BOOST_AUTO_TEST_CASE(struct_copy_via_local)
BOOST_CHECK(callContractFunction("test()") == encodeArgs(true)); BOOST_CHECK(callContractFunction("test()") == encodeArgs(true));
} }
BOOST_AUTO_TEST_CASE(using_enums)
{
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
{
choices = ActionChoices.GoStraight;
}
function getChoice() returns (uint d)
{
d = uint256(choices);
}
ActionChoices choices;
}
)";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("getChoice()") == encodeArgs(2));
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

91
test/SolidityNameAndTypeResolution.cpp

@ -992,6 +992,97 @@ BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big)
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
} }
BOOST_AUTO_TEST_CASE(enum_member_access)
{
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
{
choices = ActionChoices.GoStraight;
}
ActionChoices choices;
}
)";
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
}
BOOST_AUTO_TEST_CASE(enum_invalid_member_access)
{
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
{
choices = ActionChoices.RunAroundWavingYourHands;
}
ActionChoices choices;
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay)
{
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
{
a = uint256(ActionChoices.GoStraight);
b = uint64(ActionChoices.Sit);
}
uint256 a;
uint64 b;
}
)";
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
}
BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay)
{
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
{
a = 2;
b = ActionChoices(a);
}
uint256 a;
ActionChoices b;
}
)";
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
}
BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay)
{
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function test()
{
a = ActionChoices.GoStraight;
b = ActionChoices.Sit;
}
uint256 a;
uint64 b;
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
BOOST_AUTO_TEST_CASE(enum_duplicate_values)
{
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoLeft, Sit }
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

32
test/SolidityParser.cpp

@ -703,6 +703,38 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expression
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); BOOST_CHECK_NO_THROW(parseTextExplainError(text));
} }
BOOST_AUTO_TEST_CASE(enum_valid_declaration)
{
char const* text = R"(
contract c {
enum validEnum { Value1, Value2, Value3, Value4 }
function c ()
{
a = foo.Value3;
}
uint256 a;
})";
BOOST_CHECK_NO_THROW(parseTextExplainError(text));
}
BOOST_AUTO_TEST_CASE(empty_enum_declaration)
{
char const* text = R"(
contract c {
enum foo { }
})";
BOOST_CHECK_NO_THROW(parseTextExplainError(text));
}
BOOST_AUTO_TEST_CASE(malformed_enum_declaration)
{
char const* text = R"(
contract c {
enum foo { WARNING,}
})";
BOOST_CHECK_THROW(parseText(text), ParserError);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

4
test/vm.cpp

@ -525,7 +525,7 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest)
dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests);
auto end = chrono::steady_clock::now(); auto end = chrono::steady_clock::now();
chrono::milliseconds duration(chrono::duration_cast<chrono::milliseconds>(end - start)); auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n"; cnote << "test duration: " << duration.count() << " milliseconds.\n";
} }
} }
@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(vmInputLimitsTest1)
dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests);
auto end = chrono::steady_clock::now(); auto end = chrono::steady_clock::now();
chrono::milliseconds duration(chrono::duration_cast<chrono::milliseconds>(end - start)); auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n"; cnote << "test duration: " << duration.count() << " milliseconds.\n";
} }
} }

131
test/vmPerformanceTestFiller.json

@ -1,4 +1,62 @@
{ {
"ackermann31": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "100000000000",
"currentDifficulty" : "256",
"currentTimestamp" : "1",
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"//" : "PerformanceTester.sol",
"code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"//" : "ackermann(3, 1)",
"data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"ackermann32": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "100000000000",
"currentDifficulty" : "256",
"currentTimestamp" : "1",
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"//" : "PerformanceTester.sol",
"code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"//" : "ackermann(3, 2)",
"data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002",
"gasPrice" : "100000000000000",
"gas" : "100000"
}
},
"ackermann33": { "ackermann33": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@ -12,16 +70,8 @@
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : "0", "nonce" : "0",
"//" : "contract PerformanceTester {", "//" : "PerformanceTester.sol",
"//" : " function ackermann(uint m, uint n) returns (uint) {", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056",
"//" : " if (m == 0)",
"//" : " return n + 1;",
"//" : " if (n == 0)",
"//" : " return ackermann(m - 1, 1);",
"//" : " return ackermann(m - 1, ackermann(m, n - 1));",
"//" : " }",
"//" : "}",
"code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056",
"storage": {} "storage": {}
} }
}, },
@ -30,9 +80,68 @@
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000", "value" : "1000000000000000000",
"//" : "ackermann(3, 3)",
"data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003", "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003",
"gasPrice" : "100000000000000", "gasPrice" : "100000000000000",
"gas" : "100000000000" "gas" : "100000"
}
},
"fibonacci10": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "100000000000",
"currentDifficulty" : "256",
"currentTimestamp" : "1",
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"//" : "PerformanceTester.sol",
"code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"//" : "fibonacci(10)",
"data" : "0x61047ff4000000000000000000000000000000000000000000000000000000000000000a",
"gasPrice" : "100000000000000",
"gas" : "100000"
}
},
"fibonacci16": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "100000000000",
"currentDifficulty" : "256",
"currentTimestamp" : "1",
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"//" : "PerformanceTester.sol",
"code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"//" : "fibonacci(16)",
"data" : "0x61047ff40000000000000000000000000000000000000000000000000000000000000010",
"gasPrice" : "100000000000000",
"gas" : "100000000"
} }
} }
} }

30
test/webthreestubclient.h

@ -10,7 +10,7 @@
class WebThreeStubClient : public jsonrpc::Client class WebThreeStubClient : public jsonrpc::Client
{ {
public: public:
WebThreeStubClient(jsonrpc::IClientConnector &conn) : jsonrpc::Client(conn) {} WebThreeStubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {}
std::string web3_sha3(const std::string& param1) throw (jsonrpc::JsonRpcException) std::string web3_sha3(const std::string& param1) throw (jsonrpc::JsonRpcException)
{ {
@ -52,7 +52,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
bool eth_setListening(const bool& param1) throw (jsonrpc::JsonRpcException) bool eth_setListening(bool param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -72,7 +72,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
bool eth_setMining(const bool& param1) throw (jsonrpc::JsonRpcException) bool eth_setMining(bool param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -122,7 +122,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
bool eth_setDefaultBlock(const int& param1) throw (jsonrpc::JsonRpcException) bool eth_setDefaultBlock(int param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -233,7 +233,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_blockByNumber(const int& param1) throw (jsonrpc::JsonRpcException) Json::Value eth_blockByNumber(int param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -243,7 +243,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_transactionByHash(const std::string& param1, const int& param2) throw (jsonrpc::JsonRpcException) Json::Value eth_transactionByHash(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -254,7 +254,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_transactionByNumber(const int& param1, const int& param2) throw (jsonrpc::JsonRpcException) Json::Value eth_transactionByNumber(int param1, int param2) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -265,7 +265,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_uncleByHash(const std::string& param1, const int& param2) throw (jsonrpc::JsonRpcException) Json::Value eth_uncleByHash(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -276,7 +276,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_uncleByNumber(const int& param1, const int& param2) throw (jsonrpc::JsonRpcException) Json::Value eth_uncleByNumber(int param1, int param2) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -347,7 +347,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
bool eth_uninstallFilter(const int& param1) throw (jsonrpc::JsonRpcException) bool eth_uninstallFilter(int param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -357,7 +357,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_changed(const int& param1) throw (jsonrpc::JsonRpcException) Json::Value eth_changed(int param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -367,7 +367,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_filterLogs(const int& param1) throw (jsonrpc::JsonRpcException) Json::Value eth_filterLogs(int param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -515,7 +515,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
bool shh_uninstallFilter(const int& param1) throw (jsonrpc::JsonRpcException) bool shh_uninstallFilter(int param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -525,7 +525,7 @@ class WebThreeStubClient : public jsonrpc::Client
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value shh_changed(const int& param1) throw (jsonrpc::JsonRpcException) Json::Value shh_changed(int param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
@ -537,4 +537,4 @@ class WebThreeStubClient : public jsonrpc::Client
} }
}; };
#endif //JSONRPC_CPP_WEBTHREESTUBCLIENT_H_ #endif //JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_

Loading…
Cancel
Save