aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md2
-rw-r--r--libdevcore/CommonIO.cpp5
-rw-r--r--libdevcore/SwarmHash.cpp4
-rw-r--r--libevmasm/Instruction.h20
-rw-r--r--libevmasm/PeepholeOptimiser.cpp5
-rw-r--r--libsolidity/ast/AST.cpp12
-rw-r--r--libsolidity/ast/Types.cpp5
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp5
-rw-r--r--lllc/main.cpp6
-rw-r--r--solc/jsonCompiler.cpp10
-rw-r--r--solc/jsonCompiler.h42
-rw-r--r--test/ExecutionFramework.cpp6
-rw-r--r--test/fuzzer.cpp9
-rw-r--r--test/libsolidity/JSONCompiler.cpp11
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp20
15 files changed, 123 insertions, 39 deletions
diff --git a/Changelog.md b/Changelog.md
index 49855369..4af4419d 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -5,9 +5,9 @@ Features:
* Type Checker: Warn on using literals as tight packing parameters in ``keccak256``, ``sha3``, ``sha256`` and ``ripemd160``.
Bugfixes:
+ * ABI JSON: Include all overloaded events.
* Parser: Crash fix related to parseTypeName.
-
### 0.4.16 (2017-08-24)
Features:
diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp
index 52829455..5d47937b 100644
--- a/libdevcore/CommonIO.cpp
+++ b/libdevcore/CommonIO.cpp
@@ -35,6 +35,9 @@
using namespace std;
using namespace dev;
+namespace
+{
+
template <typename _T>
inline _T contentsGeneric(std::string const& _file)
{
@@ -56,6 +59,8 @@ inline _T contentsGeneric(std::string const& _file)
return ret;
}
+}
+
string dev::contentsString(string const& _file)
{
return contentsGeneric<string>(_file);
diff --git a/libdevcore/SwarmHash.cpp b/libdevcore/SwarmHash.cpp
index 78188668..1c718200 100644
--- a/libdevcore/SwarmHash.cpp
+++ b/libdevcore/SwarmHash.cpp
@@ -24,6 +24,8 @@
using namespace std;
using namespace dev;
+namespace
+{
bytes toLittleEndian(size_t _size)
{
@@ -59,6 +61,8 @@ h256 swarmHashIntermediate(string const& _input, size_t _offset, size_t _length)
return swarmHashSimple(ref, _length);
}
+}
+
h256 dev::swarmHash(string const& _input)
{
return swarmHashIntermediate(_input, 0, _input.size());
diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h
index 89a25fb7..afbef71d 100644
--- a/libevmasm/Instruction.h
+++ b/libevmasm/Instruction.h
@@ -87,13 +87,6 @@ enum class Instruction: uint8_t
DIFFICULTY, ///< get the block's difficulty
GASLIMIT, ///< get the block's gas limit
- JUMPTO = 0x4a, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
- JUMPIF, ///< conditionally alter the program counter -- not part of Instructions.cpp
- JUMPV, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
- JUMPSUB, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
- JUMPSUBV, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
- RETURNSUB, ///< return to subroutine jumped from -- not part of Instructions.cpp
-
POP = 0x50, ///< remove item from stack
MLOAD, ///< load word from memory
MSTORE, ///< save word to memory
@@ -106,8 +99,6 @@ enum class Instruction: uint8_t
MSIZE, ///< get the size of active memory
GAS, ///< get the amount of available gas
JUMPDEST, ///< set a potential jump destination
- BEGINSUB, ///< set a potential jumpsub destination -- not part of Instructions.cpp
- BEGINDATA, ///< begine the data section -- not part of Instructions.cpp
PUSH1 = 0x60, ///< place 1 byte item on stack
PUSH2, ///< place 2 byte item on stack
@@ -182,6 +173,17 @@ enum class Instruction: uint8_t
LOG3, ///< Makes a log entry; 3 topics.
LOG4, ///< Makes a log entry; 4 topics.
+ JUMPTO = 0xb0, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
+ JUMPIF, ///< conditionally alter the program counter -- not part of Instructions.cpp
+ JUMPV, ///< alter the program counter to a jumpdest -- not part of Instructions.cpp
+ JUMPSUB, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
+ JUMPSUBV, ///< alter the program counter to a beginsub -- not part of Instructions.cpp
+ BEGINSUB, ///< set a potential jumpsub destination -- not part of Instructions.cpp
+ BEGINDATA, ///< begin the data section -- not part of Instructions.cpp
+ RETURNSUB, ///< return to subroutine jumped from -- not part of Instructions.cpp
+ PUTLOCAL, ///< pop top of stack to local variable -- not part of Instructions.cpp
+ GETLOCAL, ///< push local variable to top of stack -- not part of Instructions.cpp
+
CREATE = 0xf0, ///< create a new account with associated code
CALL, ///< message-call into an account
CALLCODE, ///< message-call with another account's code only
diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp
index e94a8ba4..31fdd317 100644
--- a/libevmasm/PeepholeOptimiser.cpp
+++ b/libevmasm/PeepholeOptimiser.cpp
@@ -30,6 +30,9 @@ using namespace dev;
// TODO: Extend this to use the tools from ExpressionClasses.cpp
+namespace
+{
+
struct OptimiserState
{
AssemblyItems const& items;
@@ -246,6 +249,8 @@ void applyMethods(OptimiserState& _state, Method, OtherMethods... _other)
applyMethods(_state, _other...);
}
+}
+
bool PeepholeOptimiser::optimise()
{
OptimiserState state {m_items, 0, std::back_inserter(m_optimisedItems)};
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 2e4ae72a..a805322b 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -176,11 +176,19 @@ vector<EventDefinition const*> const& ContractDefinition::interfaceEvents() cons
m_interfaceEvents.reset(new vector<EventDefinition const*>());
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
for (EventDefinition const* e: contract->events())
- if (eventsSeen.count(e->name()) == 0)
+ {
+ /// NOTE: this requires the "internal" version of an Event,
+ /// though here internal strictly refers to visibility,
+ /// and not to function encoding (jump vs. call)
+ auto const& function = e->functionType(true);
+ solAssert(function, "");
+ string eventSignature = function->externalSignature();
+ if (eventsSeen.count(eventSignature) == 0)
{
- eventsSeen.insert(e->name());
+ eventsSeen.insert(eventSignature);
m_interfaceEvents->push_back(e);
}
+ }
}
return *m_interfaceEvents;
}
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 22751c45..10424858 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -304,6 +304,9 @@ MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition
return members;
}
+namespace
+{
+
bool isValidShiftAndAmountType(Token::Value _operator, Type const& _shiftAmountType)
{
// Disable >>> here.
@@ -317,6 +320,8 @@ bool isValidShiftAndAmountType(Token::Value _operator, Type const& _shiftAmountT
return false;
}
+}
+
IntegerType::IntegerType(int _bits, IntegerType::Modifier _modifier):
m_bits(_bits), m_modifier(_modifier)
{
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index e53f1b94..24d3d959 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -39,6 +39,9 @@ using namespace std;
using namespace dev;
using namespace dev::solidity;
+namespace
+{
+
/**
* Simple helper class to ensure that the stack height is the same at certain places in the code.
*/
@@ -53,6 +56,8 @@ private:
unsigned stackHeight;
};
+}
+
void ContractCompiler::compileContract(
ContractDefinition const& _contract,
std::map<const ContractDefinition*, eth::Assembly const*> const& _contracts
diff --git a/lllc/main.cpp b/lllc/main.cpp
index adf181c7..06a0fc81 100644
--- a/lllc/main.cpp
+++ b/lllc/main.cpp
@@ -39,7 +39,7 @@ static string const VersionString =
(string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) +
(string(SOL_VERSION_BUILDINFO).empty() ? "" : "+" + string(SOL_VERSION_BUILDINFO));
-void help()
+static void help()
{
cout
<< "Usage lllc [OPTIONS] <file>" << endl
@@ -54,7 +54,7 @@ void help()
exit(0);
}
-void version()
+static void version()
{
cout << "LLLC, the Lovely Little Language Compiler " << endl;
cout << "Version: " << VersionString << endl;
@@ -74,7 +74,7 @@ specified default locale if it is valid, and if not then it will modify the
environment the process is running in to use a sensible default. This also means
that users do not need to install language packs for their OS.
*/
-void setDefaultOrCLocale()
+static void setDefaultOrCLocale()
{
#if __unix__
if (!std::setlocale(LC_ALL, ""))
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index 684d49e4..7e797a62 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -20,24 +20,20 @@
* JSON interface for the solidity compiler to be used from Javascript.
*/
-#include <string>
+#include <solc/jsonCompiler.h>
#include <libdevcore/Common.h>
#include <libdevcore/JSON.h>
#include <libsolidity/interface/StandardCompiler.h>
#include <libsolidity/interface/Version.h>
+#include <string>
+
#include "license.h"
using namespace std;
using namespace dev;
using namespace solidity;
-extern "C" {
-/// Callback used to retrieve additional source files. "Returns" two pointers that should be
-/// heap-allocated and are free'd by the caller.
-typedef void (*CStyleReadFileCallback)(char const* _path, char** o_contents, char** o_error);
-}
-
namespace
{
diff --git a/solc/jsonCompiler.h b/solc/jsonCompiler.h
new file mode 100644
index 00000000..c392ce93
--- /dev/null
+++ b/solc/jsonCompiler.h
@@ -0,0 +1,42 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @author Christian <c@ethdev.com>
+ * @date 2014
+ * JSON interface for the solidity compiler to be used from Javascript.
+ */
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// Callback used to retrieve additional source files. "Returns" two pointers that should be
+/// heap-allocated and are free'd by the caller.
+typedef void (*CStyleReadFileCallback)(char const* _path, char** o_contents, char** o_error);
+
+char const* license();
+char const* version();
+char const* compileJSON(char const* _input, bool _optimize);
+char const* compileJSONMulti(char const* _input, bool _optimize);
+char const* compileJSONCallback(char const* _input, bool _optimize, CStyleReadFileCallback _readCallback);
+char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp
index f4e5fcef..b2de814a 100644
--- a/test/ExecutionFramework.cpp
+++ b/test/ExecutionFramework.cpp
@@ -31,8 +31,8 @@ using namespace dev::test;
namespace // anonymous
{
- h256 const EmptyTrie("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421");
-}
+
+h256 const EmptyTrie("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421");
string getIPCSocketPath()
{
@@ -43,6 +43,8 @@ string getIPCSocketPath()
return ipcPath;
}
+}
+
ExecutionFramework::ExecutionFramework() :
m_rpc(RPCSession::instance(getIPCSocketPath())),
m_optimize(dev::test::Options::get().optimize),
diff --git a/test/fuzzer.cpp b/test/fuzzer.cpp
index cf99755f..2c39dde2 100644
--- a/test/fuzzer.cpp
+++ b/test/fuzzer.cpp
@@ -20,6 +20,7 @@
#include <libevmasm/Assembly.h>
#include <libevmasm/ConstantOptimiser.h>
+#include <solc/jsonCompiler.h>
#include <json/json.h>
@@ -33,12 +34,8 @@ using namespace dev;
using namespace dev::eth;
namespace po = boost::program_options;
-extern "C"
+namespace
{
-extern char const* compileJSON(char const* _input, bool _optimize);
-typedef void (*CStyleReadFileCallback)(char const* _path, char** o_contents, char** o_error);
-extern char const* compileStandard(char const* _input, CStyleReadFileCallback _readCallback);
-}
bool quiet = false;
@@ -169,6 +166,8 @@ void testCompiler()
}
}
+}
+
int main(int argc, char** argv)
{
po::options_description options(
diff --git a/test/libsolidity/JSONCompiler.cpp b/test/libsolidity/JSONCompiler.cpp
index 541cfbf0..7dc4808b 100644
--- a/test/libsolidity/JSONCompiler.cpp
+++ b/test/libsolidity/JSONCompiler.cpp
@@ -23,22 +23,13 @@
#include <boost/test/unit_test.hpp>
#include <libdevcore/JSON.h>
#include <libsolidity/interface/Version.h>
+#include <solc/jsonCompiler.h>
#include "../Metadata.h"
#include "../TestHelper.h"
using namespace std;
-extern "C"
-{
-extern char const* version();
-extern char const* license();
-extern char const* compileJSON(char const* _input, bool _optimize);
-extern char const* compileJSONMulti(char const* _input, bool _optimize);
-extern char const* compileJSONCallback(char const* _input, bool _optimize, void* _readCallback);
-extern char const* compileStandard(char const* _input, void* _readCallback);
-}
-
namespace dev
{
namespace solidity
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index 0512ba1f..4b9223de 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -423,6 +423,8 @@ BOOST_AUTO_TEST_CASE(events)
function f(uint a) returns(uint d) { return a * 7; }
event e1(uint b, address indexed c);
event e2();
+ event e2(uint a);
+ event e3() anonymous;
}
)";
char const* interface = R"([
@@ -467,6 +469,24 @@ BOOST_AUTO_TEST_CASE(events)
"type": "event",
"anonymous": false,
"inputs": []
+ },
+ {
+ "name": "e2",
+ "type": "event",
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": false,
+ "name": "a",
+ "type": "uint256"
+ }
+ ]
+ },
+ {
+ "name": "e3",
+ "type": "event",
+ "anonymous": true,
+ "inputs": []
}
])";