Commit 8940931b0b019a690e9130aed5037797ea2033ac
fixed callcopy
wanderer committed on 8/12/2016, 10:32:18 PMParent: a546716646b9629d579c38a8342c9e5f81109e96
Files changed
debugInterface.js | changed |
interface.js | changed |
debugInterface.js | ||
---|---|---|
@@ -33,16 +33,16 @@ | ||
33 | 33 | opcode.name += opcode.number |
34 | 34 | } |
35 | 35 | console.error(`op: ${opcode.name} gas: ${this.environment.gasLimit}`) |
36 | 36 | console.log('-------------stack--------------') |
37 | - for (let i = sp; i > -32; i -= 32) { | |
38 | - console.log(`${(sp - i) / 32} ${this.getMemoryBuffer(i, 32).toString('hex')}`) | |
37 | + for (let i = sp; i >= 0; i -= 32) { | |
38 | + console.log(`${(sp - i) / 32} ${this.getMemoryBuffer(i).toString('hex')}`) | |
39 | 39 | } |
40 | 40 | return sp |
41 | 41 | }.bind(this) |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - getMemoryBuffer (offset, length) { | |
46 | - return new Buffer(new Uint8Array(this.module.exports.memory, offset, length)) | |
45 | + getMemoryBuffer (offset) { | |
46 | + return new Buffer(this.module.exports.memory.slice(offset, offset + 32)).reverse() | |
47 | 47 | } |
48 | 48 | } |
interface.js | ||
---|---|---|
@@ -146,10 +146,10 @@ | ||
146 | 146 | * @param {integer} dataOffset the offset in the input data |
147 | 147 | * @param {integer} length the length of data to copy |
148 | 148 | */ |
149 | 149 | callDataCopy (offset, dataOffset, length) { |
150 | - const callData = new Uint8Array(this.environment.callData, offset, length) | |
151 | - this.setMemory(offset, length, callData) | |
150 | + const callData = Buffer.from(this.environment.callData.slice(offset, offset + length)).reverse() | |
151 | + this.setMemory(dataOffset, length, callData) | |
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Gets the size of code running in current environment. |
@@ -302,9 +302,8 @@ | ||
302 | 302 | const data = this.getMemory(dataOffset, dataLength) |
303 | 303 | // Run the call |
304 | 304 | const [result, errorCode] = this.environment.call(gas, address, value, data) |
305 | 305 | this.setMemory(resultOffset, resultLength, result) |
306 | - | |
307 | 306 | return errorCode |
308 | 307 | } |
309 | 308 | |
310 | 309 | /** |
@@ -323,9 +322,8 @@ | ||
323 | 322 | const data = this.getMemory(dataOffset, dataLength) |
324 | 323 | const address = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES) |
325 | 324 | const [result, errorCode] = this.environment.callDelegate(gas, address, data) |
326 | 325 | this.setMemory(resultOffset, resultLength, result) |
327 | - | |
328 | 326 | return errorCode |
329 | 327 | } |
330 | 328 | |
331 | 329 | /** |
Built with git-ssb-web