git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 8940931b0b019a690e9130aed5037797ea2033ac

fixed callcopy

wanderer committed on 8/12/2016, 10:32:18 PM
Parent: a546716646b9629d579c38a8342c9e5f81109e96

Files changed

debugInterface.jschanged
interface.jschanged
debugInterface.jsView
@@ -33,16 +33,16 @@
3333 opcode.name += opcode.number
3434 }
3535 console.error(`op: ${opcode.name} gas: ${this.environment.gasLimit}`)
3636 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')}`)
3939 }
4040 return sp
4141 }.bind(this)
4242 }
4343 }
4444
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()
4747 }
4848 }
interface.jsView
@@ -146,10 +146,10 @@
146146 * @param {integer} dataOffset the offset in the input data
147147 * @param {integer} length the length of data to copy
148148 */
149149 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)
152152 }
153153
154154 /**
155155 * Gets the size of code running in current environment.
@@ -302,9 +302,8 @@
302302 const data = this.getMemory(dataOffset, dataLength)
303303 // Run the call
304304 const [result, errorCode] = this.environment.call(gas, address, value, data)
305305 this.setMemory(resultOffset, resultLength, result)
306-
307306 return errorCode
308307 }
309308
310309 /**
@@ -323,9 +322,8 @@
323322 const data = this.getMemory(dataOffset, dataLength)
324323 const address = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)
325324 const [result, errorCode] = this.environment.callDelegate(gas, address, data)
326325 this.setMemory(resultOffset, resultLength, result)
327-
328326 return errorCode
329327 }
330328
331329 /**

Built with git-ssb-web