manage immutable

pull/1344/head
yann300 4 years ago committed by joseph izang
parent 3adf7655c1
commit bcafc4046c
  1. 11
      libs/remix-debug/src/solidity-decoder/decodeInfo.ts
  2. 4
      libs/remix-debug/src/solidity-decoder/stateDecoder.ts

@ -336,7 +336,9 @@ function computeOffsets (types, stateDefinitions, contractName, location) {
console.log('unable to retrieve decode info of ' + variable.typeDescriptions.typeString) console.log('unable to retrieve decode info of ' + variable.typeDescriptions.typeString)
return null return null
} }
if (!variable.constant && storagelocation.offset + type.storageBytes > 32) { const immutable = variable.mutability === 'immutable'
const hasStorageSlots = !immutable && !variable.constant
if (hasStorageSlots && storagelocation.offset + type.storageBytes > 32) {
storagelocation.slot++ storagelocation.slot++
storagelocation.offset = 0 storagelocation.offset = 0
} }
@ -344,12 +346,13 @@ function computeOffsets (types, stateDefinitions, contractName, location) {
name: variable.name, name: variable.name,
type: type, type: type,
constant: variable.constant, constant: variable.constant,
immutable,
storagelocation: { storagelocation: {
offset: variable.constant ? 0 : storagelocation.offset, offset: !hasStorageSlots ? 0 : storagelocation.offset,
slot: variable.constant ? 0 : storagelocation.slot slot: !hasStorageSlots ? 0 : storagelocation.slot
} }
}) })
if (!variable.constant) { if (hasStorageSlots) {
if (type.storageSlots === 1 && storagelocation.offset + type.storageBytes <= 32) { if (type.storageSlots === 1 && storagelocation.offset + type.storageBytes <= 32) {
storagelocation.offset += type.storageBytes storagelocation.offset += type.storageBytes
} else { } else {

@ -15,9 +15,13 @@ export async function decodeState (stateVars, storageResolver) {
try { try {
const decoded = await stateVar.type.decodeFromStorage(stateVar.storagelocation, storageResolver) const decoded = await stateVar.type.decodeFromStorage(stateVar.storagelocation, storageResolver)
decoded.constant = stateVar.constant decoded.constant = stateVar.constant
decoded.immutable = stateVar.immutable
if (decoded.constant) { if (decoded.constant) {
decoded.value = '<constant>' decoded.value = '<constant>'
} }
if (decoded.immutable) {
decoded.value = '<immutable>'
}
ret[stateVar.name] = decoded ret[stateVar.name] = decoded
} catch (e) { } catch (e) {
console.log(e) console.log(e)

Loading…
Cancel
Save