aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/control-structures.rst6
-rw-r--r--docs/introduction-to-smart-contracts.rst10
-rw-r--r--docs/miscellaneous.rst17
-rw-r--r--libsolidity/ast/Types.cpp6
-rwxr-xr-xscripts/travis-emscripten/publish_binary.sh6
-rw-r--r--test/libsolidity/SolidityExecutionFramework.h10
6 files changed, 42 insertions, 13 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index 6cbbcdf8..c754de64 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -505,7 +505,7 @@ The opcodes ``pushi`` and ``jumpdest`` cannot be used directly.
+-------------------------+------+-----------------------------------------------------------------+
| pc | | current position in code |
+-------------------------+------+-----------------------------------------------------------------+
-| pop | `*` | remove topmost stack slot |
+| pop(x) | `-` | remove the element pushed by x |
+-------------------------+------+-----------------------------------------------------------------+
| dup1 ... dup16 | | copy ith stack slot to the top (counting from top) |
+-------------------------+------+-----------------------------------------------------------------+
@@ -561,9 +561,9 @@ The opcodes ``pushi`` and ``jumpdest`` cannot be used directly.
| delegatecall(g, a, in, | | identical to `callcode` but also keep ``caller`` |
| insize, out, outsize) | | and ``callvalue`` |
+-------------------------+------+-----------------------------------------------------------------+
-| return(p, s) | `*` | end execution, return data mem[p..(p+s)) |
+| return(p, s) | `-` | end execution, return data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+
-| selfdestruct(a) | `*` | end execution, destroy current contract and send funds to a |
+| selfdestruct(a) | `-` | end execution, destroy current contract and send funds to a |
+-------------------------+------+-----------------------------------------------------------------+
| log0(p, s) | `-` | log without topics and data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+
diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst
index 922056ec..ad0a9650 100644
--- a/docs/introduction-to-smart-contracts.rst
+++ b/docs/introduction-to-smart-contracts.rst
@@ -348,10 +348,12 @@ storage. A contract can neither read nor write to any storage apart
from its own.
The second memory area is called **memory**, of which a contract obtains
-a freshly cleared instance for each message call. Memory can be
-addressed at byte level, but read and written to in 32 byte (256-bit)
-chunks. Memory is more costly the larger it grows (it scales
-quadratically).
+a freshly cleared instance for each message call. Memory is linear and can be
+addressed at byte level, but reads are limited to a width of 256 bits, while writes
+can be either 8 bits or 256 bits wide. Memory is expanded by a word (256-bit), when
+accessing (either reading or writing) a previously untouched memory word (ie. any offset
+within a word). At the time of expansion, the cost in gas must be paid. Memory is more
+costly the larger it grows (it scales quadratically).
The EVM is not a register machine but a stack machine, so all
computations are performed on an area called the **stack**. It has a maximum size of
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index d32186ca..72e32617 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -56,6 +56,23 @@ So for the following contract snippet::
The position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint256(4) . uint256(1))) + 1``.
+****************
+Layout in Memory
+****************
+
+Solidity reserves three 256-bit slots:
+- 0 - 64: scratch space for hashing methods
+- 64 - 96: currently allocated memory size (aka. free memory pointer)
+
+Scratch space can be used between statements (ie. within inline assembly).
+
+Solidity always places new objects at the free memory pointer and memory is never freed (this might change in the future).
+
+.. warning::
+ There are some operations in Solidity that need a temporary memory area larger than 64 bytes and therefore will not fit into the scratch space. They will be placed where the free memory points to, but given their short lifecycle, the pointer is not updated. The memory may or may not be zeroed out. Because of this, one shouldn't expect the free memory to be zeroed out.
+
+.. index: memory layout
+
*****************
Esoteric Features
*****************
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 6d1af534..edb0fbe4 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -574,7 +574,11 @@ bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{
FixedBytesType const& fixedBytes = dynamic_cast<FixedBytesType const&>(_convertTo);
if (!isFractional())
- return fixedBytes.numBytes() * 8 >= integerType()->numBits();
+ {
+ if (integerType())
+ return fixedBytes.numBytes() * 8 >= integerType()->numBits();
+ return false;
+ }
else
return false;
}
diff --git a/scripts/travis-emscripten/publish_binary.sh b/scripts/travis-emscripten/publish_binary.sh
index e2cc1eea..236d976a 100755
--- a/scripts/travis-emscripten/publish_binary.sh
+++ b/scripts/travis-emscripten/publish_binary.sh
@@ -84,8 +84,6 @@ fi
# This file is assumed to be the product of the build_emscripten.sh script.
cp ../soljson.js ./bin/"soljson-$FULLVERSION.js"
node ./update
-cd bin
-git add .
-git add ../soljson.js
-git commit -m "Added compiler version $FULLVERSION"
+git add ./bin/"soljson-$FULLVERSION.js"
+git commit -a -m "Added compiler version $FULLVERSION"
git push origin gh-pages
diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h
index 1cd45603..7d44edaf 100644
--- a/test/libsolidity/SolidityExecutionFramework.h
+++ b/test/libsolidity/SolidityExecutionFramework.h
@@ -39,6 +39,7 @@ namespace dev
{
namespace solidity
{
+ using rational = boost::rational<dev::bigint>;
/// An Ethereum address: 20 bytes.
/// @NOTE This is not endian-specific; it's just a bunch of bytes.
using Address = h160;
@@ -155,6 +156,14 @@ public:
static bytes encode(char const* _value) { return encode(std::string(_value)); }
static bytes encode(byte _value) { return bytes(31, 0) + bytes{_value}; }
static bytes encode(u256 const& _value) { return toBigEndian(_value); }
+ /// @returns the fixed-point encoding of a rational number with a given
+ /// number of fractional bits.
+ static bytes encode(std::pair<rational, int> const& _valueAndPrecision)
+ {
+ rational const& value = _valueAndPrecision.first;
+ int fractionalBits = _valueAndPrecision.second;
+ return encode(u256((value.numerator() << fractionalBits) / value.denominator()));
+ }
static bytes encode(h256 const& _value) { return _value.asBytes(); }
static bytes encode(bytes const& _value, bool _padLeft = true)
{
@@ -186,7 +195,6 @@ public:
{
return encodeArgs(u256(0x20), u256(_arg.size()), _arg);
}
-
class ContractInterface
{
public: