Commit b2bfec66 authored by yann300's avatar yann300

decodeFromMemory enum, int, uint

parent d4daac1f
......@@ -30,6 +30,13 @@ Enum.prototype.decodeLocals = function (stackHeight, stack, memory) {
return output(defaultValue, this.enumDef)
}
Enum.prototype.decodeFromMemory = function (offset, memory) {
var value = memory.substr(offset, 64)
value = util.extractHexByteSlice(value, this.storageBytes, 0)
value = parseInt(value, 16)
return output(value, this.enumDef)
}
function output (value, enumDef) {
if (enumDef.children.length > value) {
return enumDef.children[value].attributes.name
......
......@@ -19,4 +19,9 @@ Int.prototype.decodeLocals = function (stackHeight, stack, memory) {
}
}
Int.prototype.decodeFromMemory = function (offset, memory) {
var value = memory.substr(offset, 64)
return util.decodeIntFromHex(value, 32, true)
}
module.exports = Int
......@@ -19,4 +19,9 @@ Uint.prototype.decodeLocals = function (stackHeight, stack, memory) {
}
}
Uint.prototype.decodeFromMemory = function (offset, memory) {
var value = memory.substr(offset, 64)
return util.decodeIntFromHex(value, this.storageBytes, false)
}
module.exports = Uint
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment