diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-21 08:34:41 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:11 +0800 |
commit | 978a58105cd2d2f5d6ee3bcd870218fd357fb010 (patch) | |
tree | 8e390150a6d665dfa335e41593c33f84196a07bd | |
parent | dcc439c2e3a756af75889ddf3b22146322d1d97d (diff) | |
download | dexon-sol-tools-978a58105cd2d2f5d6ee3bcd870218fd357fb010.tar dexon-sol-tools-978a58105cd2d2f5d6ee3bcd870218fd357fb010.tar.gz dexon-sol-tools-978a58105cd2d2f5d6ee3bcd870218fd357fb010.tar.bz2 dexon-sol-tools-978a58105cd2d2f5d6ee3bcd870218fd357fb010.tar.lz dexon-sol-tools-978a58105cd2d2f5d6ee3bcd870218fd357fb010.tar.xz dexon-sol-tools-978a58105cd2d2f5d6ee3bcd870218fd357fb010.tar.zst dexon-sol-tools-978a58105cd2d2f5d6ee3bcd870218fd357fb010.zip |
Prepended `front` to function names in Queue
-rw-r--r-- | packages/utils/src/abi_encoder/calldata/calldata.ts | 14 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/calldata/raw_calldata.ts | 6 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/utils/queue.ts | 8 |
3 files changed, 14 insertions, 14 deletions
diff --git a/packages/utils/src/abi_encoder/calldata/calldata.ts b/packages/utils/src/abi_encoder/calldata/calldata.ts index 154a81b7f..3b85f821b 100644 --- a/packages/utils/src/abi_encoder/calldata/calldata.ts +++ b/packages/utils/src/abi_encoder/calldata/calldata.ts @@ -19,7 +19,7 @@ export class Calldata { // Base Case if (!(block instanceof CalldataBlocks.MemberCalldataBlock)) { - blockQueue.push(block); + blockQueue.pushBack(block); return blockQueue; } @@ -38,9 +38,9 @@ export class Calldata { if (member instanceof CalldataBlocks.DependentCalldataBlock && member.getAlias() === undefined) { const dependency = member.getDependency(); if (dependency instanceof CalldataBlocks.MemberCalldataBlock) { - blockQueue.merge(Calldata._createQueue(dependency)); + blockQueue.mergeBack(Calldata._createQueue(dependency)); } else { - blockQueue.push(dependency); + blockQueue.pushBack(dependency); } } }); @@ -100,7 +100,7 @@ export class Calldata { const offsetQueue = Calldata._createQueue(this._root); let block: CalldataBlock | undefined; let offset = 0; - for (block = offsetQueue.pop(); block !== undefined; block = offsetQueue.pop()) { + for (block = offsetQueue.popFront(); block !== undefined; block = offsetQueue.popFront()) { block.setOffset(offset); offset += block.getSizeInBytes(); } @@ -140,9 +140,9 @@ export class Calldata { let block: CalldataBlock | undefined; let offset = 0; - const functionBlock = valueQueue.peek(); + const functionBlock = valueQueue.peekFront(); const functionName: string = functionBlock === undefined ? '' : functionBlock.getName(); - for (block = valueQueue.pop(); block !== undefined; block = valueQueue.pop()) { + for (block = valueQueue.popFront(); block !== undefined; block = valueQueue.popFront()) { // Process each block 1 word at a time const size = block.getSizeInBytes(); const name = block.getName(); @@ -212,7 +212,7 @@ export class Calldata { const valueQueue = Calldata._createQueue(this._root); const valueBufs: Buffer[] = [selectorBuffer]; let block: CalldataBlock | undefined; - for (block = valueQueue.pop(); block !== undefined; block = valueQueue.pop()) { + for (block = valueQueue.popFront(); block !== undefined; block = valueQueue.popFront()) { valueBufs.push(block.toBuffer()); } diff --git a/packages/utils/src/abi_encoder/calldata/raw_calldata.ts b/packages/utils/src/abi_encoder/calldata/raw_calldata.ts index 27a59c6a3..9e72bbd62 100644 --- a/packages/utils/src/abi_encoder/calldata/raw_calldata.ts +++ b/packages/utils/src/abi_encoder/calldata/raw_calldata.ts @@ -26,7 +26,7 @@ export class RawCalldata { } this._scopes = new Queue<number>(); - this._scopes.push(RawCalldata._INITIAL_OFFSET); + this._scopes.pushBack(RawCalldata._INITIAL_OFFSET); this._offset = RawCalldata._INITIAL_OFFSET; } @@ -60,7 +60,7 @@ export class RawCalldata { } public endScope(): void { - this._scopes.pop(); + this._scopes.popFront(); } public getOffset(): number { @@ -68,7 +68,7 @@ export class RawCalldata { } public toAbsoluteOffset(relativeOffset: number): number { - const scopeOffset = this._scopes.peek(); + const scopeOffset = this._scopes.peekFront(); if (scopeOffset === undefined) { throw new Error(`Tried to access undefined scope.`); } diff --git a/packages/utils/src/abi_encoder/utils/queue.ts b/packages/utils/src/abi_encoder/utils/queue.ts index 3309d8ba2..53afb7e11 100644 --- a/packages/utils/src/abi_encoder/utils/queue.ts +++ b/packages/utils/src/abi_encoder/utils/queue.ts @@ -1,7 +1,7 @@ export class Queue<T> { private _store: T[] = []; - public push(val: T): void { + public pushBack(val: T): void { this._store.push(val); } @@ -9,7 +9,7 @@ export class Queue<T> { this._store.unshift(val); } - public pop(): T | undefined { + public popFront(): T | undefined { return this._store.shift(); } @@ -21,7 +21,7 @@ export class Queue<T> { return backElement; } - public merge(q: Queue<T>): void { + public mergeBack(q: Queue<T>): void { this._store = this._store.concat(q._store); } @@ -33,7 +33,7 @@ export class Queue<T> { return this._store; } - public peek(): T | undefined { + public peekFront(): T | undefined { return this._store.length >= 0 ? this._store[0] : undefined; } } |