|
|
@ -7,20 +7,31 @@ class RefType { |
|
|
|
this.storageSlots = storageSlots |
|
|
|
this.storageSlots = storageSlots |
|
|
|
this.storageBytes = storageBytes |
|
|
|
this.storageBytes = storageBytes |
|
|
|
this.typeName = typeName |
|
|
|
this.typeName = typeName |
|
|
|
|
|
|
|
this.basicType = 'RefType' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
decodeFromStack (stackDepth, stack, memory, storage) { |
|
|
|
decodeFromStack (stackDepth, stack, memory, storage) { |
|
|
|
|
|
|
|
if (!storage) { |
|
|
|
|
|
|
|
storage = {} // TODO this is a fallback, should manage properly locals store in storage
|
|
|
|
|
|
|
|
} |
|
|
|
if (stack.length - 1 < stackDepth) { |
|
|
|
if (stack.length - 1 < stackDepth) { |
|
|
|
return [] |
|
|
|
return { error: '<decoding failed - stack underflow ' + stackDepth + '>' } |
|
|
|
} |
|
|
|
} |
|
|
|
var offset = stack[stack.length - 1 - stackDepth] |
|
|
|
var offset = stack[stack.length - 1 - stackDepth] |
|
|
|
offset = 2 * parseInt(offset, 16) |
|
|
|
offset = parseInt(offset, 16) |
|
|
|
|
|
|
|
return this.decode(offset, memory, storage) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decode (offset, memory, storage) { |
|
|
|
|
|
|
|
if (!storage) { |
|
|
|
|
|
|
|
storage = {} // TODO this is a fallback, should manage properly locals store in storage
|
|
|
|
|
|
|
|
} |
|
|
|
if (util.storageStore(this)) { |
|
|
|
if (util.storageStore(this)) { |
|
|
|
return this.decodeFromStorage(offset, storage) |
|
|
|
return this.decodeFromStorage({ offset: 0, slot: offset }, storage) |
|
|
|
} else if (util.memoryStore(this)) { |
|
|
|
} else if (util.memoryStore(this)) { |
|
|
|
return this.decodeFromMemory(offset, memory) |
|
|
|
return this.decodeFromMemory(offset, memory) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return '<decoding failed - no decoder for ' + this.location + '>' |
|
|
|
return { error: '<decoding failed - no decoder for ' + this.location + '>' } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|