rename stackHeight stackDepth

pull/7/head
yann300 8 years ago
commit d2da5fd672
  1. 2
      src/solidity/localDecoder.js
  2. 6
      src/solidity/types/Address.js
  3. 6
      src/solidity/types/ArrayType.js
  4. 6
      src/solidity/types/Bool.js
  5. 12
      src/solidity/types/DynamicByteArray.js
  6. 6
      src/solidity/types/Enum.js
  7. 6
      src/solidity/types/FixedByteArray.js
  8. 6
      src/solidity/types/Int.js
  9. 4
      src/solidity/types/StringType.js
  10. 12
      src/solidity/types/Struct.js
  11. 6
      src/solidity/types/Uint.js
  12. 2
      src/util/internalCallTree.js

@ -10,7 +10,7 @@ function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory) {
for (var local in scope.locals) { for (var local in scope.locals) {
let variable = scope.locals[local] let variable = scope.locals[local]
if (variable.type.decodeLocals) { if (variable.type.decodeLocals) {
locals[variable.name] = variable.type.decodeLocals(variable.stackHeight, stack, memory) locals[variable.name] = variable.type.decodeLocals(variable.stackDepth, stack, memory)
} else { } else {
locals[variable.name] = '' locals[variable.name] = ''
} }

@ -12,11 +12,11 @@ Address.prototype.decodeFromStorage = function (location, storageContent) {
return '0x' + value.toUpperCase() return '0x' + value.toUpperCase()
} }
Address.prototype.decodeLocals = function (stackHeight, stack, memory) { Address.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stackHeight >= stack.length) { if (stackDepth >= stack.length) {
return '0x0000000000000000000000000000000000000000' return '0x0000000000000000000000000000000000000000'
} else { } else {
return '0x' + util.extractHexByteSlice(stack[stack.length - 1 - stackHeight], this.storageBytes, 0) return '0x' + util.extractHexByteSlice(stack[stack.length - 1 - stackDepth], this.storageBytes, 0)
} }
} }

@ -54,11 +54,11 @@ ArrayType.prototype.decodeFromStorage = function (location, storageContent) {
} }
} }
ArrayType.prototype.decodeLocals = function (stackHeight, stack, memory) { ArrayType.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
return [] return []
} else { // TODO manage decoding locals from storage } else { // TODO manage decoding locals from storage
var offset = stack[stack.length - 1 - stackHeight] var offset = stack[stack.length - 1 - stackDepth]
offset = 2 * parseInt(offset, 16) offset = 2 * parseInt(offset, 16)
return this.decodeFromMemory(offset, memory) return this.decodeFromMemory(offset, memory)
} }

@ -12,11 +12,11 @@ Bool.prototype.decodeFromStorage = function (location, storageContent) {
return value !== '00' return value !== '00'
} }
Bool.prototype.decodeLocals = function (stackHeight, stack, memory) { Bool.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
return false return false
} else { } else {
return util.extractHexByteSlice(stack[stack.length - 1 - stackHeight], this.storageBytes, 0) !== '00' return util.extractHexByteSlice(stack[stack.length - 1 - stackDepth], this.storageBytes, 0) !== '00'
} }
} }

@ -35,14 +35,14 @@ DynamicByteArray.prototype.decodeFromStorage = function (location, storageConten
} }
} }
DynamicByteArray.prototype.decodeLocals = function (stackHeight, stack, memory) { DynamicByteArray.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
return { return {
value: '0x', value: '0x',
length: '0x0' length: '0x0'
} }
} else { } else {
var offset = stack[stack.length - 1 - stackHeight] var offset = stack[stack.length - 1 - stackDepth]
offset = 2 * parseInt(offset, 16) offset = 2 * parseInt(offset, 16)
return this.decodeFromMemory(offset, memory) return this.decodeFromMemory(offset, memory)
} }
@ -57,14 +57,14 @@ DynamicByteArray.prototype.decodeFromMemory = function (offset, memory) {
} }
} }
DynamicByteArray.prototype.decodeLocals = function (stackHeight, stack, memory) { DynamicByteArray.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
return { return {
value: '0x', value: '0x',
length: '0x0' length: '0x0'
} }
} else { } else {
var offset = stack[stack.length - 1 - stackHeight] var offset = stack[stack.length - 1 - stackDepth]
offset = 2 * parseInt(offset, 16) offset = 2 * parseInt(offset, 16)
return this.decodeFromMemory(offset, memory) return this.decodeFromMemory(offset, memory)
} }

@ -19,12 +19,12 @@ Enum.prototype.decodeFromStorage = function (location, storageContent) {
return output(value, this.enumDef) return output(value, this.enumDef)
} }
Enum.prototype.decodeLocals = function (stackHeight, stack, memory) { Enum.prototype.decodeLocals = function (stackDepth, stack, memory) {
var defaultValue = 0 var defaultValue = 0
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
defaultValue = 0 defaultValue = 0
} else { } else {
defaultValue = util.extractHexByteSlice(stack[stack.length - 1 - stackHeight], this.storageBytes, 0) defaultValue = util.extractHexByteSlice(stack[stack.length - 1 - stackDepth], this.storageBytes, 0)
defaultValue = parseInt(defaultValue, 16) defaultValue = parseInt(defaultValue, 16)
} }
return output(defaultValue, this.enumDef) return output(defaultValue, this.enumDef)

