aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md1
-rw-r--r--docs/index.rst3
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp8
-rw-r--r--solc/jsonCompiler.cpp92
4 files changed, 65 insertions, 39 deletions
diff --git a/Changelog.md b/Changelog.md
index 18ca861c..bd8d924f 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -40,6 +40,7 @@ Bugfixes:
* JSON AST: nodes were added at wrong parent
* Why3 translator: crash fix for exponentiation
* Type Checker: Fallback function cannot return data anymore.
+ * Code Generator: Fix crash when sha3() was used on unsupported types.
Lots of changes to the documentation mainly by voluntary external contributors.
diff --git a/docs/index.rst b/docs/index.rst
index a5ab3f86..4e90dd43 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -46,6 +46,9 @@ Available Solidity Integrations
* `Atom Solidity Linter <https://atom.io/packages/linter-solidity>`_
Plugin for the Atom editor that provides Solidity linting.
+
+* `Solium <https://github.com/duaraghav8/Solium/>`_
+ A commandline linter for Solidity which strictly follows the rules prescribed by the `Solidity Style Guide <http://solidity.readthedocs.io/en/latest/style-guide.html>`_.
* `Visual Studio Code extension <http://juan.blanco.ws/solidity-contracts-in-visual-studio-code/>`_
Solidity plugin for Microsoft Visual Studio Code that includes syntax highlighting and the Solidity compiler.
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index d7d17b8e..ec496df8 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -160,7 +160,15 @@ void CompilerUtils::encodeToMemory(
TypePointers targetTypes = _targetTypes.empty() ? _givenTypes : _targetTypes;
solAssert(targetTypes.size() == _givenTypes.size(), "");
for (TypePointer& t: targetTypes)
+ {
+ solAssert(
+ t->mobileType() &&
+ t->mobileType()->interfaceType(_encodeAsLibraryTypes) &&
+ t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType(),
+ "Encoding type \"" + t->toString() + "\" not yet implemented."
+ );
t = t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType();
+ }
// Stack during operation:
// <v1> <v2> ... <vn> <mem_start> <dyn_head_1> ... <dyn_head_r> <end_of_mem>
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index 5cdee2e2..671b8c0f 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -203,51 +203,65 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
if (success)
{
- output["contracts"] = Json::Value(Json::objectValue);
- for (string const& contractName: compiler.contractNames())
+ try
{
- Json::Value contractData(Json::objectValue);
- contractData["interface"] = compiler.interface(contractName);
- contractData["bytecode"] = compiler.object(contractName).toHex();
- contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex();
- contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode);
- contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName));
- contractData["gasEstimates"] = estimateGas(compiler, contractName);
- auto sourceMap = compiler.sourceMapping(contractName);
- contractData["srcmap"] = sourceMap ? *sourceMap : "";
- auto runtimeSourceMap = compiler.runtimeSourceMapping(contractName);
- contractData["srcmapRuntime"] = runtimeSourceMap ? *runtimeSourceMap : "";
- ostringstream unused;
- contractData["assembly"] = compiler.streamAssembly(unused, contractName, _sources, true);
- output["contracts"][contractName] = contractData;
- }
+ output["contracts"] = Json::Value(Json::objectValue);
+ for (string const& contractName: compiler.contractNames())
+ {
+ Json::Value contractData(Json::objectValue);
+ contractData["interface"] = compiler.interface(contractName);
+ contractData["bytecode"] = compiler.object(contractName).toHex();
+ contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex();
+ contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode);
+ contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName));
+ contractData["gasEstimates"] = estimateGas(compiler, contractName);
+ auto sourceMap = compiler.sourceMapping(contractName);
+ contractData["srcmap"] = sourceMap ? *sourceMap : "";
+ auto runtimeSourceMap = compiler.runtimeSourceMapping(contractName);
+ contractData["srcmapRuntime"] = runtimeSourceMap ? *runtimeSourceMap : "";
+ ostringstream unused;
+ contractData["assembly"] = compiler.streamAssembly(unused, contractName, _sources, true);
+ output["contracts"][contractName] = contractData;
+ }
+
+ // Do not taint the internal error list
+ ErrorList formalErrors;
+ if (compiler.prepareFormalAnalysis(&formalErrors))
+ output["formal"]["why3"] = compiler.formalTranslation();
+ if (!formalErrors.empty())
+ {
+ Json::Value errors(Json::arrayValue);
+ for (auto const& error: formalErrors)
+ errors.append(formatError(
+ *error,
+ (error->type() == Error::Type::Warning) ? "Warning" : "Error",
+ scannerFromSourceName
+ ));
+ output["formal"]["errors"] = errors;
+ }
- // Do not taint the internal error list
- ErrorList formalErrors;
- if (compiler.prepareFormalAnalysis(&formalErrors))
- output["formal"]["why3"] = compiler.formalTranslation();
- if (!formalErrors.empty())
+ // Indices into this array are used to abbreviate source names in source locations.
+ output["sourceList"] = Json::Value(Json::arrayValue);
+ for (auto const& source: compiler.sourceNames())
+ output["sourceList"].append(source);
+ output["sources"] = Json::Value(Json::objectValue);
+ for (auto const& source: compiler.sourceNames())
+ output["sources"][source]["AST"] = ASTJsonConverter(compiler.ast(source), compiler.sourceIndices()).json();
+ }
+ catch (...)
{
- Json::Value errors(Json::arrayValue);
- for (auto const& error: formalErrors)
- errors.append(formatError(
- *error,
- (error->type() == Error::Type::Warning) ? "Warning" : "Error",
- scannerFromSourceName
- ));
- output["formal"]["errors"] = errors;
+ output["errors"].append("Unknown exception while generating compiler output.");
}
-
- // Indices into this array are used to abbreviate source names in source locations.
- output["sourceList"] = Json::Value(Json::arrayValue);
- for (auto const& source: compiler.sourceNames())
- output["sourceList"].append(source);
- output["sources"] = Json::Value(Json::objectValue);
- for (auto const& source: compiler.sourceNames())
- output["sources"][source]["AST"] = ASTJsonConverter(compiler.ast(source), compiler.sourceIndices()).json();
}
- return Json::FastWriter().write(output);
+ try
+ {
+ return Json::FastWriter().write(output);
+ }
+ catch (...)
+ {
+ return "{\"errors\":[\"Unknown error while generating JSON.\"]}";
+ }
}
string compileMulti(string const& _input, bool _optimize, CStyleReadFileCallback _readCallback = nullptr)