Commit 918ae29e authored by Mark Tyneway's avatar Mark Tyneway

ast: cleanup

parent ab777b4c
...@@ -61,6 +61,9 @@ func CanonicalizeASTIDs(in *solc.StorageLayout) *solc.StorageLayout { ...@@ -61,6 +61,9 @@ func CanonicalizeASTIDs(in *solc.StorageLayout) *solc.StorageLayout {
continue continue
} }
// The storage types include the size when its a fixed size.
// This is subject to breaking in the future if a type with
// an ast id is added in a fixed storage type
if strings.Contains(oldType, "storage") { if strings.Contains(oldType, "storage") {
continue continue
} }
...@@ -106,8 +109,8 @@ func CanonicalizeASTIDs(in *solc.StorageLayout) *solc.StorageLayout { ...@@ -106,8 +109,8 @@ func CanonicalizeASTIDs(in *solc.StorageLayout) *solc.StorageLayout {
} }
func replaceType(typeRemappings map[string]string, in string) string { func replaceType(typeRemappings map[string]string, in string) string {
if typeRemappings[in] != "" { if remap := typeRemappings[in]; remap != "" {
return typeRemappings[in] return remap
} }
// Track the number of matches // Track the number of matches
...@@ -118,20 +121,8 @@ func replaceType(typeRemappings map[string]string, in string) string { ...@@ -118,20 +121,8 @@ func replaceType(typeRemappings map[string]string, in string) string {
} }
} }
// Sometimes types are nested, so handle the recursive case iteratively for _, match := range matches {
if len(matches) > 1 { in = strings.Replace(in, match.oldType, match.newType, 1)
for _, match := range matches {
in = strings.Replace(in, match.oldType, match.newType, 1)
}
return in
}
// Its safe to return on the first match here as the case with multiple
// is handled above
for oldType, newType := range typeRemappings {
if strings.Contains(in, oldType) {
return strings.Replace(in, oldType, newType, 1)
}
} }
return in return in
......
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