make struct / array label more specific

pull/7/head
yann300 8 years ago
parent 7f30c45859
commit a4a004800b
  1. 2
      src/solidity/decodeInfo.js
  2. 2
      src/solidity/types/ArrayType.js
  3. 4
      src/solidity/types/Struct.js
  4. 18
      src/ui/SolidityTypeFormatter.js

@ -181,7 +181,7 @@ function struct (type, stateDefinitions, contractName, location) {
}
var memberDetails = getStructMembers(match[1], stateDefinitions, contractName, location) // type is used to extract the ast struct definition
if (!memberDetails) return null
return new StructType(memberDetails, location)
return new StructType(memberDetails, location, match[1])
} else {
return null
}

@ -17,7 +17,7 @@ class ArrayType extends RefType {
storageSlots = arraySize * underlyingType.storageSlots
}
}
super(storageSlots, 32, 'array', location)
super(storageSlots, 32, underlyingType.typeName + '[' + arraySize + ']', location)
this.underlyingType = underlyingType
this.arraySize = arraySize
}

@ -3,8 +3,8 @@ var util = require('./util')
var RefType = require('./RefType')
class Struct extends RefType {
constructor (memberDetails, location) {
super(memberDetails.storageSlots, 32, 'struct', location)
constructor (memberDetails, location, fullType) {
super(memberDetails.storageSlots, 32, 'struct ' + fullType, location)
this.members = memberDetails.members
}

@ -9,7 +9,7 @@ module.exports = {
function formatData (key, data) {
var style = fontColor(data)
var type = ''
if (data.type !== 'array' && data.type !== 'struct') {
if (!isArray(data.type) && !isStruct(data.type)) {
type = data.type
}
return yo`<label>${key}: <label style=${style}>${data.self}</label><label style='font-style:italic'> ${type}</label></label>`
@ -17,10 +17,10 @@ function formatData (key, data) {
function extractData (item, key) {
var ret = {}
if (item.type === 'array') {
if (isArray(item.type)) {
ret.children = item.value || []
ret.self = 'Array' + '[' + ret.children.length + ']'
} else if (item.type === 'struct') {
ret.self = item.type
} else if (isStruct(item.type)) {
ret.children = item.value || []
ret.self = 'Struct' + '{' + Object.keys(ret.children).length + '}'
} else {
@ -33,7 +33,7 @@ function extractData (item, key) {
function fontColor (data) {
var color = '#124B46'
if (data.type === 'array' || data.type === 'struct') {
if (isArray(data.type) || isStruct(data.type)) {
color = '#847979'
} else if (data.type.indexOf('uint') === 0 ||
data.type.indexOf('int') === 0 ||
@ -45,3 +45,11 @@ function fontColor (data) {
}
return 'color:' + color
}
function isArray (type) {
return type.lastIndexOf(']') === type.length - 1
}
function isStruct (type) {
return type.indexOf('struct') === 0
}

Loading…
Cancel
Save