From 3267adcd14ba10e27a4b177e771fca9c9ab39646 Mon Sep 17 00:00:00 2001 From: Chase McDermott Date: Sat, 14 Jul 2018 16:42:01 -0500 Subject: Added default data locations to docs and other external tests. --- test/compilationTests/stringutils/strings.sol | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'test/compilationTests/stringutils') diff --git a/test/compilationTests/stringutils/strings.sol b/test/compilationTests/stringutils/strings.sol index fc46ec5a..390fb5d9 100644 --- a/test/compilationTests/stringutils/strings.sol +++ b/test/compilationTests/stringutils/strings.sol @@ -63,7 +63,7 @@ library strings { * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ - function toSlice(string self) internal returns (slice) { + function toSlice(string memory self) internal returns (slice memory) { uint ptr; assembly { ptr := add(self, 0x20) @@ -109,7 +109,7 @@ library strings { * @return A new slice containing the value of the input argument up to the * first null. */ - function toSliceB32(bytes32 self) internal returns (slice ret) { + function toSliceB32(bytes32 self) internal returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) @@ -125,7 +125,7 @@ library strings { * @param self The slice to copy. * @return A new slice containing the same data as `self`. */ - function copy(slice self) internal returns (slice) { + function copy(slice memory self) internal returns (slice memory) { return slice(self._len, self._ptr); } @@ -134,7 +134,7 @@ library strings { * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ - function toString(slice self) internal returns (string) { + function toString(slice memory self) internal returns (string memory) { string memory ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } @@ -151,7 +151,7 @@ library strings { * @param self The slice to operate on. * @return The length of the slice in runes. */ - function len(slice self) internal returns (uint) { + function len(slice memory self) internal returns (uint) { // Starting at ptr-31 means the LSB will be the byte we care about uint ptr = self._ptr - 31; uint end = ptr + self._len; @@ -181,7 +181,7 @@ library strings { * @param self The slice to operate on. * @return True if the slice is empty, False otherwise. */ - function empty(slice self) internal returns (bool) { + function empty(slice memory self) internal returns (bool) { return self._len == 0; } @@ -194,7 +194,7 @@ library strings { * @param other The second slice to compare. * @return The result of the comparison. */ - function compare(slice self, slice other) internal returns (int) { + function compare(slice memory self, slice memory other) internal returns (int) { uint shortest = self._len; if (other._len < self._len) shortest = other._len; @@ -227,7 +227,7 @@ library strings { * @param self The second slice to compare. * @return True if the slices are equal, false otherwise. */ - function equals(slice self, slice other) internal returns (bool) { + function equals(slice memory self, slice memory other) internal returns (bool) { return compare(self, other) == 0; } @@ -238,7 +238,7 @@ library strings { * @param rune The slice that will contain the first rune. * @return `rune`. */ - function nextRune(slice self, slice rune) internal returns (slice) { + function nextRune(slice memory self, slice memory rune) internal returns (slice memory) { rune._ptr = self._ptr; if (self._len == 0) { @@ -280,7 +280,7 @@ library strings { * @param self The slice to operate on. * @return A slice containing only the first rune from `self`. */ - function nextRune(slice self) internal returns (slice ret) { + function nextRune(slice memory self) internal returns (slice memory ret) { nextRune(self, ret); } @@ -289,7 +289,7 @@ library strings { * @param self The slice to operate on. * @return The number of the first codepoint in the slice. */ - function ord(slice self) internal returns (uint ret) { + function ord(slice memory self) internal returns (uint ret) { if (self._len == 0) { return 0; } @@ -338,7 +338,7 @@ library strings { * @param self The slice to hash. * @return The hash of the slice. */ - function keccak(slice self) internal returns (bytes32 ret) { + function keccak(slice memory self) internal returns (bytes32 ret) { assembly { ret := keccak256(mload(add(self, 32)), mload(self)) } @@ -350,7 +350,7 @@ library strings { * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ - function startsWith(slice self, slice needle) internal returns (bool) { + function startsWith(slice memory self, slice memory needle) internal returns (bool) { if (self._len < needle._len) { return false; } @@ -376,7 +376,7 @@ library strings { * @param needle The slice to search for. * @return `self` */ - function beyond(slice self, slice needle) internal returns (slice) { + function beyond(slice memory self, slice memory needle) internal returns (slice memory) { if (self._len < needle._len) { return self; } @@ -405,7 +405,7 @@ library strings { * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ - function endsWith(slice self, slice needle) internal returns (bool) { + function endsWith(slice memory self, slice memory needle) internal returns (bool) { if (self._len < needle._len) { return false; } @@ -433,7 +433,7 @@ library strings { * @param needle The slice to search for. * @return `self` */ - function until(slice self, slice needle) internal returns (slice) { + function until(slice memory self, slice memory needle) internal returns (slice memory) { if (self._len < needle._len) { return self; } @@ -542,7 +542,7 @@ library strings { * @param needle The text to search for. * @return `self`. */ - function find(slice self, slice needle) internal returns (slice) { + function find(slice memory self, slice memory needle) internal returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; @@ -557,7 +557,7 @@ library strings { * @param needle The text to search for. * @return `self`. */ - function rfind(slice self, slice needle) internal returns (slice) { + function rfind(slice memory self, slice memory needle) internal returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; @@ -573,7 +573,7 @@ library strings { * @param token An output parameter to which the first token is written. * @return `token`. */ - function split(slice self, slice needle, slice token) internal returns (slice) { + function split(slice memory self, slice memory needle, slice memory token) internal returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; @@ -596,7 +596,7 @@ library strings { * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ - function split(slice self, slice needle) internal returns (slice token) { + function split(slice memory self, slice memory needle) internal returns (slice memory token) { split(self, needle, token); } @@ -610,7 +610,7 @@ library strings { * @param token An output parameter to which the first token is written. * @return `token`. */ - function rsplit(slice self, slice needle, slice token) internal returns (slice) { + function rsplit(slice memory self, slice memory needle, slice memory token) internal returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); @@ -632,7 +632,7 @@ library strings { * @param needle The text to search for in `self`. * @return The part of `self` after the last occurrence of `delim`. */ - function rsplit(slice self, slice needle) internal returns (slice token) { + function rsplit(slice memory self, slice memory needle) internal returns (slice memory token) { rsplit(self, needle, token); } @@ -642,7 +642,7 @@ library strings { * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ - function count(slice self, slice needle) internal returns (uint count) { + function count(slice memory self, slice memory needle) internal returns (uint count) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { count++; @@ -656,7 +656,7 @@ library strings { * @param needle The text to search for in `self`. * @return True if `needle` is found in `self`, false otherwise. */ - function contains(slice self, slice needle) internal returns (bool) { + function contains(slice memory self, slice memory needle) internal returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } @@ -667,7 +667,7 @@ library strings { * @param other The second slice to concatenate. * @return The concatenation of the two strings. */ - function concat(slice self, slice other) internal returns (string) { + function concat(slice memory self, slice memory other) internal returns (string memory) { string memory ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } @@ -684,7 +684,7 @@ library strings { * @return A newly allocated string containing all the slices in `parts`, * joined with `self`. */ - function join(slice self, slice[] parts) internal returns (string) { + function join(slice memory self, slice[] memory parts) internal returns (string memory) { if (parts.length == 0) return ""; -- cgit v1.2.3