diff options
-rw-r--r-- | docs/control-structures.rst | 10 | ||||
-rw-r--r-- | docs/types.rst | 2 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 4 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.h | 2 | ||||
-rwxr-xr-x | scripts/isolate_tests.py | 8 | ||||
-rw-r--r-- | solc/jsonCompiler.cpp | 6 |
6 files changed, 19 insertions, 13 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst index a3af41dd..a2d34274 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -113,8 +113,8 @@ actual contract has not been created yet. Functions of other contracts have to be called externally. For an external call, all function arguments have to be copied to memory. -When calling functions -of other contracts, the amount of Wei sent with the call and the gas can be specified:: +When calling functions of other contracts, the amount of Wei sent with the call and +the gas can be specified with special options ``.value()`` and ``.gas()``, respectively:: contract InfoFeed { function info() payable returns (uint ret) { return 42; } @@ -127,8 +127,8 @@ of other contracts, the amount of Wei sent with the call and the gas can be spec function callFeed() { feed.info.value(10).gas(800)(); } } -The modifier ``payable`` has to be used for ``info``, because otherwise, -we would not be able to send Ether to it in the call ``feed.info.value(10).gas(800)()``. +The modifier ``payable`` has to be used for ``info``, because otherwise, the `.value()` +option would not be available. Note that the expression ``InfoFeed(addr)`` performs an explicit type conversion stating that "we know that the type of the contract at the given address is ``InfoFeed``" and @@ -235,7 +235,7 @@ creation-dependencies are not possible. } } -As seen in the example, it is possible to forward Ether to the creation, +As seen in the example, it is possible to forward Ether to the creation using the ``.value()`` option, but it is not possible to limit the amount of gas. If the creation fails (due to out-of-stack, not enough balance or other problems), an exception is thrown. diff --git a/docs/types.rst b/docs/types.rst index 6379f01c..60235ad2 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -123,6 +123,8 @@ In a similar way, the function ``delegatecall`` can be used: The difference is t All three functions ``call``, ``delegatecall`` and ``callcode`` are very low-level functions and should only be used as a *last resort* as they break the type-safety of Solidity. +The ``.gas()`` option is available on all three methods, while the ``.value()`` option is not supported for ``delegatecall``. + .. note:: All contracts inherit the members of address, so it is possible to query the balance of the current contract using ``this.balance``. diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 6b0024ad..effc8309 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -527,13 +527,13 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string result = m_readFile(importPath); if (result.success) - newSources[importPath] = result.contentsOrErrorMesage; + newSources[importPath] = result.contentsOrErrorMessage; else { auto err = make_shared<Error>(Error::Type::ParserError); *err << errinfo_sourceLocation(import->location()) << - errinfo_comment("Source \"" + importPath + "\" not found: " + result.contentsOrErrorMesage); + errinfo_comment("Source \"" + importPath + "\" not found: " + result.contentsOrErrorMessage); m_errors.push_back(std::move(err)); continue; } diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index eddfea68..65850683 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -80,7 +80,7 @@ public: struct ReadFileResult { bool success; - std::string contentsOrErrorMesage; + std::string contentsOrErrorMessage; }; /// File reading callback. diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 91900aa6..9bb52f4c 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -7,23 +7,27 @@ # scripts/isolate_tests.py test/libsolidity/* import sys +import re def extract_cases(path): lines = open(path).read().splitlines() inside = False + delimiter = '' tests = [] for l in lines: if inside: - if l.strip().endswith(')";'): + if l.strip().endswith(')' + delimiter + '";'): inside = False else: tests[-1] += l + '\n' else: - if l.strip().endswith('R"('): + m = re.search(r'R"([^(]*)\($', l.strip()) + if m: inside = True + delimiter = m.group(1) tests += [''] return tests diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index 6ebd1a55..45322117 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -143,18 +143,18 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback if (!contents_c && !error_c) { result.success = false; - result.contentsOrErrorMesage = "File not found."; + result.contentsOrErrorMessage = "File not found."; } if (contents_c) { result.success = true; - result.contentsOrErrorMesage = string(contents_c); + result.contentsOrErrorMessage = string(contents_c); free(contents_c); } if (error_c) { result.success = false; - result.contentsOrErrorMesage = string(error_c); + result.contentsOrErrorMessage = string(error_c); free(error_c); } return result; |