mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Random documentation updates (assembly, faq)
This commit is contained in:
parent
cd2d893634
commit
64eaff6420
@ -162,6 +162,8 @@ The opcodes ``pushi`` and ``jumpdest`` cannot be used directly.
|
||||
In the grammar, opcodes are represented as pre-defined identifiers.
|
||||
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| Instruction | | Explanation |
|
||||
+=========================+======+=================================================================+
|
||||
| stop + `-` | stop execution, identical to return(0,0) |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| add(x, y) | | x + y |
|
||||
@ -228,7 +230,7 @@ In the grammar, opcodes are represented as pre-defined identifiers.
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| mstore(p, v) | `-` | mem[p..(p+32)) := v |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| mstore8(p, v) | `-` | mem[p] := v & 0xff - only modifies a single byte |
|
||||
| mstore8(p, v) | `-` | mem[p] := v & 0xff (only modifies a single byte) |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| sload(p) | | storage[p] |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
@ -242,7 +244,7 @@ In the grammar, opcodes are represented as pre-defined identifiers.
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| balance(a) | | wei balance at address a |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| caller | | call sender (excluding delegatecall) |
|
||||
| caller | | call sender (excluding ``delegatecall``) |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| callvalue | | wei sent together with the current call |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
@ -276,13 +278,13 @@ In the grammar, opcodes are represented as pre-defined identifiers.
|
||||
| | | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) |
|
||||
| | | and 1 on success |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| callcode(g, a, v, in, | | identical to `call` but only use the code from a and stay |
|
||||
| callcode(g, a, v, in, | | identical to ``call`` but only use the code from a and stay |
|
||||
| insize, out, outsize) | | in the context of the current contract otherwise |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| delegatecall(g, a, in, | | identical to `callcode` but also keep ``caller`` |
|
||||
| delegatecall(g, a, in, | | identical to ``callcode`` but also keep ``caller`` |
|
||||
| insize, out, outsize) | | and ``callvalue`` |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| staticcall(g, a, in, | | identical to `call(g, a, 0, in, insize, out, outsize)` but do |
|
||||
| staticcall(g, a, in, | | identical to ``call(g, a, 0, in, insize, out, outsize)`` but do |
|
||||
| insize, out, outsize) | | not allow state modifications |
|
||||
+-------------------------+------+-----------------------------------------------------------------+
|
||||
| return(p, s) | `-` | end execution, return data mem[p..(p+s)) |
|
||||
@ -727,7 +729,7 @@ The following assembly will be generated::
|
||||
// function dispatcher
|
||||
switch div(calldataload(0), exp(2, 226))
|
||||
case 0xb3de648b {
|
||||
let (r) = f(calldataload(4))
|
||||
let r := f(calldataload(4))
|
||||
let ret := $allocate(0x20)
|
||||
mstore(ret, r)
|
||||
return(ret, 0x20)
|
||||
|
@ -467,13 +467,13 @@ The following statements are considered modifying the state:
|
||||
}
|
||||
|
||||
.. note::
|
||||
``constant`` is an alias to ``view``.
|
||||
``constant`` on functions is an alias to ``view``.
|
||||
|
||||
.. note::
|
||||
Getter methods are marked ``view``.
|
||||
|
||||
.. warning::
|
||||
The compiler does not enforce yet that a ``view`` method is not modifying state.
|
||||
Before version 0.4.17 the compiler didn't enforce that ``view`` is not modifying the state.
|
||||
|
||||
.. index:: ! pure function, function;pure
|
||||
|
||||
@ -503,7 +503,7 @@ In addition to the list of state modifying statements explained above, the follo
|
||||
}
|
||||
|
||||
.. warning::
|
||||
The compiler does not enforce yet that a ``pure`` method is not reading from the state.
|
||||
Before version 0.4.17 the compiler didn't enforce that ``view`` is not reading the state.
|
||||
|
||||
.. index:: ! fallback function, function;fallback
|
||||
|
||||
|
@ -9,17 +9,6 @@ This list was originally compiled by `fivedogit <mailto:fivedogit@gmail.com>`_.
|
||||
Basic Questions
|
||||
***************
|
||||
|
||||
Example contracts
|
||||
=================
|
||||
|
||||
There are some `contract examples <https://github.com/fivedogit/solidity-baby-steps/tree/master/contracts/>`_ by fivedogit and
|
||||
there should be a `test contract <https://github.com/ethereum/solidity/blob/develop/test/libsolidity/SolidityEndToEndTest.cpp>`_ for every single feature of Solidity.
|
||||
|
||||
Create and publish the most basic contract possible
|
||||
===================================================
|
||||
|
||||
A quite simple contract is the `greeter <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/05_greeter.sol>`_
|
||||
|
||||
Is it possible to do something on a specific block number? (e.g. publish a contract or execute a transaction)
|
||||
=============================================================================================================
|
||||
|
||||
@ -74,25 +63,6 @@ has it (which includes `Remix <https://remix.ethereum.org/>`_), then
|
||||
``contractname.kill.sendTransaction({from:eth.coinbase})``, just the same as my
|
||||
examples.
|
||||
|
||||
Store Ether in a contract
|
||||
=========================
|
||||
|
||||
The trick is to create the contract with ``{from:someaddress, value: web3.toWei(3,"ether")...}``
|
||||
|
||||
See `endowment_retriever.sol <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/30_endowment_retriever.sol>`_.
|
||||
|
||||
Use a non-constant function (req ``sendTransaction``) to increment a variable in a contract
|
||||
===========================================================================================
|
||||
|
||||
See `value_incrementer.sol <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/20_value_incrementer.sol>`_.
|
||||
|
||||
Get a contract to return its funds to you (not using ``selfdestruct(...)``).
|
||||
============================================================================
|
||||
|
||||
This example demonstrates how to send funds from a contract to an address.
|
||||
|
||||
See `endowment_retriever <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/30_endowment_retriever.sol>`_.
|
||||
|
||||
Can you return an array or a ``string`` from a solidity function call?
|
||||
======================================================================
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user