mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
commit
84e2d7f456
@ -19,7 +19,11 @@ import os
|
|||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
|
def setup(sphinx):
|
||||||
|
sys.path.insert(0, os.path.abspath('./utils'))
|
||||||
|
from SolidityLexer import SolidityLexer
|
||||||
|
sphinx.add_lexer('Solidity', SolidityLexer())
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
@ -88,7 +92,7 @@ exclude_patterns = ['_build']
|
|||||||
# The name of the Pygments (syntax highlighting) style to use.
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
pygments_style = 'sphinx'
|
pygments_style = 'sphinx'
|
||||||
|
|
||||||
highlight_language = 'javascript'
|
highlight_language = 'Solidity'
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
# A list of ignored prefixes for module index sorting.
|
||||||
#modindex_common_prefix = []
|
#modindex_common_prefix = []
|
||||||
|
@ -163,6 +163,13 @@ and the default is `internal`.
|
|||||||
visible for the contract they are defined in and not in
|
visible for the contract they are defined in and not in
|
||||||
derived contracts.
|
derived contracts.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Everything that is inside a contract is visible to
|
||||||
|
all external observers. Making something `private`
|
||||||
|
only prevents other contract from accessing and modifying
|
||||||
|
the information, but it will still be visible to the
|
||||||
|
whole world outside of the blockchain.
|
||||||
|
|
||||||
The visibility specifier is given after the type for
|
The visibility specifier is given after the type for
|
||||||
state variables and between parameter list and
|
state variables and between parameter list and
|
||||||
return parameter list for functions.
|
return parameter list for functions.
|
||||||
|
@ -742,6 +742,20 @@ If you want to send 20 Ether from a contract to the address `x`, you use `x.send
|
|||||||
Here, `x` can be a plain address or a contract. If the contract already explicitly defines
|
Here, `x` can be a plain address or a contract. If the contract already explicitly defines
|
||||||
a function `send` (and thus overwrites the special function), you can use `address(x).send(20 ether);`.
|
a function `send` (and thus overwrites the special function), you can use `address(x).send(20 ether);`.
|
||||||
|
|
||||||
|
What does the following strange check do in the Custom Token contract?
|
||||||
|
======================================================================
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
|
||||||
|
|
||||||
|
Integers in Solidity (and most other machine-related programming languages) are restricted to a certain range.
|
||||||
|
For `uint256`, this is `0` up to `2**256 - 1`. If the result of some operation on those numbers
|
||||||
|
does not fit inside this range, it is truncated. These truncations can have
|
||||||
|
`serious consequences <https://en.bitcoin.it/wiki/Value_overflow_incident>`_, so code like the one
|
||||||
|
above is necessary to avoid certain attacks.
|
||||||
|
|
||||||
|
|
||||||
More Questions?
|
More Questions?
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
@ -1,13 +1,34 @@
|
|||||||
Welcome to Solidity's documentation!
|
Solidity
|
||||||
====================================
|
========
|
||||||
|
|
||||||
See also `Russian version (русский перевод) <https://github.com/ethereum/wiki/wiki/%D0%A0%D1%83%D0%BA%D0%BE%D0%B2%D0%BE%D0%B4%D1%81%D1%82%D0%B2%D0%BE-%D0%BF%D0%BE-Solidity>`_.
|
|
||||||
|
|
||||||
Solidity is a high-level language whose syntax is similar to that of JavaScript
|
Solidity is a high-level language whose syntax is similar to that of JavaScript
|
||||||
and it is designed to compile to code for the Ethereum Virtual Machine.
|
and it is designed to compile to code for the Ethereum Virtual Machine.
|
||||||
As you will see, it is quite easy to create contracts for voting,
|
As you will see, it is quite easy to create contracts for voting,
|
||||||
crowdfunding, blind auctions, multi-signature wallets and more.
|
crowdfunding, blind auctions, multi-signature wallets and more.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
The best way to try out Solidity right now is using the
|
||||||
|
`Browser-Based Compiler <https://chriseth.github.io/browser-solidity/>`_
|
||||||
|
(it can take a while to load, please be patient).
|
||||||
|
|
||||||
|
Useful links
|
||||||
|
------------
|
||||||
|
|
||||||
|
* `Ethereum <https://ethereum.org>`_
|
||||||
|
|
||||||
|
* `Browser-Based Compiler <https://chriseth.github.io/browser-solidity/>`_
|
||||||
|
|
||||||
|
* `Changelog <https://github.com/ethereum/wiki/wiki/Solidity-Changelog>`_
|
||||||
|
|
||||||
|
* `Story Backlog <https://www.pivotaltracker.com/n/projects/1189488>`_
|
||||||
|
|
||||||
|
* `Source Code <https://github.com/ethereum/solidity/>`_
|
||||||
|
|
||||||
|
* `Gitter Chat <https://gitter.im/ethereum/solidity/>`_
|
||||||
|
|
||||||
|
Language Documentation
|
||||||
|
----------------------
|
||||||
|
|
||||||
On the next pages, we will first see a :ref:`simple smart contract <simple-smart-contract>` written
|
On the next pages, we will first see a :ref:`simple smart contract <simple-smart-contract>` written
|
||||||
in Solidity followed by the basics about :ref:`blockchains <blockchain-basics>`
|
in Solidity followed by the basics about :ref:`blockchains <blockchain-basics>`
|
||||||
and the :ref:`Ethereum Virtual Machine <the-ethereum-virtual-machine>`.
|
and the :ref:`Ethereum Virtual Machine <the-ethereum-virtual-machine>`.
|
||||||
@ -22,19 +43,18 @@ The last and most extensive section will cover all aspects of Solidity in depth.
|
|||||||
If you still have questions or ideas for improving Solidity or this documentation,
|
If you still have questions or ideas for improving Solidity or this documentation,
|
||||||
please feel free to come to out `gitter channel <https://gitter.im/ethereum/solidity/>`_.
|
please feel free to come to out `gitter channel <https://gitter.im/ethereum/solidity/>`_.
|
||||||
|
|
||||||
Index and Search
|
See also `Russian version (русский перевод) <https://github.com/ethereum/wiki/wiki/%D0%A0%D1%83%D0%BA%D0%BE%D0%B2%D0%BE%D0%B4%D1%81%D1%82%D0%B2%D0%BE-%D0%BF%D0%BE-Solidity>`_.
|
||||||
==================
|
|
||||||
|
|
||||||
* :ref:`genindex`
|
|
||||||
* :ref:`search`
|
|
||||||
|
|
||||||
Contents
|
Contents
|
||||||
========
|
========
|
||||||
|
|
||||||
|
:ref:`Keyword Index <genindex>`, :ref:`Search Page <search>`
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
introduction-to-smart-contracts.rst
|
introduction-to-smart-contracts.rst
|
||||||
|
installing-solidity.rst
|
||||||
solidity-by-example.rst
|
solidity-by-example.rst
|
||||||
solidity-in-depth.rst
|
solidity-in-depth.rst
|
||||||
style-guide.rst
|
style-guide.rst
|
||||||
|
140
docs/installing-solidity.rst
Normal file
140
docs/installing-solidity.rst
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
###################
|
||||||
|
Installing Solidity
|
||||||
|
###################
|
||||||
|
|
||||||
|
Browser-Solidity
|
||||||
|
================
|
||||||
|
|
||||||
|
If you just want to try Solidity for small contracts, you
|
||||||
|
can try `browser-solidity <https://chriseth.github.io/browser-solidity>`_
|
||||||
|
which does not need any installation. If you want to use it
|
||||||
|
without connection to the Internet, you can also just save the page
|
||||||
|
locally or clone http://github.com/chriseth/browser-solidity.
|
||||||
|
|
||||||
|
NPM / node.js
|
||||||
|
=============
|
||||||
|
|
||||||
|
This is probably the most portable and most convenient way to install Solidity locally.
|
||||||
|
|
||||||
|
A platform-independent JavaScript library is provided by compiling the C++ source
|
||||||
|
into JavaScript using Emscripten for browser-solidity and there is also an NPM
|
||||||
|
package available.
|
||||||
|
|
||||||
|
To install it, simply use
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
npm install solc
|
||||||
|
|
||||||
|
Details about the usage of the nodejs package can be found in the
|
||||||
|
`repository <https://github.com/chriseth/browser-solidity#nodejs-usage>`_.
|
||||||
|
|
||||||
|
Binary Packages
|
||||||
|
===============
|
||||||
|
|
||||||
|
Binary packages of Solidity together with its IDE Mix are available through
|
||||||
|
the `C++ bundle <https://github.com/ethereum/webthree-umbrella/releases>`_ of
|
||||||
|
Ethereum.
|
||||||
|
|
||||||
|
Building from Source
|
||||||
|
====================
|
||||||
|
|
||||||
|
Building Solidity is quite similar on MacOS X, Ubuntu and probably other Unices.
|
||||||
|
This guide starts explaining how to install the dependencies for each platform
|
||||||
|
and then shows how to build Solidity itself.
|
||||||
|
|
||||||
|
MacOS X
|
||||||
|
-------
|
||||||
|
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
|
||||||
|
- OS X Yosemite (10.10.5)
|
||||||
|
- Homebrew
|
||||||
|
- Xcode
|
||||||
|
|
||||||
|
Set up Homebrew:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
brew update
|
||||||
|
brew install boost --c++11 # this takes a while
|
||||||
|
brew install cmake cryptopp miniupnpc leveldb gmp libmicrohttpd libjson-rpc-cpp
|
||||||
|
# For Mix IDE and Alethzero only
|
||||||
|
brew install xz d-bus
|
||||||
|
brew install llvm --HEAD --with-clang
|
||||||
|
brew install qt5 --with-d-bus # add --verbose if long waits with a stale screen drive you crazy as well
|
||||||
|
|
||||||
|
Ubuntu
|
||||||
|
------
|
||||||
|
|
||||||
|
Below are the build instructions for the latest versions of Ubuntu. The best
|
||||||
|
supported platform as of December 2014 is Ubuntu 14.04, 64 bit, with at least 2
|
||||||
|
GB RAM. All our tests are done with this version. Community contributions for
|
||||||
|
other versions are welcome!
|
||||||
|
|
||||||
|
Install dependencies:
|
||||||
|
|
||||||
|
Before you can build the source, you need several tools and dependencies for the application to get started.
|
||||||
|
|
||||||
|
First, update your repositories. Not all packages are provided in the main
|
||||||
|
Ubuntu repository, those you'll get from the Ethereum PPA and the LLVM archive.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Ubuntu 14.04 users, you'll need the latest version of cmake. For this, use:
|
||||||
|
`sudo apt-add-repository ppa:george-edison55/cmake-3.x`
|
||||||
|
|
||||||
|
Now add all the rest:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo apt-get -y update
|
||||||
|
sudo apt-get -y install language-pack-en-base
|
||||||
|
sudo dpkg-reconfigure locales
|
||||||
|
sudo apt-get -y install software-properties-common
|
||||||
|
sudo add-apt-repository -y ppa:ethereum/ethereum
|
||||||
|
sudo add-apt-repository -y ppa:ethereum/ethereum-dev
|
||||||
|
sudo apt-get -y update
|
||||||
|
sudo apt-get -y upgrade
|
||||||
|
|
||||||
|
Use the following command to add the develop packages:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo apt-get -y install build-essential git cmake libboost-all-dev libgmp-dev libleveldb-dev libminiupnpc-dev libreadline-dev libncurses5-dev libcurl4-openssl-dev libcryptopp-dev libjson-rpc-cpp-dev libmicrohttpd-dev libjsoncpp-dev libedit-dev libz-dev
|
||||||
|
|
||||||
|
Building
|
||||||
|
--------
|
||||||
|
|
||||||
|
Run this if you plan on installing Solidity only, ignore errors at the end as
|
||||||
|
they relate only to Alethzero and Mix
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
git clone --recursive https://github.com/ethereum/webthree-umbrella.git
|
||||||
|
cd webthree-umbrella
|
||||||
|
./webthree-helpers/scripts/ethupdate.sh --no-push --simple-pull --project solidity # update Solidity repo
|
||||||
|
./webthree-helpers/scripts/ethbuild.sh --no-git --project solidity --all --cores 4 # build Solidity
|
||||||
|
|
||||||
|
If you opted to install Alethzero and Mix:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
git clone --recursive https://github.com/ethereum/webthree-umbrella.git
|
||||||
|
cd webthree-umbrella && mkdir -p build && cd build
|
||||||
|
cmake ..
|
||||||
|
|
||||||
|
If you want to help developing Solidity,
|
||||||
|
you should fork Solidity and add your personal fork as a second remote:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
cd webthree-umbrella/solidity
|
||||||
|
git remote add personal git@github.com:username/solidity.git
|
||||||
|
|
||||||
|
Note that webthree-umbrella uses submodules, so solidity is its own git
|
||||||
|
repository, but its settings are not stored in `.git/config`, but in
|
||||||
|
`webthree-umbrella/.git/modules/solidity/config`.
|
||||||
|
|
||||||
|
|
85
docs/utils/SolidityLexer.py
Normal file
85
docs/utils/SolidityLexer.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import re
|
||||||
|
import copy
|
||||||
|
|
||||||
|
from pygments.lexer import RegexLexer, ExtendedRegexLexer, bygroups, using, \
|
||||||
|
include, this
|
||||||
|
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
||||||
|
Number, Other, Punctuation, Literal
|
||||||
|
|
||||||
|
__all__ = ['SolidityLexer']
|
||||||
|
|
||||||
|
class SolidityLexer(RegexLexer):
|
||||||
|
name = "Solidity"
|
||||||
|
aliases = ['sol', 'solidity']
|
||||||
|
filenames = ['*.sol']
|
||||||
|
mimetypes = []
|
||||||
|
flags = re.DOTALL
|
||||||
|
tokens = {
|
||||||
|
'commentsandwhitespace': [
|
||||||
|
(r'\s+', Text),
|
||||||
|
(r'<!--', Comment),
|
||||||
|
(r'///', Comment.Special, 'docstringsingle'),
|
||||||
|
(r'//.*?\n', Comment.Single),
|
||||||
|
(r'/\*\*', Comment.Special, 'docstringmulti'),
|
||||||
|
(r'/\*.*?\*/', Comment.Multiline)
|
||||||
|
],
|
||||||
|
'natspec': [
|
||||||
|
(r'@author|@dev|@notice|@return|@param|@why3|@title', Keyword),
|
||||||
|
(r'.[^@*\n]*?', Comment.Special)
|
||||||
|
],
|
||||||
|
'docstringsingle': [
|
||||||
|
(r'\n', Comment.Special, '#pop'),
|
||||||
|
include('natspec')
|
||||||
|
],
|
||||||
|
'docstringmulti': [
|
||||||
|
(r'\*/', Comment.Special, '#pop'),
|
||||||
|
include('natspec')
|
||||||
|
],
|
||||||
|
'slashstartsregex': [
|
||||||
|
include('commentsandwhitespace'),
|
||||||
|
(r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
|
||||||
|
r'([gim]+\b|\B)', String.Regex, '#pop'),
|
||||||
|
(r'(?=/)', Text, ('#pop', 'badregex')),
|
||||||
|
(r'', Text, '#pop')
|
||||||
|
],
|
||||||
|
'badregex': [
|
||||||
|
(r'\n', Text, '#pop')
|
||||||
|
],
|
||||||
|
'root': [
|
||||||
|
(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
|
||||||
|
include('commentsandwhitespace'),
|
||||||
|
(r'\+\+|--|\*\*|~|&&|\?|:|\|\||\\(?=\n)|'
|
||||||
|
r'(<<|>>>?|==?|!=?|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
|
||||||
|
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
|
||||||
|
(r'[})\].]', Punctuation),
|
||||||
|
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
|
||||||
|
r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
|
||||||
|
r'this|import|mapping|returns|private|public|external|internal|'
|
||||||
|
r'constant|memory|storage)\b', Keyword, 'slashstartsregex'),
|
||||||
|
(r'(var|let|with|function|event|modifier|struct|enum|contract)\b', Keyword.Declaration, 'slashstartsregex'),
|
||||||
|
(r'(bytes|string|address|uint|int|bool|byte|' +
|
||||||
|
'|'.join(
|
||||||
|
['uint%d' % (i + 8) for i in range(0, 256, 8)] +
|
||||||
|
['int%d' % (i + 8) for i in range(0, 256, 8)] +
|
||||||
|
['bytes%d' % (i + 1) for i in range(0, 32)]
|
||||||
|
) + r')\b', Keyword.Type, 'slashstartsregex'),
|
||||||
|
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
|
||||||
|
r'extends|final|float|goto|implements|int|interface|long|native|'
|
||||||
|
r'package|private|protected|public|short|static|super|synchronized|throws|'
|
||||||
|
r'transient|volatile)\b', Keyword.Reserved),
|
||||||
|
(r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
|
||||||
|
(r'(Array|Boolean|Date|Error|Function|Math|netscape|'
|
||||||
|
r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
|
||||||
|
r'decodeURIComponent|encodeURI|encodeURIComponent|'
|
||||||
|
r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
|
||||||
|
r'window)\b', Name.Builtin),
|
||||||
|
(r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
|
||||||
|
(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
|
||||||
|
(r'0x[0-9a-fA-F]+', Number.Hex),
|
||||||
|
(r'[0-9]+', Number.Integer),
|
||||||
|
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
||||||
|
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
||||||
|
]
|
||||||
|
}
|
@ -337,6 +337,7 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
|||||||
auto const& arguments = _inheritance.arguments();
|
auto const& arguments = _inheritance.arguments();
|
||||||
TypePointers parameterTypes = ContractType(*base).constructorType()->parameterTypes();
|
TypePointers parameterTypes = ContractType(*base).constructorType()->parameterTypes();
|
||||||
if (!arguments.empty() && parameterTypes.size() != arguments.size())
|
if (!arguments.empty() && parameterTypes.size() != arguments.size())
|
||||||
|
{
|
||||||
typeError(
|
typeError(
|
||||||
_inheritance.location(),
|
_inheritance.location(),
|
||||||
"Wrong argument count for constructor call: " +
|
"Wrong argument count for constructor call: " +
|
||||||
@ -345,6 +346,8 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
|||||||
toString(parameterTypes.size()) +
|
toString(parameterTypes.size()) +
|
||||||
"."
|
"."
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arguments.size(); ++i)
|
for (size_t i = 0; i < arguments.size(); ++i)
|
||||||
if (!type(*arguments[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
|
if (!type(*arguments[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
|
||||||
@ -950,7 +953,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
|
|||||||
else
|
else
|
||||||
_functionCall.annotation().type = make_shared<TupleType>(functionType->returnParameterTypes());
|
_functionCall.annotation().type = make_shared<TupleType>(functionType->returnParameterTypes());
|
||||||
|
|
||||||
TypePointers const& parameterTypes = functionType->parameterTypes();
|
TypePointers parameterTypes = functionType->parameterTypes();
|
||||||
if (!functionType->takesArbitraryParameters() && parameterTypes.size() != arguments.size())
|
if (!functionType->takesArbitraryParameters() && parameterTypes.size() != arguments.size())
|
||||||
{
|
{
|
||||||
string msg =
|
string msg =
|
||||||
@ -1079,7 +1082,7 @@ void TypeChecker::endVisit(NewExpression const& _newExpression)
|
|||||||
);
|
);
|
||||||
|
|
||||||
auto contractType = make_shared<ContractType>(*contract);
|
auto contractType = make_shared<ContractType>(*contract);
|
||||||
TypePointers const& parameterTypes = contractType->constructorType()->parameterTypes();
|
TypePointers parameterTypes = contractType->constructorType()->parameterTypes();
|
||||||
_newExpression.annotation().type = make_shared<FunctionType>(
|
_newExpression.annotation().type = make_shared<FunctionType>(
|
||||||
parameterTypes,
|
parameterTypes,
|
||||||
TypePointers{contractType},
|
TypePointers{contractType},
|
||||||
|
@ -85,7 +85,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
|
|||||||
CompilerContext::LocationSetter locationSetter(m_context, _varDecl);
|
CompilerContext::LocationSetter locationSetter(m_context, _varDecl);
|
||||||
FunctionType accessorType(_varDecl);
|
FunctionType accessorType(_varDecl);
|
||||||
|
|
||||||
TypePointers const& paramTypes = accessorType.parameterTypes();
|
TypePointers paramTypes = accessorType.parameterTypes();
|
||||||
|
|
||||||
// retrieve the position of the variable
|
// retrieve the position of the variable
|
||||||
auto const& location = m_context.storageLocationOfVariable(_varDecl);
|
auto const& location = m_context.storageLocationOfVariable(_varDecl);
|
||||||
@ -380,7 +380,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
else
|
else
|
||||||
functionType = dynamic_pointer_cast<FunctionType const>(_functionCall.expression().annotation().type);
|
functionType = dynamic_pointer_cast<FunctionType const>(_functionCall.expression().annotation().type);
|
||||||
|
|
||||||
TypePointers const& parameterTypes = functionType->parameterTypes();
|
TypePointers parameterTypes = functionType->parameterTypes();
|
||||||
vector<ASTPointer<Expression const>> const& callArguments = _functionCall.arguments();
|
vector<ASTPointer<Expression const>> const& callArguments = _functionCall.arguments();
|
||||||
vector<ASTPointer<ASTString>> const& callArgumentNames = _functionCall.names();
|
vector<ASTPointer<ASTString>> const& callArgumentNames = _functionCall.names();
|
||||||
if (!functionType->takesArbitraryParameters())
|
if (!functionType->takesArbitraryParameters())
|
||||||
|
@ -278,9 +278,9 @@ void CommandLineInterface::handleGasEstimation(string const& _contract)
|
|||||||
gas = GasEstimator::functionalEstimation(*items, entry, *it);
|
gas = GasEstimator::functionalEstimation(*items, entry, *it);
|
||||||
FunctionType type(*it);
|
FunctionType type(*it);
|
||||||
cout << " " << it->name() << "(";
|
cout << " " << it->name() << "(";
|
||||||
auto end = type.parameterTypes().end();
|
auto paramTypes = type.parameterTypes();
|
||||||
for (auto it = type.parameterTypes().begin(); it != end; ++it)
|
for (auto it = paramTypes.begin(); it != paramTypes.end(); ++it)
|
||||||
cout << (*it)->toString() << (it + 1 == end ? "" : ",");
|
cout << (*it)->toString() << (it + 1 == paramTypes.end() ? "" : ",");
|
||||||
cout << "):\t" << gas << endl;
|
cout << "):\t" << gas << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
FROM ubuntu:14.04
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get upgrade -y
|
|
||||||
|
|
||||||
# Ethereum dependencies
|
|
||||||
RUN apt-get install -qy build-essential git cmake libcurl4-openssl-dev wget
|
|
||||||
RUN apt-get install -qy automake libtool yasm scons
|
|
||||||
|
|
||||||
RUN useradd -ms /bin/bash user
|
|
||||||
USER user
|
|
||||||
ENV HOME /home/user
|
|
||||||
WORKDIR /home/user
|
|
||||||
|
|
||||||
# Emscripten SDK
|
|
||||||
RUN wget -c https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
|
|
||||||
RUN tar xzf emsdk-portable.tar.gz
|
|
||||||
WORKDIR /home/user/emsdk_portable
|
|
||||||
RUN ./emsdk update && ./emsdk install latest && ./emsdk activate latest
|
|
||||||
ENV PATH $PATH:/home/user/emsdk_portable:/home/user/emsdk_portable/clang/fastcomp/build_master_64/bin:/home/user/emsdk_portable/emscripten/master
|
|
||||||
|
|
||||||
USER root
|
|
||||||
RUN apt-get install -qy nodejs
|
|
||||||
USER user
|
|
||||||
RUN sed -i "s/NODE_JS = 'node'/NODE_JS = 'nodejs'/g" ~/.emscripten
|
|
||||||
|
|
||||||
# CryptoPP
|
|
||||||
WORKDIR /home/user
|
|
||||||
RUN git clone https://github.com/mmoss/cryptopp.git
|
|
||||||
WORKDIR /home/user/cryptopp
|
|
||||||
RUN emcmake cmake -DCRYPTOPP_LIBRARY_TYPE=STATIC -DCRYPTOPP_RUNTIME_TYPE=STATIC && emmake make -j 4
|
|
||||||
RUN ln -s . src/cryptopp
|
|
||||||
|
|
||||||
# Boost
|
|
||||||
WORKDIR /home/user
|
|
||||||
RUN wget 'http://downloads.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F1.57.0%2F&ts=1421887207&use_mirror=cznic' -O boost_1_57_0.tar.bz2
|
|
||||||
RUN tar xjf boost_1_57_0.tar.bz2
|
|
||||||
WORKDIR /home/user/boost_1_57_0
|
|
||||||
RUN ./bootstrap.sh --with-libraries=thread,system,regex
|
|
||||||
RUN sed -i 's/using gcc ;/using gcc : : \/home\/user\/emsdk_portable\/emscripten\/master\/em++ ;/g' ./project-config.jam
|
|
||||||
RUN sed -i 's/$(archiver\[1\])/\/home\/user\/emsdk_portable\/emscripten\/master\/emar/g' ./tools/build/src/tools/gcc.jam
|
|
||||||
RUN sed -i 's/$(ranlib\[1\])/\/home\/user\/emsdk_portable\/emscripten\/master\/emranlib/g' ./tools/build/src/tools/gcc.jam
|
|
||||||
RUN ./b2 link=static variant=release threading=single runtime-link=static thread system regex
|
|
||||||
|
|
||||||
# Json-CPP
|
|
||||||
WORKDIR /home/user
|
|
||||||
RUN git clone https://github.com/open-source-parsers/jsoncpp.git
|
|
||||||
WORKDIR /home/user/jsoncpp
|
|
||||||
RUN emcmake cmake -DJSONCPP_LIB_BUILD_STATIC=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF -G "Unix Makefiles" .
|
|
||||||
RUN emmake make
|
|
||||||
|
|
||||||
## Build soljs
|
|
||||||
WORKDIR /home/user
|
|
||||||
ADD https://api.github.com/repos/ethereum/cpp-ethereum/git/refs/heads/develop unused.txt
|
|
||||||
RUN git clone --depth=1 https://github.com/ethereum/cpp-ethereum
|
|
||||||
WORKDIR /home/user/cpp-ethereum
|
|
||||||
RUN git config --global user.email "me@example.com"
|
|
||||||
RUN git config --global user.name "Jane Doe"
|
|
||||||
ADD https://api.github.com/repos/chriseth/cpp-ethereum/git/refs/heads/solidity-js unused2.txt
|
|
||||||
RUN git remote add -f solidityjs https://github.com/chriseth/cpp-ethereum
|
|
||||||
# TODO this should be a proper merge but somehow causes problems
|
|
||||||
# NOTE that we only get the latest commit of that branch
|
|
||||||
RUN git cherry-pick solidityjs/solidity-js
|
|
||||||
RUN emcmake cmake -DMINER=0 -DETHKEY=0 -DSERPENT=0 -DTESTS=0 -DETHASHCL=0 -DJSCONSOLE=0 -DEVMJIT=0 -DETH_STATIC=1 -DSOLIDITY=1 -DGUI=0 -DCMAKE_CXX_COMPILER=/home/user/emsdk_portable/emscripten/master/em++ -DCMAKE_C_COMPILER=/home/user/emsdk_portable/emscripten/master/emcc
|
|
||||||
RUN emmake make -j 6 soljson
|
|
||||||
|
|
||||||
WORKDIR /home/user/cpp-ethereum/solc
|
|
||||||
ENTRYPOINT cat soljson.js
|
|
||||||
|
|
@ -103,9 +103,9 @@ Json::Value estimateGas(CompilerStack const& _compiler, string const& _contract)
|
|||||||
gas = GasEstimator::functionalEstimation(*items, entry, *it);
|
gas = GasEstimator::functionalEstimation(*items, entry, *it);
|
||||||
FunctionType type(*it);
|
FunctionType type(*it);
|
||||||
string sig = it->name() + "(";
|
string sig = it->name() + "(";
|
||||||
auto end = type.parameterTypes().end();
|
auto paramTypes = type.parameterTypes();
|
||||||
for (auto it = type.parameterTypes().begin(); it != end; ++it)
|
for (auto it = paramTypes.begin(); it != paramTypes.end(); ++it)
|
||||||
sig += (*it)->toString() + (it + 1 == end ? "" : ",");
|
sig += (*it)->toString() + (it + 1 == paramTypes.end() ? "" : ",");
|
||||||
sig += ")";
|
sig += ")";
|
||||||
internalFunctions[sig] = gasToJson(gas);
|
internalFunctions[sig] = gasToJson(gas);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user