Skip to content

Commit 822622c

Browse files
committed
Merge remote-tracking branch 'origin/develop' into release
2 parents 2dabbdf + 3a692e3 commit 822622c

180 files changed

Lines changed: 6420 additions & 3176 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
# http://solidity.readthedocs.org
77
#
88
# ------------------------------------------------------------------------------
9-
# This file is part of cpp-ethereum.
9+
# This file is part of solidity.
1010
#
11-
# cpp-ethereum is free software: you can redistribute it and/or modify
11+
# solidity is free software: you can redistribute it and/or modify
1212
# it under the terms of the GNU General Public License as published by
1313
# the Free Software Foundation, either version 3 of the License, or
1414
# (at your option) any later version.
1515
#
16-
# cpp-ethereum is distributed in the hope that it will be useful,
16+
# solidity is distributed in the hope that it will be useful,
1717
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1818
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1919
# GNU General Public License for more details.
2020
#
2121
# You should have received a copy of the GNU General Public License
22-
# along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>
22+
# along with solidity. If not, see <http://www.gnu.org/licenses/>
2323
#
24-
# (c) 2016 cpp-ethereum contributors.
24+
# (c) 2016 solidity contributors.
2525
#------------------------------------------------------------------------------
2626

2727
language: cpp

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include(EthPolicy)
88
eth_policy()
99

1010
# project name and version should be set after cmake_policy CMP0048
11-
set(PROJECT_VERSION "0.4.6")
11+
set(PROJECT_VERSION "0.4.7")
1212
project(solidity VERSION ${PROJECT_VERSION})
1313

1414
# Let's find our dependencies

Changelog.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
### 0.4.7 (2016-12-15)
2+
3+
Features:
4+
* Bitshift operators.
5+
* Type checker: Warn when ``msg.value`` is used in non-payable function.
6+
* Code generator: Inject the Swarm hash of a metadata file into the bytecode.
7+
* Code generator: Replace expensive memcpy precompile by simple assembly loop.
8+
* Optimizer: Some dead code elimination.
9+
10+
Bugfixes:
11+
* Code generator: throw if calling the identity precompile failed during memory (array) copying.
12+
* Type checker: string literals that are not valid UTF-8 cannot be converted to string type
13+
* Code generator: any non-zero value given as a boolean argument is now converted into 1.
14+
* AST Json Converter: replace ``VariableDefinitionStatement`` nodes with ``VariableDeclarationStatement``
15+
* AST Json Converter: fix the camel case in ``ElementaryTypeNameExpression``
16+
* AST Json Converter: replace ``public`` field with ``visibility`` in the function definition nodes
17+
118
### 0.4.6 (2016-11-22)
219

320
Bugfixes:
4-
* Optimizer: Knowledge about state was not correctly cleared for JUMPDESTs
21+
* Optimizer: Knowledge about state was not correctly cleared for JUMPDESTs (introduced in 0.4.5)
522

623
### 0.4.5 (2016-11-21)
724

appveyor.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
# sockets unconditionally at the time of writing.
1010
#
1111
# ------------------------------------------------------------------------------
12-
# This file is part of cpp-ethereum.
12+
# This file is part of solidity.
1313
#
14-
# cpp-ethereum is free software: you can redistribute it and/or modify
14+
# solidity is free software: you can redistribute it and/or modify
1515
# it under the terms of the GNU General Public License as published by
1616
# the Free Software Foundation, either version 3 of the License, or
1717
# (at your option) any later version.
1818
#
19-
# cpp-ethereum is distributed in the hope that it will be useful,
19+
# solidity is distributed in the hope that it will be useful,
2020
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2121
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2222
# GNU General Public License for more details.
2323
#
2424
# You should have received a copy of the GNU General Public License
25-
# along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>
25+
# along with solidity. If not, see <http://www.gnu.org/licenses/>
2626
#
27-
# (c) 2016 cpp-ethereum contributors.
27+
# (c) 2016 solidity contributors.
2828
#------------------------------------------------------------------------------
2929

