Created
March 14, 2017 22:39
-
-
Save palimondo/ffec7c42dbc97261d9ca9fdecc8a0614 to your computer and use it in GitHub Desktop.
Additions to dump the memory layout of indirect enums.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum List<Element> { | |
case End | |
indirect case Node(Element, List<Element>) | |
} | |
struct ManyListEnumHolder<Element> { | |
var a: List<Element> | |
var b: List<Element> | |
var c: List<Element> | |
var d: List<Element> | |
var e: List<Element> | |
} | |
dumpAndOpenGraph(dumping: ManyListEnumHolder<Int>(a: .End, b: .Node(1, .End), c: .Node(2, .Node(3, .End)), d: .Node(4, .Node(5, .Node(6, .End))), e: .Node(7, .Node(8, .Node(9, .Node(10, .End))))), maxDepth: 5, filename: "Many List enum") | |
indirect enum Tree<Element: Comparable> { | |
case Empty | |
case Node(Tree<Element>,Element,Tree<Element>) | |
} | |
struct ManyTreeEnumHolder<Element> where Element : Comparable { | |
var a: Tree<Element> | |
var b: Tree<Element> | |
var c: Tree<Element> | |
var d: Tree<Element> | |
var e: Tree<Element> | |
} | |
dumpAndOpenGraph(dumping: ManyTreeEnumHolder<Int>(a: .Empty, b: .Node(.Empty, 0x999999, .Empty), c: .Node(.Node(.Empty, 0x111111, .Empty), 0x222222, .Empty), d: .Node(.Empty, 0x333333, .Node(.Empty, 0x444444, .Empty)), e: .Node(.Node(.Empty, 0x555555, .Empty), 0x666666, .Node(.Empty, 0x777777, .Empty))), maxDepth: 5, filename: "Many Tree enum") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added to the main.swift from https://github.com/mikeash/memorydumper2