|
|
@ -13,15 +13,14 @@ class Enum extends ValueType { |
|
|
|
super(1, storageBytes, 'enum') |
|
|
|
super(1, storageBytes, 'enum') |
|
|
|
this.enumDef = enumDef |
|
|
|
this.enumDef = enumDef |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Enum.prototype.decodeFromStorage = function (location, storageContent) { |
|
|
|
decodeFromStorage (location, storageContent) { |
|
|
|
var value = util.extractHexValue(location, storageContent, this.storageBytes) |
|
|
|
var value = util.extractHexValue(location, storageContent, this.storageBytes) |
|
|
|
value = parseInt(value, 16) |
|
|
|
value = parseInt(value, 16) |
|
|
|
return output(value, this.enumDef) |
|
|
|
return output(value, this.enumDef) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Enum.prototype.decodeFromStack = function (stackDepth, stack, memory) { |
|
|
|
decodeFromStack (stackDepth, stack, memory) { |
|
|
|
var defaultValue = 0 |
|
|
|
var defaultValue = 0 |
|
|
|
if (stack.length - 1 < stackDepth) { |
|
|
|
if (stack.length - 1 < stackDepth) { |
|
|
|
defaultValue = 0 |
|
|
|
defaultValue = 0 |
|
|
@ -32,12 +31,13 @@ Enum.prototype.decodeFromStack = function (stackDepth, stack, memory) { |
|
|
|
return output(defaultValue, this.enumDef) |
|
|
|
return output(defaultValue, this.enumDef) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Enum.prototype.decodeFromMemory = function (offset, memory) { |
|
|
|
decodeFromMemory (offset, memory) { |
|
|
|
var value = memory.substr(offset, 64) |
|
|
|
var value = memory.substr(offset, 64) |
|
|
|
value = util.extractHexByteSlice(value, this.storageBytes, 0) |
|
|
|
value = util.extractHexByteSlice(value, this.storageBytes, 0) |
|
|
|
value = parseInt(value, 16) |
|
|
|
value = parseInt(value, 16) |
|
|
|
return output(value, this.enumDef) |
|
|
|
return output(value, this.enumDef) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function output (value, enumDef) { |
|
|
|
function output (value, enumDef) { |
|
|
|
if (enumDef.children.length > value) { |
|
|
|
if (enumDef.children.length > value) { |
|
|
|