@ -12,11 +12,11 @@ FixedByteArray.prototype.decodeFromStorage = function (location, storageContent)
return '0x' + value.toUpperCase() return '0x' + value.toUpperCase()
} }
FixedByteArray.prototype.decodeLocals = function (stackHeight, stack, memory) { FixedByteArray.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
return '0x' return '0x'
} else { } else {
var value = stack[stack.length - 1 - stackHeight] var value = stack[stack.length - 1 - stackDepth]
return '0x' + value.substr(2, 2 * this.storageBytes).toUpperCase() return '0x' + value.substr(2, 2 * this.storageBytes).toUpperCase()
} }
} }

@ -11,11 +11,11 @@ Int.prototype.decodeFromStorage = function (location, storageContent) {
return util.decodeInt(location, storageContent, this.storageBytes, true) return util.decodeInt(location, storageContent, this.storageBytes, true)
} }
Int.prototype.decodeLocals = function (stackHeight, stack, memory) { Int.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stackHeight >= stack.length) { if (stackDepth >= stack.length) {
return '0' return '0'
} else { } else {
return util.decodeIntFromHex(stack[stack.length - 1 - stackHeight].replace('0x', ''), 32, true) return util.decodeIntFromHex(stack[stack.length - 1 - stackDepth].replace('0x', ''), 32, true)
} }
} }

@ -13,8 +13,8 @@ StringType.prototype.decodeFromStorage = function (location, storageContent) {
return format(decoded) return format(decoded)
} }
StringType.prototype.decodeLocals = function (stackHeight, stack, memory) { StringType.prototype.decodeLocals = function (stackDepth, stack, memory) {
var decoded = this.dynamicBytes.decodeLocals(stackHeight, stack, memory) var decoded = this.dynamicBytes.decodeLocals(stackDepth, stack, memory)
return format(decoded) return format(decoded)
} }

@ -20,11 +20,11 @@ Struct.prototype.decodeFromStorage = function (location, storageContent) {
return ret return ret
} }
Struct.prototype.decodeLocals = function (stackHeight, stack, memory) { Struct.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
return {} return {}
} else { // TODO manage decoding locals from storage } else { // TODO manage decoding locals from storage
var offset = stack[stack.length - 1 - stackHeight] var offset = stack[stack.length - 1 - stackDepth]
offset = 2 * parseInt(offset, 16) offset = 2 * parseInt(offset, 16)
return this.decodeFromMemory(offset, memory) return this.decodeFromMemory(offset, memory)
} }
@ -45,11 +45,11 @@ Struct.prototype.decodeFromMemory = function (offset, memory) {
return ret return ret
} }
Struct.prototype.decodeLocals = function (stackHeight, stack, memory) { Struct.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stack.length - 1 < stackHeight) { if (stack.length - 1 < stackDepth) {
return {} return {}
} else { // TODO manage decoding locals from storage } else { // TODO manage decoding locals from storage
var offset = stack[stack.length - 1 - stackHeight] var offset = stack[stack.length - 1 - stackDepth]
offset = 2 * parseInt(offset, 16) offset = 2 * parseInt(offset, 16)
return this.decodeFromMemory(offset, memory) return this.decodeFromMemory(offset, memory)
} }

@ -11,11 +11,11 @@ Uint.prototype.decodeFromStorage = function (location, storageContent) {
return util.decodeInt(location, storageContent, this.storageBytes, false) return util.decodeInt(location, storageContent, this.storageBytes, false)
} }
Uint.prototype.decodeLocals = function (stackHeight, stack, memory) { Uint.prototype.decodeLocals = function (stackDepth, stack, memory) {
if (stackHeight >= stack.length) { if (stackDepth >= stack.length) {
return '0' return '0'
} else { } else {
return util.decodeIntFromHex(stack[stack.length - 1 - stackHeight].replace('0x', ''), this.storageBytes, false) return util.decodeIntFromHex(stack[stack.length - 1 - stackDepth].replace('0x', ''), this.storageBytes, false)
} }
} }

@ -132,7 +132,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId) {
tree.scopes[scopeId].locals[variableDeclaration.attributes.name] = { tree.scopes[scopeId].locals[variableDeclaration.attributes.name] = {
name: variableDeclaration.attributes.name, name: variableDeclaration.attributes.name,
type: decodeInfo.parseType(variableDeclaration.attributes.type, states, contractName), type: decodeInfo.parseType(variableDeclaration.attributes.type, states, contractName),
stackHeight: stack.length stackDepth: stack.stackDepth
} }
} }
}) })

Loading…
Cancel
Save