aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-01-30 03:06:02 +0800
committerGitHub <noreply@github.com>2018-01-30 03:06:02 +0800
commitcc1c461fc05255f0efc3a36f6c90336092c66aae (patch)
tree4806779c50b3b2d2b35a79a82e07e9deb2328f4e /docs
parentbd3692f1e69c3c1954c09bd7cb964b5e62450989 (diff)
parentb517ebb8bcb9494a55ecbcc0ea99b1e372d1219a (diff)
downloaddexon-solidity-cc1c461fc05255f0efc3a36f6c90336092c66aae.tar
dexon-solidity-cc1c461fc05255f0efc3a36f6c90336092c66aae.tar.gz
dexon-solidity-cc1c461fc05255f0efc3a36f6c90336092c66aae.tar.bz2
dexon-solidity-cc1c461fc05255f0efc3a36f6c90336092c66aae.tar.lz
dexon-solidity-cc1c461fc05255f0efc3a36f6c90336092c66aae.tar.xz
dexon-solidity-cc1c461fc05255f0efc3a36f6c90336092c66aae.tar.zst
dexon-solidity-cc1c461fc05255f0efc3a36f6c90336092c66aae.zip
Merge pull request #3447 from fulldecent/patch-7
Fix new Solidity warnings, for #3379
Diffstat (limited to 'docs')
-rw-r--r--docs/assembly.rst18
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/assembly.rst b/docs/assembly.rst
index 825892b3..afc44d66 100644
--- a/docs/assembly.rst
+++ b/docs/assembly.rst
@@ -54,7 +54,7 @@ idea is that assembly libraries will be used to enhance the language in such way
pragma solidity ^0.4.0;
library GetCode {
- function at(address _addr) public returns (bytes o_code) {
+ function at(address _addr) public view returns (bytes o_code) {
assembly {
// retrieve the size of the code, this needs assembly
let size := extcodesize(_addr)
@@ -78,12 +78,12 @@ you really know what you are doing.
.. code::
- pragma solidity ^0.4.12;
+ pragma solidity ^0.4.16;
library VectorSum {
// This function is less efficient because the optimizer currently fails to
// remove the bounds checks in array access.
- function sumSolidity(uint[] _data) public returns (uint o_sum) {
+ function sumSolidity(uint[] _data) public view returns (uint o_sum) {
for (uint i = 0; i < _data.length; ++i)
o_sum += _data[i];
}
@@ -91,7 +91,7 @@ you really know what you are doing.
// We know that we only access the array in bounds, so we can avoid the check.
// 0x20 needs to be added to an array because the first slot contains the
// array length.
- function sumAsm(uint[] _data) public returns (uint o_sum) {
+ function sumAsm(uint[] _data) public view returns (uint o_sum) {
for (uint i = 0; i < _data.length; ++i) {
assembly {
o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))
@@ -100,7 +100,7 @@ you really know what you are doing.
}
// Same as above, but accomplish the entire code within inline assembly.
- function sumPureAsm(uint[] _data) public returns (uint o_sum) {
+ function sumPureAsm(uint[] _data) public view returns (uint o_sum) {
assembly {
// Load the length (first 32 bytes)
let len := mload(_data)
@@ -459,10 +459,10 @@ be just ``0``, but it can also be a complex functional-style expression.
.. code::
- pragma solidity ^0.4.0;
+ pragma solidity ^0.4.16;
contract C {
- function f(uint x) public returns (uint b) {
+ function f(uint x) public view returns (uint b) {
assembly {
let v := add(x, 1)
mstore(0x80, v)
@@ -710,10 +710,10 @@ Example:
We will follow an example compilation from Solidity to desugared assembly.
We consider the runtime bytecode of the following Solidity program::
- pragma solidity ^0.4.0;
+ pragma solidity ^0.4.16;
contract C {
- function f(uint x) public returns (uint y) {
+ function f(uint x) public pure returns (uint y) {
y = 1;
for (uint i = 0; i < x; i++)
y = 2 * y;