3030
branches:

cmake/EthCompilerSettings.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
155155

156156
if (EMSCRIPTEN)
157157
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --memory-init-file 0 -O3 -s LINKABLE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_DYNAMIC_EXECUTION=1")
158+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
159+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
160+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NO_FILESYSTEM=1 -s AGGRESSIVE_VARIABLE_ELIMINATION=1")
158161
add_definitions(-DETH_EMSCRIPTEN=1)
159162
endif()
160163
endif()

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def setup(sphinx):
5656
# built documents.
5757
#
5858
# The short X.Y version.
59-
version = '0.4.6'
59+
version = '0.4.7'
6060
# The full version, including alpha/beta/rc tags.
61-
release = '0.4.6-develop'
61+
release = '0.4.7-develop'
6262

6363
# The language for content autogenerated by Sphinx. Refer to documentation
6464
# for a list of supported languages.

docs/contracts.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,10 @@ Details are given in the following example.
721721
NameReg(config.lookup(1)).register(name);
722722
}
723723

724-
// Functions can be overridden, both local and
725-
// message-based function calls take these overrides
724+
// Functions can be overridden by another function with the same name and
725+
// the same number/types of inputs. If the overriding function has different
726+
// types of output parameters, that causes an error.
727+
// Both local and message-based function calls take these overrides
726728
// into account.
727729
function kill() {
728730
if (msg.sender == owner) {

docs/contributing.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,18 @@ for this project. Also, even though we do CI testing, please test your code and
5959
ensure that it builds locally before submitting a pull request.
6060

6161
Thank you for your help!
62+
63+
Running the compiler tests
64+
==========================
65+
66+
Solidity includes different types of tests. They are included in the application
67+
called ``soltest``. Some of them require the ``cpp-ethereum`` client in testing mode.
68+
69+
To run ``cpp-ethereum`` in testing mode: ``eth --test -d /tmp/testeth``.
70+
71+
To run the tests: ``soltest -- --ipcpath /tmp/testeth/geth.ipc``.
72+
73+
To run a subset of tests, filters can be used:
74+
``soltest -t TestSuite/TestName -- --ipcpath /tmp/testeth/geth.ipc``, where ``TestName`` can be a wildcard ``*``.
75+
76+
Alternatively, there is a testing script at ``scripts/test.sh`` which executes all tests.

docs/control-structures.rst

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,62 @@
22
Expressions and Control Structures
33
##################################
44

5+
.. index:: ! parameter, parameter;input, parameter;output
6+
7+
Input Parameters and Output Parameters
8+
======================================
9+
10+
As in Javascript, functions may take parameters as input;
11+
unlike in Javascript and C, they may also return arbitrary number of
12+
parameters as output.
13+
14+
Input Parameters
15+
----------------
16+
17+
The input parameters are declared the same way as variables are. As an
18+
exception, unused parameters can omit the variable name.
19+
For example, suppose we want our contract to
20+
accept one kind of external calls with two integers, we would write
21+
something like::
22+
23+
contract Simple {
24+
function taker(uint _a, uint _b) {
25+
// do something with _a and _b.
26+
}
27+
}
28+
29+
Output Parameters
30+
-----------------
31+
32+
The output parameters can be declared with the same syntax after the
33+
``returns`` keyword. For example, suppose we wished to return two results:
34+
the sum and the product of the two given integers, then we would
35+
write::
36+
37+
contract Simple {
38+
function arithmetics(uint _a, uint _b) returns (uint o_sum, uint o_product) {
39+
o_sum = _a + _b;
40+
o_product = _a * _b;
41+
}
42+
}
43+
44+
The names of output parameters can be omitted.
45+
The output values can also be specified using ``return`` statements.
46+
The ``return`` statements are also capable of returning multiple
47+
values, see :ref:`multi-return`.
48+
Return parameters are initialized to zero; if they are not explicitly
49+
set, they stay to be zero.
50+
51+
Input parameters and output parameters can be used as expressions in
52+
the function body. There, they are also usable in the left-hand side
53+
of assignment.
54+
555
.. index:: if, else, while, do/while, for, break, continue, return, switch, goto
656

757
Control Structures
858
===================
959

10-
Most of the control structures from C or JavaScript are available in Solidity
60+
Most of the control structures from JavaScript are available in Solidity
1161
except for ``switch`` and ``goto``. So
1262
there is: ``if``, ``else``, ``while``, ``do``, ``for``, ``break``, ``continue``, ``return``, ``? :``, with
1363
the usual semantics known from C or JavaScript.
@@ -16,7 +66,17 @@ Parentheses can *not* be omitted for conditionals, but curly brances can be omit
1666
around single-statement bodies.
1767

1868
Note that there is no type conversion from non-boolean to boolean types as
19-
there is in C and JavaScript, so ``if (1) { ... }`` is *not* valid Solidity.
69+
there is in C and JavaScript, so ``if (1) { ... }`` is *not* valid
70+
Solidity.
71+
72+
.. _multi-return:
73+
74+
Returning Multiple Values
75+
-------------------------
76+
77+
When a function has multiple output parameters, ``return (v0, v1, ...,
78+
vn)`` can return multiple values. The number of components must be
79+
the same as the number of output parameters.
2080

2181
.. index:: ! function;call, function;internal, function;external
2282

@@ -322,17 +382,18 @@ In the following example, we show how ``throw`` can be used to easily revert an
322382
}
323383
}
324384

