14 lines
449 B
Kotlin
14 lines
449 B
Kotlin
package tinyvm
|
|
|
|
sealed class Node(type: String) : Object(type)
|
|
|
|
class Tree(val nodes: Map<String, Node>) : Node("tree") {
|
|
// For simplicity just use the hex-formatted hash, not the actual value like git does.
|
|
override val data: String
|
|
get() =
|
|
nodes.map { (name, node) ->
|
|
"${node.type} $name\u0000${node.hash()}"
|
|
}.sorted().joinToString()
|
|
}
|
|
|
|
class Blob(override val data: String) : Node("blob") |