blob: 66d74b29563cef027347a690055ed20f64ac53e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package moe.nea.lisp
class StackFrame(val parent: StackFrame?) {
val variables = mutableMapOf<String, LispData>()
interface MetaKey<T>
private val meta: MutableMap<MetaKey<*>, Any> = mutableMapOf()
fun <T : Any> getMeta(key: MetaKey<T>): T? {
return meta[key] as? T
}
fun <T : Any> setMeta(key: MetaKey<T>, value: T) {
meta[key] = value
}
fun resolveReference(label: String): LispData? =
variables[label] ?: parent?.resolveReference(label)
fun setValueLocal(label: String, value: LispData): LispData {
variables[label] = value
return value
}
fun fork(): StackFrame {
return StackFrame(this)
}
}
|