325-
Currently, there are situations, where exceptions happen automatically in Solidity:
385+
Currently, Solidity automatically generates a runtime exception in the following situations:
326386

327387
1. If you access an array at a too large or negative index (i.e. ``x[i]`` where ``i >= x.length`` or ``i < 0``).
328-
2. If you access a fixed-length ``bytesN`` at a too large or negative index.
329-
3. If you call a function via a message call but it does not finish properly (i.e. it runs out of gas, has no matching function, or throws an exception itself), except when a low level operation ``call``, ``send``, ``delegatecall`` or ``callcode`` is used. The low level operations never throw exceptions but indicate failures by returning ``false``.
330-
4. If you create a contract using the ``new`` keyword but the contract creation does not finish properly (see above for the definition of "not finish properly").
331-
5. If you divide or modulo by zero (e.g. ``5 / 0`` or ``23 % 0``).
332-
6. If you convert a value too big or negative into an enum type.
333-
7. If you perform an external function call targeting a contract that contains no code.
334-
8. If your contract receives Ether via a public function without ``payable`` modifier (including the constructor and the fallback function).
335-
9. If your contract receives Ether via a public accessor function.
388+
1. If you access a fixed-length ``bytesN`` at a too large or negative index.
389+
1. If you call a function via a message call but it does not finish properly (i.e. it runs out of gas, has no matching function, or throws an exception itself), except when a low level operation ``call``, ``send``, ``delegatecall`` or ``callcode`` is used. The low level operations never throw exceptions but indicate failures by returning ``false``.
390+
1. If you create a contract using the ``new`` keyword but the contract creation does not finish properly (see above for the definition of "not finish properly").
391+
1. If you divide or modulo by zero (e.g. ``5 / 0`` or ``23 % 0``).
392+
1. If you shift by a negative amount.
393+
1. If you convert a value too big or negative into an enum type.
394+
1. If you perform an external function call targeting a contract that contains no code.
395+
1. If your contract receives Ether via a public function without ``payable`` modifier (including the constructor and the fallback function).
396+
1. If your contract receives Ether via a public accessor function.
336397

337398
Internally, Solidity performs an "invalid jump" when an exception is thrown and thus causes the EVM to revert all changes made to the state. The reason for this is that there is no safe way to continue execution, because an expected effect did not occur. Because we want to retain the atomicity of transactions, the safest thing to do is to revert all changes and make the whole transaction (or at least call) without effect.
338399

0 commit comments

Comments
 (0)