From 8b22007cba38f82110e4e4b1499a498453c751e3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 28 Nov 2016 10:50:48 +0100 Subject: [PATCH] add comments --- src/solidity/types/util.js | 14 ++++++++++++++ src/util/astWalker.js | 10 +++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/solidity/types/util.js b/src/solidity/types/util.js index 0cd6696428..cdb2077a8a 100644 --- a/src/solidity/types/util.js +++ b/src/solidity/types/util.js @@ -33,6 +33,13 @@ function readFromStorage (slot, storageContent) { } } +/** + * @returns a hex encoded byte slice of length @arg byteLength from inside @arg slotValue. + * + * @param {String} slotValue - right aligned hex encoded value to extract the byte slice from (can have 0x prefix) + * @param {Int} byteLength - Length of the byte slice to extract + * @param {Int} offsetFromLSB - byte distance from the right end slot value to the right end of the byte slice + */ function extractHexByteSlice (slotValue, byteLength, offsetFromLSB) { slotValue = slotValue.replace('0x', '') if (slotValue.length < 64) { @@ -42,6 +49,13 @@ function extractHexByteSlice (slotValue, byteLength, offsetFromLSB) { return slotValue.substr(offset, 2 * byteLength) } +/** + * @returns a hex encoded storage content at the given @arg location. it does not have Ox prefix but always has the full length. + * + * @param {Object} location - object containing the slot and offset of the data to extract. + * @param {Object} storageContent - full storage mapping. + * @param {Int} byteLength - Length of the byte slice to extract + */ function extractHexByte (location, storageContent, byteLength) { var slotvalue = readFromStorage(location.slot, storageContent) return extractHexByteSlice(slotvalue, byteLength, location.offset) diff --git a/src/util/astWalker.js b/src/util/astWalker.js index 38dc3f9337..f8737122d6 100644 --- a/src/util/astWalker.js +++ b/src/util/astWalker.js @@ -31,11 +31,11 @@ AstWalker.prototype.walk = function (ast, callback) { } /** - + * walk the given @astList - + * - + * @param {Object} sourcesList - sources list (containing root AST node) - + * @param {Function} - callback used by AstWalker to compute response - + */ + * walk the given @astList + * + * @param {Object} sourcesList - sources list (containing root AST node) + * @param {Function} - callback used by AstWalker to compute response + */ AstWalker.prototype.walkAstList = function (sourcesList, callback) { var walker = new AstWalker() for (var k in sourcesList) {