diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Changelog.md | 14 | ||||
-rw-r--r-- | docs/bugs_by_version.json | 4 | ||||
-rw-r--r-- | libjulia/AsmDataForward.h | 52 | ||||
-rw-r--r-- | libjulia/backends/evm/EVMAssembly.cpp | 2 | ||||
-rw-r--r-- | libjulia/backends/evm/EVMCodeTransform.cpp | 19 | ||||
-rw-r--r-- | libjulia/backends/evm/EVMCodeTransform.h | 43 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 4 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmData.h | 2 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmDataForward.h | 3 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 4 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmPrinter.cpp | 6 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmScopeFiller.cpp | 6 | ||||
-rwxr-xr-x | scripts/docker_deploy_manual.sh | 49 |
15 files changed, 163 insertions, 49 deletions
diff --git a/.travis.yml b/.travis.yml index a2301c42..708d3620 100644 --- a/.travis.yml +++ b/.travis.yml @@ -184,10 +184,8 @@ before_script: script: - test $SOLC_EMSCRIPTEN != On || (scripts/test_emscripten.sh) - - test $? == 0 || SOLC_STOREBYTECODE=Off - test $SOLC_DOCS != On || (scripts/docs.sh) - test $SOLC_TESTS != On || (cd $TRAVIS_BUILD_DIR && scripts/tests.sh) - - test $? == 0 || SOLC_STOREBYTECODE=Off - test $SOLC_STOREBYTECODE != On || (cd $TRAVIS_BUILD_DIR && scripts/bytecodecompare/storebytecode.sh) deploy: diff --git a/CMakeLists.txt b/CMakeLists.txt index 24bea3b3..105de851 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.4.19") +set(PROJECT_VERSION "0.4.20") project(solidity VERSION ${PROJECT_VERSION}) option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF) diff --git a/Changelog.md b/Changelog.md index 8f610a53..fd256af8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,14 +1,20 @@ -### 0.4.19 (unreleased) +### 0.4.20 (unreleased) + +Features: + +Bugfixes: + +### 0.4.19 (2017-11-30) Features: - * Allow constant variables to be used as array length * Code Generator: New ABI decoder which supports structs and arbitrarily nested - arrays and checks input size (activate using ``pragma experimental ABIEncoderV2;``. + arrays and checks input size (activate using ``pragma experimental ABIEncoderV2;``). + * General: Allow constant variables to be used as array length. + * Inline Assembly: ``if`` statement. * Standard JSON: Support the ``outputSelection`` field for selective compilation of target artifacts. * Syntax Checker: Turn the usage of ``callcode`` into an error as experimental 0.5.0 feature. * Type Checker: Improve address checksum warning. * Type Checker: More detailed errors for invalid array lengths (such as division by zero). - * Inline Assembly: ``if`` statement. Bugfixes: diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index cca45428..3a8ff9a1 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -397,6 +397,10 @@ "bugs": [], "released": "2017-10-18" }, + "0.4.19": { + "bugs": [], + "released": "2017-11-30" + }, "0.4.2": { "bugs": [ "ZeroFunctionSelector", diff --git a/libjulia/AsmDataForward.h b/libjulia/AsmDataForward.h new file mode 100644 index 00000000..3806e321 --- /dev/null +++ b/libjulia/AsmDataForward.h @@ -0,0 +1,52 @@ +/* + 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/>. +*/ +/** + * @date 2017 + * Pull in some identifiers from the solidity::assembly namespace. + */ + +#pragma once + +#include <libsolidity/inlineasm/AsmDataForward.h> + +namespace dev +{ +namespace julia +{ + +using Instruction = solidity::assembly::Instruction; +using Literal = solidity::assembly::Literal; +using Label = solidity::assembly::Label; +using StackAssignment = solidity::assembly::StackAssignment; +using Identifier = solidity::assembly::Identifier; +using Assignment = solidity::assembly::Assignment; +using VariableDeclaration = solidity::assembly::VariableDeclaration; +using FunctionalInstruction = solidity::assembly::FunctionalInstruction; +using FunctionDefinition = solidity::assembly::FunctionDefinition; +using FunctionCall = solidity::assembly::FunctionCall; +using If = solidity::assembly::If; +using Case = solidity::assembly::Case; +using Switch = solidity::assembly::Switch; +using ForLoop = solidity::assembly::ForLoop; +using Block = solidity::assembly::Block; + +using TypedName = solidity::assembly::TypedName; + +using Statement = boost::variant<Instruction, Literal, Label, StackAssignment, Identifier, Assignment, FunctionCall, FunctionalInstruction, VariableDeclaration, FunctionDefinition, If, Switch, ForLoop, Block>; + +} +} diff --git a/libjulia/backends/evm/EVMAssembly.cpp b/libjulia/backends/evm/EVMAssembly.cpp index 1d499b20..07ad05c9 100644 --- a/libjulia/backends/evm/EVMAssembly.cpp +++ b/libjulia/backends/evm/EVMAssembly.cpp @@ -26,7 +26,7 @@ using namespace std; using namespace dev; -using namespace julia; +using namespace dev::julia; namespace { diff --git a/libjulia/backends/evm/EVMCodeTransform.cpp b/libjulia/backends/evm/EVMCodeTransform.cpp index 13d9d011..733e39e9 100644 --- a/libjulia/backends/evm/EVMCodeTransform.cpp +++ b/libjulia/backends/evm/EVMCodeTransform.cpp @@ -31,7 +31,8 @@ using namespace std; using namespace dev; using namespace dev::julia; using namespace dev::solidity; -using namespace dev::solidity::assembly; + +using Scope = dev::solidity::assembly::Scope; void CodeTransform::operator()(VariableDeclaration const& _varDecl) { @@ -289,7 +290,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) solAssert(m_info.scopes.at(&_function.body), ""); Scope* varScope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get(); solAssert(varScope, ""); - for (auto const& v: _function.arguments | boost::adaptors::reversed) + for (auto const& v: _function.parameters | boost::adaptors::reversed) { auto& var = boost::get<Scope::Variable>(varScope->identifiers.at(v.name)); m_context->variableStackHeights[&var] = height++; @@ -302,7 +303,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) if (m_evm15) { m_assembly.appendJumpTo(afterFunction, -stackHeightBefore); - m_assembly.appendBeginsub(functionEntryID(_function.name, function), _function.arguments.size()); + m_assembly.appendBeginsub(functionEntryID(_function.name, function), _function.parameters.size()); } else { @@ -311,7 +312,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) } m_stackAdjustment += localStackAdjustment; - for (auto const& v: _function.returns) + for (auto const& v: _function.returnVariables) { auto& var = boost::get<Scope::Variable>(varScope->identifiers.at(v.name)); m_context->variableStackHeights[&var] = height++; @@ -341,9 +342,9 @@ void CodeTransform::operator()(FunctionDefinition const& _function) // modified parallel to the actual stack. vector<int> stackLayout; if (!m_evm15) - stackLayout.push_back(_function.returns.size()); // Move return label to the top - stackLayout += vector<int>(_function.arguments.size(), -1); // discard all arguments - for (size_t i = 0; i < _function.returns.size(); ++i) + stackLayout.push_back(_function.returnVariables.size()); // Move return label to the top + stackLayout += vector<int>(_function.parameters.size(), -1); // discard all arguments + for (size_t i = 0; i < _function.returnVariables.size(); ++i) stackLayout.push_back(i); // Move return values down, but keep order. solAssert(stackLayout.size() <= 17, "Stack too deep"); @@ -363,9 +364,9 @@ void CodeTransform::operator()(FunctionDefinition const& _function) } if (m_evm15) - m_assembly.appendReturnsub(_function.returns.size(), stackHeightBefore); + m_assembly.appendReturnsub(_function.returnVariables.size(), stackHeightBefore); else - m_assembly.appendJump(stackHeightBefore - _function.returns.size()); + m_assembly.appendJump(stackHeightBefore - _function.returnVariables.size()); m_stackAdjustment -= localStackAdjustment; m_assembly.appendLabel(afterFunction); checkStackHeight(&_function); diff --git a/libjulia/backends/evm/EVMCodeTransform.h b/libjulia/backends/evm/EVMCodeTransform.h index 387720a2..e4cb20ed 100644 --- a/libjulia/backends/evm/EVMCodeTransform.h +++ b/libjulia/backends/evm/EVMCodeTransform.h @@ -20,8 +20,9 @@ #include <libjulia/backends/evm/EVMAssembly.h> +#include <libjulia/AsmDataForward.h> + #include <libsolidity/inlineasm/AsmScope.h> -#include <libsolidity/inlineasm/AsmDataForward.h> #include <boost/variant.hpp> #include <boost/optional.hpp> @@ -95,38 +96,38 @@ protected: {} public: - void operator()(solidity::assembly::Instruction const& _instruction); - void operator()(solidity::assembly::Literal const& _literal); - void operator()(solidity::assembly::Identifier const& _identifier); - void operator()(solidity::assembly::FunctionalInstruction const& _instr); - void operator()(solidity::assembly::FunctionCall const&); - void operator()(solidity::assembly::Label const& _label); - void operator()(solidity::assembly::StackAssignment const& _assignment); - void operator()(solidity::assembly::Assignment const& _assignment); - void operator()(solidity::assembly::VariableDeclaration const& _varDecl); - void operator()(solidity::assembly::If const& _if); - void operator()(solidity::assembly::Switch const& _switch); - void operator()(solidity::assembly::FunctionDefinition const&); - void operator()(solidity::assembly::ForLoop const&); - void operator()(solidity::assembly::Block const& _block); + void operator()(Instruction const& _instruction); + void operator()(Literal const& _literal); + void operator()(Identifier const& _identifier); + void operator()(FunctionalInstruction const& _instr); + void operator()(FunctionCall const&); + void operator()(Label const& _label); + void operator()(StackAssignment const& _assignment); + void operator()(Assignment const& _assignment); + void operator()(VariableDeclaration const& _varDecl); + void operator()(If const& _if); + void operator()(Switch const& _switch); + void operator()(FunctionDefinition const&); + void operator()(ForLoop const&); + void operator()(Block const& _block); private: - AbstractAssembly::LabelID labelFromIdentifier(solidity::assembly::Identifier const& _identifier); + AbstractAssembly::LabelID labelFromIdentifier(Identifier const& _identifier); /// @returns the label ID corresponding to the given label, allocating a new one if /// necessary. AbstractAssembly::LabelID labelID(solidity::assembly::Scope::Label const& _label); AbstractAssembly::LabelID functionEntryID(std::string const& _name, solidity::assembly::Scope::Function const& _function); /// Generates code for an expression that is supposed to return a single value. - void visitExpression(solidity::assembly::Statement const& _expression); + void visitExpression(Statement const& _expression); - void visitStatements(std::vector<solidity::assembly::Statement> const& _statements); + void visitStatements(std::vector<Statement> const& _statements); /// Pops all variables declared in the block and checks that the stack height is equal /// to @a _blackStartStackHeight. - void finalizeBlock(solidity::assembly::Block const& _block, int _blockStartStackHeight); + void finalizeBlock(Block const& _block, int _blockStartStackHeight); - void generateMultiAssignment(std::vector<solidity::assembly::Identifier> const& _variableNames); - void generateAssignment(solidity::assembly::Identifier const& _variableName); + void generateMultiAssignment(std::vector<Identifier> const& _variableNames); + void generateAssignment(Identifier const& _variableName); /// Determines the stack height difference to the given variables. Throws /// if it is not yet in scope or the height difference is too large. Returns diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index 2804ddfc..c55355e2 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -217,14 +217,14 @@ bool AsmAnalyzer::operator()(assembly::FunctionDefinition const& _funDef) Block const* virtualBlock = m_info.virtualBlocks.at(&_funDef).get(); solAssert(virtualBlock, ""); Scope& varScope = scope(virtualBlock); - for (auto const& var: _funDef.arguments + _funDef.returns) + for (auto const& var: _funDef.parameters + _funDef.returnVariables) { expectValidType(var.type, var.location); m_activeVariables.insert(&boost::get<Scope::Variable>(varScope.identifiers.at(var.name))); } int const stackHeight = m_stackHeight; - m_stackHeight = _funDef.arguments.size() + _funDef.returns.size(); + m_stackHeight = _funDef.parameters.size() + _funDef.returnVariables.size(); bool success = (*this)(_funDef.body); diff --git a/libsolidity/inlineasm/AsmData.h b/libsolidity/inlineasm/AsmData.h index a792a1b8..e1753af4 100644 --- a/libsolidity/inlineasm/AsmData.h +++ b/libsolidity/inlineasm/AsmData.h @@ -67,7 +67,7 @@ struct VariableDeclaration { SourceLocation location; TypedNameList variables; s /// Block that creates a scope (frees declared stack variables) struct Block { SourceLocation location; std::vector<Statement> statements; }; /// Function definition ("function f(a, b) -> (d, e) { ... }") -struct FunctionDefinition { SourceLocation location; std::string name; TypedNameList arguments; TypedNameList returns; Block body; }; +struct FunctionDefinition { SourceLocation location; std::string name; TypedNameList parameters; TypedNameList returnVariables; Block body; }; /// Conditional execution without "else" part. struct If { SourceLocation location; std::shared_ptr<Statement> condition; Block body; }; /// Switch case or default case diff --git a/libsolidity/inlineasm/AsmDataForward.h b/libsolidity/inlineasm/AsmDataForward.h index d627b41a..1ab62cc0 100644 --- a/libsolidity/inlineasm/AsmDataForward.h +++ b/libsolidity/inlineasm/AsmDataForward.h @@ -43,9 +43,12 @@ struct FunctionDefinition; struct FunctionCall; struct If; struct Switch; +struct Case; struct ForLoop; struct Block; +struct TypedName; + using Statement = boost::variant<Instruction, Literal, Label, StackAssignment, Identifier, Assignment, FunctionCall, FunctionalInstruction, VariableDeclaration, FunctionDefinition, If, Switch, ForLoop, Block>; } diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index 8f171005..1555804b 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -419,7 +419,7 @@ assembly::FunctionDefinition Parser::parseFunctionDefinition() expectToken(Token::LParen); while (currentToken() != Token::RParen) { - funDef.arguments.emplace_back(parseTypedName()); + funDef.parameters.emplace_back(parseTypedName()); if (currentToken() == Token::RParen) break; expectToken(Token::Comma); @@ -431,7 +431,7 @@ assembly::FunctionDefinition Parser::parseFunctionDefinition() expectToken(Token::GreaterThan); while (true) { - funDef.returns.emplace_back(parseTypedName()); + funDef.returnVariables.emplace_back(parseTypedName()); if (currentToken() == Token::LBrace) break; expectToken(Token::Comma); diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp index 0f183244..804fb1d5 100644 --- a/libsolidity/inlineasm/AsmPrinter.cpp +++ b/libsolidity/inlineasm/AsmPrinter.cpp @@ -144,17 +144,17 @@ string AsmPrinter::operator()(assembly::FunctionDefinition const& _functionDefin { string out = "function " + _functionDefinition.name + "("; out += boost::algorithm::join( - _functionDefinition.arguments | boost::adaptors::transformed( + _functionDefinition.parameters | boost::adaptors::transformed( [this](TypedName argument) { return argument.name + appendTypeName(argument.type); } ), ", " ); out += ")"; - if (!_functionDefinition.returns.empty()) + if (!_functionDefinition.returnVariables.empty()) { out += " -> "; out += boost::algorithm::join( - _functionDefinition.returns | boost::adaptors::transformed( + _functionDefinition.returnVariables | boost::adaptors::transformed( [this](TypedName argument) { return argument.name + appendTypeName(argument.type); } ), ", " diff --git a/libsolidity/inlineasm/AsmScopeFiller.cpp b/libsolidity/inlineasm/AsmScopeFiller.cpp index 77ae9102..0984e7d2 100644 --- a/libsolidity/inlineasm/AsmScopeFiller.cpp +++ b/libsolidity/inlineasm/AsmScopeFiller.cpp @@ -71,10 +71,10 @@ bool ScopeFiller::operator()(assembly::FunctionDefinition const& _funDef) { bool success = true; vector<Scope::JuliaType> arguments; - for (auto const& _argument: _funDef.arguments) + for (auto const& _argument: _funDef.parameters) arguments.push_back(_argument.type); vector<Scope::JuliaType> returns; - for (auto const& _return: _funDef.returns) + for (auto const& _return: _funDef.returnVariables) returns.push_back(_return.type); if (!m_currentScope->registerFunction(_funDef.name, arguments, returns)) { @@ -91,7 +91,7 @@ bool ScopeFiller::operator()(assembly::FunctionDefinition const& _funDef) varScope.superScope = m_currentScope; m_currentScope = &varScope; varScope.functionScope = true; - for (auto const& var: _funDef.arguments + _funDef.returns) + for (auto const& var: _funDef.parameters + _funDef.returnVariables) if (!registerVariable(var, _funDef.location, varScope)) success = false; diff --git a/scripts/docker_deploy_manual.sh b/scripts/docker_deploy_manual.sh new file mode 100755 index 00000000..c098f4ee --- /dev/null +++ b/scripts/docker_deploy_manual.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env sh + +set -e + +if [ -z "$1" ] +then + echo "Usage: $0 <tag/branch>" + exit 1 +fi +branch="$1" + +#docker login + +DIR=$(mktemp -d) +( +cd "$DIR" + +git clone --depth 2 https://github.com/ethereum/solidity.git -b "$branch" +cd solidity +commithash=$(git rev-parse --short=8 HEAD) +echo -n "$commithash" > commit_hash.txt +version=$($(dirname "$0")/get_version.sh) +if [ "$branch" = "release" -o "$branch" = v"$version" ] +then + echo -n > prerelease.txt +else + date -u +"nightly.%Y.%-m.%-d" > prerelease.txt +fi + +rm -rf .git +docker build -t ethereum/solc:build -f scripts/Dockerfile . +tmp_container=$(docker create ethereum/solc:build sh) +if [ "$branch" = "develop" ] +then + docker tag ethereum/solc:build ethereum/solc:nightly; + docker tag ethereum/solc:build ethereum/solc:nightly-"$version"-"$commithash" + docker push ethereum/solc:nightly-"$version"-"$commithash"; + docker push ethereum/solc:nightly; +elif [ "$branch" = v"$version" ] +then + docker tag ethereum/solc:build ethereum/solc:stable; + docker tag ethereum/solc:build ethereum/solc:"$version"; + docker push ethereum/solc:stable; + docker push ethereum/solc:"$version"; +else + echo "Not publishing docker image from branch or tag $branch" +fi +) +rm -rf "$DIR" |